Philipp Marek
marek@bmlv.gv.at
AUSTRIA/EUROPE


Categories: most powerful


I had this idea for a long time, and once it worked,
there was no problem implementing it.

First I tried to get it into 512 bytes (without \s),
but after some time with still 125 bytes to shorten 
I gave up and remembered the sentence "a maximum
of 512 bytes (not including whitespace".
    
So, if whitespace dont count, they dont count ...


I wrote a perl 'script' to convert my program in a 
bitstring (pack), then translated the 0s and 1s to
whitespace - No problem with the limit and funny
to look at with vi's ":set list"



Ok, so here is the original with long varnames:

#START OF PERL SCRIPT
#!/usr/bin/perl

die "arg: .tar-file" unless @ARGV==1 && -r ($_=shift);

%d=(\%r,"root of archive");

open(F,"tar tvf $_ |") || die "tar cries";

$_=<F>;

/^(.*\d+:\d+\s+19\d{2}\s+)/;

$p=length($1) || die "unknown tar-format";

do
{
  chomp;

  ($f=substr($_,$p)) =~ s/ -> .*//;
  $a=\%r;
  $y=$f;
  while ($f =~ m#([^/]+)/#g)
  {
    $x=\%{${$a}{$1}};
    ($a,${$x}{".."})=($x,$a);
    $y=$';
  }

  ${$a}{$y}=$_; 
  $d{$a}=$f unless $y;
}
while (<F>);

$N=\%r;
while (1)
{
  print "> ",$d{$N},"\n\nls cd X> ";
  last unless $_=<>;
  if (/^ls/i)
  {
    open(F,"| " . $ENV{"PAGER"}) || die;
    print F join("\n", 
	map { ref($y=${$N}{$_}) ? ${$y}{""} : $y } 
	  sort grep(!/\.\./,keys %$N)),"\n";
    close(F);
  }
  elsif (/X/)
  {
    last;
  }
  elsif (($_)=/^cd (.*)/i)
  {
    $N=\%r if s#^/+##;

    for(split(m#/#))
    {
      warn("$_ not found/no directory"),last
	unless ref($n=${$N}{$_});
      $N=$n;
    }
  }
}
#END OF PERL SCRIPT
