[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] [Q] use of $1, $2...



On 7/1/98 at 3:00 AM, Nobumi Iyanaga <n-iyanag@ppp.bekkoame.or.jp> wrote:

>Hello,

>But if I comment out the line "$a =~ s/ //;", I get the expected result:
>
>a =  abcde., b =  egi
>
>Must I think that something is changed in $2 when I remove the space in $a??


Nobumi,

Yep, it changes, because of the regexp in the substitution. You can avoid losing the backmatches by using tr:

$a =~ tr/ //d;

tr is often more efficient than using the s operator.

>Thank you in advance for any explanation.
>
>Nobumi Iyanaga
>Tokyo,
>Japan

j
--
#!/usr/bin/perl
$dot="\x2e";$lt="\x3c";$gt="\x3e";$at="\x40";
print "J Mignault ${lt}mignault${at}nytimes${dot}com${gt}\n";
$quote = qq("They'll get my perl when they pry it from my cold, dead /usr/local/bin." --Randy Futor in  <1992Sep13.175035.5623\@tc.fluke.COM>);
--
#!/usr/bin/perl
$dot="\x2e";$lt="\x3c";$gt="\x3e";$at="\x40";
print "J Mignault ${lt}mignault${at}nytimes${dot}com${gt}\n";
$quote = qq("They'll get my perl when they pry it from my cold, dead /usr/local/bin." --Randy Futor in  <1992Sep13.175035.5623\@tc.fluke.COM>);



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch