s/ / /; - doing harm ?

s/ / /; - doing harm ?

am 09.06.2009 09:28:59 von Stanislaw Romanski

This is a multi-part message in MIME format.

--===============1708923932==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0057_01C9E8E4.B82C5370"

This is a multi-part message in MIME format.

------=_NextPart_000_0057_01C9E8E4.B82C5370
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable

Hello,

Please, consider the following short script.
#-----------------------------------------------------
$_ =3D '';

s// /; ## if any of these two lines is commented out,
s/ / /; ## the printed result wil be ok, i.e. '=3D =3D' WHY ?

$_ =3D '';
s// /;
print "=3D$_=3D\n"; ## prints incorrect '=='
#-----------------------------------------------------

This was tested on Win'XT ActivePerl 5.8.8. and 5.8.9.

What is wrong ?

Thanks for any hints,

Stanislaw Romanski
------=_NextPart_000_0057_01C9E8E4.B82C5370
Content-Type: text/html;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable



charset=3Diso-8859-2">




Hello,

 

Please, consider the following short=20
script.


size=3D2>#-------------------------------------------------- ---
$_ =3D '';

 

    s//=20
/;      ## if any of these two lines is =
commented=20
out,
    s/ / /;     ## the =
printed result=20
wil be ok, i.e. '=3D =3D' WHY ?

 

$_ =3D '';
s// /;
print=20
"=3D$_=3D\n";         ## prints =
incorrect=20
'=='
#-----------------------------------------------------
=

 

This was tested on Win'XT ActivePerl 5.8.8. and 5.8.9.

 

What is wrong ?

 

Thanks for any hints,

 

Stanislaw Romanski


------=_NextPart_000_0057_01C9E8E4.B82C5370--


--===============1708923932==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============1708923932==--

Re: s/ / /; - doing harm ?

am 09.06.2009 09:41:20 von Bill Luebkert

Stanislaw Romanski wrote:
> Hello,
>
> Please, consider the following short script.
> #-----------------------------------------------------
> $_ = '';
>
> s// /; ## if any of these two lines is commented out,
> s/ / /; ## the printed result wil be ok, i.e. '= =' WHY ?
>
> $_ = '';
> s// /;
> print "=$_=\n"; ## prints incorrect '=='
> #-----------------------------------------------------
>
> This was tested on Win'XT ActivePerl 5.8.8. and 5.8.9.
>
> What is wrong ?

If you check the perlop pod under s///, you should find this:
"If the pattern evaluates to the empty string, the last
successfully executed regular expression is used instead."
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: s/ / /; - doing harm ?

am 09.06.2009 09:51:22 von Stanislaw Romanski

----- Original Message -----
From: "Bill Luebkert"
To: "Stanislaw Romanski"
Cc:
Sent: Tuesday, June 09, 2009 9:41 AM
Subject: Re: s/ / /; - doing harm ?


> Stanislaw Romanski wrote:
>> Hello,
>>
>> Please, consider the following short script.
>> #-----------------------------------------------------
>> $_ = '';
>>
>> s// /; ## if any of these two lines is commented out,
>> s/ / /; ## the printed result wil be ok, i.e. '= =' WHY ?
>>
>> $_ = '';
>> s// /;
>> print "=$_=\n"; ## prints incorrect '=='
>> #-----------------------------------------------------
>>
>> This was tested on Win'XT ActivePerl 5.8.8. and 5.8.9.
>>
>> What is wrong ?
>
> If you check the perlop pod under s///, you should find this:
> "If the pattern evaluates to the empty string, the last
> successfully executed regular expression is used instead."
>

Hello Bill,

Thanks for (en)lightning answer.
You saved a few hours of my frustration ;-)

Stanislaw Romanski
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs