Howdy,
I'm looking to have a one liner version of this:
Why? Do you win a cookie if you do it in one line? ;)
I win cookies at work for writing clear code, which often involves more than one line.
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?
my $xid = param('xid') =~ m/^(\d+)$/ ? $1 : '';
I could do the ? : ; dance but I'm not sure 'my' would stay in the scope I need it in.
?: doesn't affect my().
James
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>