Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: Pattern matching

by choroba (Bishop)
on Feb 01, 2013 at 10:30 UTC ( #1016508=note: print w/replies, xml ) Need Help??

in reply to Re: Pattern matching
in thread Pattern matching

Yes, and pray for \" not appearing in the data.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^3: Pattern matching
by perlCrazy (Monk) on Feb 01, 2013 at 10:35 UTC
    Thanks for help and input. below code works fine:
    my $file = "t.txt"; open(FH,$file) || die "can't open file \n"; while (<FH>) { chomp; my $line = $_; $line =~ s/\"(.*?)\"/replace($1)/ge; $line =~ s/\,/~/g; $line =~ s/\;/,/g; print "$line \n"; } close FH; sub replace { my ($str) = @_; $str =~ s/\,/\;/g; return $str; }
      perlCrazy like choroba has mentioned its easy to miss certain cases - Best to use a module that's been put through its paces on all kinds of different data.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1016508]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-06-25 05:25 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.