in reply to How's your Perl? (II)
Spoilers:
1:
$foo = *bar; \$foo =~ /^[A-G]/ and print "Ok!\n";
7:
*foo = *1; !eval { ($foo) = $foo } and print "Ok\n";
6: I don't know weather this is cheating or not, but it does make the (updated) expression true:
*foo = *_; sub { \$foo[0] == \$foo[1] && !$[ and print "Ok\n"; } -> ($ +x, $x);
Update: a clean solution for 6:
sub{*foo=\@_}->($x,$x); \$foo[0] == \$foo[1] && !$[ and print "Ok!\n";
Update again: 2:
*foo = \substr(1,0,1); \$foo =~ /^[H-N]/ and print "Ok!\n";
Update: a wildcard solution for 3:
BEGIN{$^H{"qr"}=sub{""};$^H|=3<<16}; \$foo =~ /^\0/ and print "Ok!\n";
Update: I finally realized that I should have known 12 from the start: it was in last year's quiz.
$[ = 2; *| = *[; ($| = 1) == 2 and print "Ok!\n"; warn 0+$|;
Update: and here's an answer for 8, although you might take it as cheating as it requires an adittional option on the command line to be set.
Update: you can give the switch in the shebang line too. If you write this to a file and execute it with perl, it works.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How's your Perl? (II)
by wog (Curate) on Jul 22, 2004 at 19:37 UTC |