Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Let's do it transparently

by jwkrahn (Monsignor)
on Sep 06, 2011 at 22:46 UTC ( #924480=note: print w/replies, xml ) Need Help??


in reply to Let's do it transparently

sub os_port { foreach (@_) { $sock = new IO::Socket::INET(PeerAddr => $server, PeerPort => $_, Proto => 'tcp'); last if $sock; } $sock; }

Subroutines defined at compile time have package scope so it makes little sense to define them inside a loop.    You will never get a new subroutine for each loop iteration.



while (<$sock>) { $sock_string = $_; last; }

Why not just:

$sock_string = <$sock>;

Replies are listed 'Best First'.
Re^2: Let's do it transparently
by rustic (Monk) on Sep 07, 2011 at 07:40 UTC
    I do completely agree with you jwkrahn. Regarding the subroutine invocation I didn't realize this misfunctionality. Regarding the while (<$sock>) {} loop I was looking to grab the result I need from a few lines response I got in my test, so this left like that. Thank you for rectifications indeed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://924480]
help
Chatterbox?
[shmem]: hmm...
[shmem]: Lady_Aleena: perl -MMP3::Tag -MFile::Find -le 'find(sub{if($File ::Find::name=~/\. mp3$/){$sum+=MP3:: Tag->new($_)-> interpolate("\%S ")} }, "Music"); print "total seconds: $sum"'
[Lady_Aleena]: shmem, sorry I was outside for a moment moving my car out of hubby's way.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2017-04-23 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.