prodevel has asked for the wisdom of the Perl Monks concerning the following question:
Client:#!/usr/local/bin/perl use IO::Socket::INET qw(CRLF); my $client = IO::Socket::INET->new('blade:12333') or die "new: $@"; while (<$client>) {if ($_ =~ /file: (.*)/) {open(FOUT,">>$1") || die "cannot create: $1";} elsif ($_ =~ /EOF/) {close(FOUT);} else {print FOUT;} }
Besides the obvious perl security/etc. flags, what do think? I wrote this back in 2004 so I'm curious how it holds up, etc.#!/usr/local/bin/perl use IO::Socket::INET qw(CRLF); my $client = IO::Socket::INET->new('blade:12333') or die "new: $@"; while (<$client>) {if ($_ =~ /file: (.*)/) {open(FOUT,">$1") || die "cannot create: $1";} elsif ($_ =~ /EOF/) {close(FOUT);} else {print FOUT;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Simple perl socket code. Any way to improve/simplify it?
by NetWallah (Canon) on Jan 23, 2020 at 18:14 UTC | |
by afoken (Chancellor) on Jan 23, 2020 at 18:40 UTC | |
|
Re: Simple perl socket code. Any way to improve/simplify it?
by tybalt89 (Monsignor) on Jan 23, 2020 at 13:59 UTC | |
|
Re: Simple perl socket code. Any way to improve/simplify it?
by tybalt89 (Monsignor) on Jan 23, 2020 at 05:53 UTC | |
|
Re: Simple perl socket code. Any way to improve/simplify it?
by Anonymous Monk on Jan 23, 2020 at 06:24 UTC |