(update: the first one has been edited to fix problems/bad style since I first pressed submit. Oopsie.)
use strict;
my @result;
my $one = "a" =~ /./;
sub add {
my($vA,$vB) = @_;
($vA,$vB) = ($vA^$vB,($vA&$vB)<<$one) while $vB;
return $vA;
}
my $val = $one;
do {
push @result, $val;
$val = add($val,$one);
} until $one.$one eq $val;
... or, without any lines preceeding it in the file it's
in ...
sub f { die if $::f_A;
die if $::f_B;
die if $::f_C;
die if $::f_D;
die if $::f_E;
die if $::f_F;
die if $::f_G;
die if $::f_H;
die if $::f_I;
die if $::f_J; }
my @vars = map { "::f_$_" } qw(A B C D E F G H I J);
my @result;
foreach (@vars) {
$$_ = "true";
eval { f() };
push @result, $@ =~ /line ([^.]+)\./;
$$_ = undef;
}
update: A very, very cheap solution: (doesn't work on EBCDIC systems, sorry)
my @result = split " ", "pasarauatawavayaxapq"^"AAAAAAAAAAAAAAAAAAAA";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.