Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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/;


Comment on Re: Cool Archlinux network script
Select or Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (18)
As of 2014-07-29 17:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (225 votes), past polls