[EMAIL PROTECTED] wrote:
Can someone please tell me, why
my $pattern = /stuff/;
That is short for:
my $pattern = $_ =~ m/stuff/;
Which assigns 1 to $pattern if the match succeeded or
'' if it failed.
$x =~ $pattern;
Which means that this is either:
$x =~ /1/;
Or:
$x =~ //;
or
my $pattern = "/stuff/";
Here you include the '/' character in the pattern which
is probably not present in the string you are matching.
$x =~ $pattern;
So this becomes:
$x =~ /\/stuff\//;
don't work the same as
$x =~ /stuff/;
You need to either store the pattern in a string or use
the qr operator.
my $pattern = 'stuff';
my $pattern = qr/stuff/;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>