Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: reduce line of code

by ysth (Canon)
on Jul 14, 2009 at 06:36 UTC ( #779809=note: print w/replies, xml ) Need Help??


in reply to Re: reduce line of code
in thread reduce line of code

I often prefer setting a default, then overwriting with the validated value:
my $cmd = 0; $cmd = $step_no if $step_no =~ /\A\d+\z/;

Replies are listed 'Best First'.
Re^3: reduce line of code
by lima1 (Curate) on Jul 14, 2009 at 08:52 UTC
    I guess this is what Sun751 meant. His non-working example scopes the $cmd variable to the if ... else blocks.
      OT: just add
      use strict ; use warnings ;
      to your programs, witch would have detected your scoping problem!

      LuCa

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779809]
help
Chatterbox?
[Discipulus]: if DE or WM means desktop env and win manager.. no, not an option
[Lady_Aleena]: That's what they mean, at least to me. 8)
[Discipulus]: in the first attempt i failed, with an not usable v-machine.. ;=)
[Discipulus]: but then discovered a registry trick to do before the physical2virtual migration
[Lady_Aleena]: Sounds like a headache.
[Discipulus]: a bit shaggy.. every atttempt is ~4hours to virtualize and 1-2hours to kick the big file to boot..
[Lady_Aleena]: Ouch...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2017-05-22 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?