Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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 surveying the Monastery: (4)
As of 2015-07-05 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (61 votes), past polls