On Apr 14, 2004, at 2:06 AM, Bryan Harris wrote:


A quick question for the wizards--

Will I do?


Is it possible to do a substitution without compiling the pattern at all?

Sure.


**************************************
#!/usr/bin/perl

$ss = "cool???";
$rs = "cool.";
$_ = "Perl is really cool???";
s/$ss/$rs/g;

The above line could also be written:


substr $_, index($_, $ss), length($ss), $rs;

print "$_\n";
**************************************

Hope that helps.


James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to