Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

vrk's scratchpad

by vrk (Chaplain)
on Mar 01, 2007 at 16:04 UTC ( #602708=scratchpad: print w/replies, xml ) Need Help??

Two neat concepts I noticed in perlsub and perlref in February, 2007:

# Try and catch using prototypes. (Almost verbatim from perlsub.) sub try (&$) { my ($try, $catch) = @_; eval { &$try; }; if ($@) { local $_ = $@; &$catch; } } sub catch (&) { $_[0] } try { die "phooey"; } catch { /phooey/ and print "unphooey\n"; };
# Nested subroutines. sub frobnicate { my $input = shift; local *grok = sub { my $input = shift; # grok's $input is lexical, and therefore # different from the outer $input. return $input . " grokked!"; }; # Note the semicolon. return grok($input); } print frobnicate('foo'), "\n"; # However, this will work as well. sub frobnicate_again { my $input = shift; local *grok = sub { return $input . " grokked!"; }; return grok($input); } print frobnicate_again('foo'), "\n";

I always wondered how to do the latter in Perl.

A feature not known to me, learned while reading Programming Perl (3rd ed.):

my $ip =; printf "%vd\n", $ip;
Log In?

What's my password?
Create A New User
[choroba]: RonW Yes, but then, one day, they needed to switch from FTP to SFTP, and... but I can't give the whole talk away here :)
[RonW]: Tunnel FTP through stunnel?
[james28909]: i guess i should have done it in perl. i bet it woulnt have taken me 5 hours to figure out haha
[choroba]: In the end, I was able to upgrade Perl from 5.8.3 to 5.22 and install Net::SFTP::Foreign , at least for the task involved
[james28909]: what would be the best way to capture that stream with perl? ffmpeg args -rtp rtp://
[LanX]: if I was forced to talk about all security risks I encountered oO

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2017-05-22 21:45 GMT
Find Nodes?
    Voting Booth?