Rus Foster <[EMAIL PROTECTED]> writes:
> my $foo="bar";
> $_ = $foo;
> $foo =~ s/bar/goo/g;
>
> There has to be a better way hasn't there?
Define "better". You've actually got two metaphores running side by
side.
Either use a named scalar variable:
my $foo="bar";
$foo =~ s/bar/goo/g;
Or use the (scratchpad) default:
$_ = $foo;
s/bar/goo/g;
You *could* on-line it, but I don't think that's "better". This
assigns a string to the scalar $foo (or $_), then immediately performs
a substitute on it.
($foo = "bar") =~ s/bar/goo/g;
($_ = "bar") =~ s/bar/goo/g;
Better? I think not (therefore I am not?)
Different, but not better.
--
Michael R. Wolf
All mammals learn by playing!
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]