karlgoethebier has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
by chance i stumbled over this:
#!/usr/bin/env perl # http://perlmonks.org/?node_id=1196297 # $Id: wantarray.pl,v 1.4 2017/07/30 10:03:17 karl Exp karl $ use strict; use warnings; use Try::Tiny; use Getopt::Long; use feature qw(say); my $flag; GetOptions( "flag" => \$flag ) or die(qq(Fubar\n)); my $array = [ 1 .. 10 ]; say join "|", @$array; say join "|", nose($array); try { ($flag) ? say join "|", nose() : nose(); } catch { warn $_; }; sub nose { my $array = shift; map { --$_ } @$array; die "Jackass!" unless defined wantarray; (wantarray) ? @$array : $array; } __END__
I tried to reduce the problem as much as i could.
And perhaps i have one these famous mental blocks again.
Thanks for any hint and best regards, Karl
«The Crux of the Biscuit is the Apostrophe»
perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "Try join say" or why is this exception not caught?
by shmem (Chancellor) on Jul 30, 2017 at 11:24 UTC | |
by karlgoethebier (Abbot) on Jul 30, 2017 at 11:34 UTC | |
|
Re: "Try join say" or why is this exception not caught?
by haukex (Archbishop) on Jul 30, 2017 at 10:43 UTC | |
by karlgoethebier (Abbot) on Jul 30, 2017 at 10:51 UTC | |
by haukex (Archbishop) on Jul 30, 2017 at 10:56 UTC | |
by karlgoethebier (Abbot) on Jul 30, 2017 at 11:26 UTC |