John W. Krahn wrote:

"Jupiterhost.Net" wrote:

Howdy,


Hello,


I'm looking to have a one liner version of this:

my $xid = '';
$xid = param('xid') if param('xid') =~ m/^\d+$/;

Basically, if the param is numeric then assign it to $xid, other wise ''
(IE empty but declared) Some thing like:

my $xid = param('xid') if param('xid') =~ m/^\d+$/ || '';

But I know that that is not right, what am I missing?

I could do the ? : ; dance but I'm not sure 'my' would stay in the scope
I need it in.


This will work if param('xid') returns anything but undef:

my ( $xid ) = param( 'xid' ) =~ /(^\d+$|)/;

I like that, good idea. It is possible it may be undef though, doh! thx

John

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