Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Cool Archlinux network script

by jwkrahn (Monsignor)
on May 26, 2012 at 07:36 UTC ( #972585=note: print w/replies, xml ) Need Help??


in reply to Cool Archlinux network script

return $inp or "";

Because of the low precedence of the or operator that will not do what you seem to think it will:

$ perl -le' sub prompt { my $inp = shift; return $inp or "zzz"; } print prompt( $_ ) for undef, 0, 1, 2; ' 0 1 2

You need to use the higher precedence || operator:

$ perl -le' sub prompt { my $inp = shift; return $inp || "zzz"; } print prompt( $_ ) for undef, 0, 1, 2; ' zzz zzz 1 2



while ( chomp(my $inpt = <STDIN>) != 0 ) {

That is usually written as:

while ( my $inpt = <STDIN> ) { chomp $inpt;



system("ifconfig wlan0 up") if ( (my $ifconf = `ifconfig`) + !~ /wlan0/ );

You never use the $ifconf variable anywhere else in your program so why are you creating it?    Just do:

system 'ifconfig wlan0 up' if `ifconfig` !~ /wlan0/;

Replies are listed 'Best First'.
Re^2: Cool Archlinux network script
by heatblazer (Scribe) on May 26, 2012 at 10:17 UTC

    Hmm.. I`ve forgot about it... I was trying some experiments with it with SIGNAL global hash...

Re^2: Cool Archlinux network script
by heatblazer (Scribe) on May 31, 2012 at 18:55 UTC

    Thanks for replying. I think that these low and high precedences are confusing... from now on I`ll just stick to ?: operator...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://972585]
help
Chatterbox?
marioroy I once fell asleep while drive and had no collection on how I exited the ramp. Then called my wife not knowing where I was totally lost.
marioroy At a large firm, had to awaken a security guy a few times so that nobody would catch him sleeping.
marioroy On a large dairy farm, almost went off the road with a 10 wheeler from exhaustion. On the farm, almost went off the silo with a big tractor. At the Fransiscan monastery, almost slipped off the dome while painting it.
[marioroy]: In Saudi Arabia caught fire but didn't burn. I think angels exist.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2017-05-29 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?