Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: socket help

by snoopy (Deacon)
on Feb 14, 2011 at 02:30 UTC ( #887911=note: print w/replies, xml ) Need Help??

in reply to socket help

The implicit use of global $_ in the client code seems a bit odd. This variable is not set explicitly from the command line without careful invocation:
echo myarg | perl -nle 'print "ARG=<$_>\n"' ARG=<myarg>

You're better off, at least, fetching from ARGV:

my ($hostname) = @ARGV; die "usage: $0 hostname" unless $hostname; my $socket = new IO::Socket::INET ( PeerAddr => $hostname, PeerPort => '7071', Proto => 'tcp', );
...or however you want to parse the command line arguments in @ARGV.

Replies are listed 'Best First'.
Re^2: socket help
by Anonymous Monk on Feb 14, 2011 at 02:47 UTC
    $_ is supposed to be $ARGV[0].
    PeerAddr => $ARGV[0],
    I've also tried using backticks
    chomp(my $output = `ls /tmp 2>&1`);
    It's like the client isn't waiting for the server to finish

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://887911]
holli writes MonkLinks 2.0
[holli]: Just to have a look what all the fuzz about the new JS features is about
[holli]: tag auch. wir sind ja unter uns :)
[Corion]: Hi holli ;)
[Corion]: In a way, it's sad that Firefox kills off the add-on functionality... But, as n-gate usually writes, "Firefox tries to be more like Chrome"
[holli]: it's not always possible to do a complete rewrite without cutting off some pigtails
[Discipulus]: indeed! new firefox seems poorer: many tab crash, and you open this link in FF?

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2017-11-20 19:00 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.