Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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?
[robby_dobby]: I was falling asleep at my chair and threw out that one bit about participating in a YAPC. Things went from there :-)
[erix]: never too late to pull legs
[LanX]: Official YAPC Africa 2013 Announcement
erix always game to pull legs from sleeping cells
[erix]: hm nice might do a spot of diving - Red Sea is said to be beautiful
[LanX]: well too many terrorist tourists
[erix]: I guess I can pass for a native
[LanX]: talking about destruction of diving spots
[LanX]: Nodes to consider
[erix]: oops - got to run, see you later

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2017-04-24 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (442 votes). Check out past polls.