Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: script to listen on a port & redirect to a file

by a31modela (Initiate)
on Aug 14, 2015 at 18:58 UTC ( [id://1138630]=note: print w/replies, xml ) Need Help??


in reply to Re: script to listen on a port & redirect to a file
in thread script to listen on a port & redirect to a file

thanks for the quick reply.... so are you saying the script should look like this ?

my $new_sock = $sock->accept(); open my $fh, '>>', $file or die $!; while(<$new_sock>) { print <$fh>; #######close $fh; }

Is this what you mean?

thanks, steve

Replies are listed 'Best First'.
Re^3: script to listen on a port & redirect to a file
by VinsWorldcom (Prior) on Aug 14, 2015 at 19:41 UTC

    I think he means:

    [...] open my $fh, '>>', $file or die $!; while(<$new_sock>) { print $fh $_; } [...]

    Alternatively, just add:

    $|++

    before the "$sock->accept()" call in your original script and the redirect to file will work.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1138630]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-24 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found