M Z wrote: > hello all - > > I am trying to do the following to this data: > input: > X|Y||||Z||A > > desired output: > X|Y| | | |Z| |A > > simply replacing || with | | > whereever it may occur in the string. > > This bit of code doesn't seem to do all of the job. > > What is wrong with this code? > > while (<>) { > while($_ =~ /([|])([|])/g) { > $_ =~ s/([|])([|])/$1 $2/g; > print "$_"; > } > } > > The problems seems that my bit of code doesn't > completely catch "all" of the || occurences within a > given line. Please help!!! >
try: #!/usr/bin/perl -w use strict; (my $string = 'X|Y||||Z||A') =~ s/\|(?=\|)/| /g; print "GET: $string\n"; print "EXPECTED: X|Y| | | |Z| |A\n"; __END__ prints: GET: X|Y| | | |Z| |A EXPECTED: X|Y| | | |Z| |A david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]