Thanks.
I used the longer one (I usually prefer readability), but I wanted to know
the shorter way to.
Yossi
"Offer Kaye"
<oferk at oren.co.i To: "Perl in Israel" <perl at perl.org.il>
l> cc:
Sent by: Subject: RE: [Israel.pm] regex substitue with lookup table
perl-bounces at per
l.org.il
03/28/2004 12:02
Please respond
to Perl in
Israel
> Hi,
>
> I have a code that looks like this:
>
> if (/someText (.+?) someMoreText (\d+)/)
> {
> if (exists $hash{$2})
> {
> my $newStr=$hash{$2};
> s/someText $newStr someMoreText/;
> }
> }
>
> I know There Is Another Way To Do It, and even a shorter one - how ?
>
> Thanks
>
> Yossi
>
> Sorry,
> It should be:
> s/someText (.+?) someMoreText/someText $newStr someMoreText/;
>
Ah, I see now. Well, I guess one shorter version of the above code is:
s/someText (.+?) someMoreText (\d+)/(exists $hash{$2})?"someText $hash{$2}
someMoreText $2":"someText $1 someMoreText $2"/e;
But frankly in this case I personally would go for the longer way- it's
simply more readable.
----------------------------------
Offer Kaye
_______________________________________________
Perl mailing list
Perl at perl.org.il
http://www.perl.org.il/mailman/listinfo/perl