I'm not really giving you the answer you're looking for, but here is one way
to go about it:
while(<>){
my @temp = split(/\|/,$_);
foreach my $item(@temp){
if($item eq ''){
$item .= ' ';
}
}
print join('|',@temp);
}
-----Original Message-----
From: M z [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 12, 2003 3:35 PM
To: [EMAIL PROTECTED]
Subject: misunderstanding the /g modifier on REGEX
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!!!
__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]