in reply to Re: return stripped characters
in thread return stripped characters

I would recommend avoiding the eval by assigning as a separate step:
$salutation =~ s/(\(.*?\))// and $stripped = $1;
or some such.

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^3: return stripped characters
by cog (Parson) on Apr 26, 2005 at 15:45 UTC
    True. My mind was thinking of global substitutions.
Re^3: return stripped characters
by radiantmatrix (Parson) on Apr 26, 2005 at 19:06 UTC

    Or, to use a conditional if construct:

    my $stripped; $stripped = $1 if $salutation =~ s/(\(.*?\))//;

    This is functionally equivalent to the parent post, just a different style of expressing it.

    Update: I was trying to be too concise, thanks to tlm for pointing me to the error of my ways. Code has been updated to predeclare $stripped, since that is much more reliable than declaration and assignment in one step with a conditional.

    radiantmatrix
    require General::Disclaimer;
    s//2fde04abe76c036c9074586c1/; while(m/(.)/g){print substr(' ,JPacehklnorstu',hex($1),1)}

      Nope. (See NOTE at the end of the cited section.)

      the lowliest monk