Charles K. Clarkson wrote:

>   Try:
>
>$q->param('jahr', 4444 );
>my ($jahr) = $q->param('jahr') =~ /\d{4}/;
>print $jahr;
>
>--
>prints:
>1
>--
>
>    Now try it this way:
>
>$q->param('jahr', 4444 );
>( my $jahr = $q->param('jahr') ) =~ /\d{4}/;
>print $jahr;
>
>--
>prints:
>4444

Wait a second... your second version does only print '4444' if the original 
$q->param('jahr') contains only 4 digits. Try the same with 

$q->param('jahr', 44445555 );
( my $jahr = $q->param('jahr') ) =~ /\d{4}/;
print $jahr;

--
prints:
44445555

You assign the whole $q->param('jahr') to $jahr and then match 4 digits in the 
resulting string - without changing the value of a variable.

My original version (I posted a messed up intermediate version, sorry for that) says:

my ($jahr) = $q ->param('jahr') =~ /(\d{4})/;

Note the brackets around both the variable $jahr and the regex. This assigns $1 to 
$jahr in list context.

Thanks,

Jan

-- 
There's no place like ~/

--
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