The oldest Perl code written by me I could find was located in my university account (yes, I still have access there, as I occasionally help them with projects I was once involved in). It's called array2.pl (I wonder what happened to version 1), it's modification time is the 12th November 2001 and it looks like this:
#!/usr/bin/perl -w # use integer; sub swap { $_[0]=$_[0] ^ $_[1]; $_[1]=$_[0] ^ $_[1]; $_[0]=$_[0] ^ $_[1]; } sub nsd { my ($a,$b)=@_; do { if ($a<$b) {$b-=$a} elsif ($b<$a) {$a-=$b} } until ($a==$b); return($a) } # main print ("Array size: "); chomp($n=<stdin>); print ("Shift: "); chomp($d=<stdin>); print("NSD:",nsd($n,$d),"\n"); for ($i=0;$i++<$n;$array[$i]=$i){} # for ($j=0;$j<nsd($n,$d);$j++) { $i=$n-$j; $aux=$array[$i]; unless ($next=($i+$d)%$n) {$next=$n} do { for($k=0;$k++<$n;printf("%2.0d",$array[$k]),print(",")){} print("\n"); $array[$i]=$array[$next]; $array[$next]=$aux; $i=$next; $aux=$array[$i]; unless ($next=($i+$d)%$n) {$next=$n} } until ($next==$n-$j); } for($k=0;$k++<$n;print($array[$k],",")){}

I was probably experimenting with the programming language that was new to me. For some reason, I disliked whitespace. Is this some kind of self-embarassment contest? ;-)

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

In reply to Re: What does your old Perl code look like? by choroba
in thread What does your old Perl code look like? by haukex

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.