On Sat, 01 Dec 2001 at 22:36:59 +0000, Jonathan E. Paton wrote:
> Okay, more imagination required.  Lets abuse the symbol
> table since I'm bored,

> --- PERL SCRIPT ---
> #!/usr/bin/perl -w
> while (<>) {
>     eval qq(\*main\:\:A$.=sub { print \"$_\" });
> }
> if ($. == 0) { exit; }

> my $middle = int ($. / 2) + 1;
> eval qq(main\:\:A$middle\(\));
> --- END PERL SCRIPT

You don't need 'eval' just to munge the symbol table:

perl -ne '${L.$.}=$_;END{print ${L.(1+$.>>1)}}'

or, closer to your idea - this one creates some closures:

perl -e 'while(my$x=<>){*{L.$.}=sub{print$x}};&{L.(1+$.>>1)}'

Ian
  • ... Greg Bacon
    • ... Michael G Schwern
      • ... Dmitry Kohmanyuk Дмитрий Кохманюк
        • ... Greg Bacon
          • ... ianb
          • ... Ian Phillipps
            • ... Jonathan E. Paton
              • ... Greg Bacon
              • ... Jonathan E. Paton
              • ... Jonathan E. Paton
              • ... Ian Phillipps
          • ... Keith C. Ivey
            • ... Greg Bacon
              • ... Vladi Belperchinov-Shabanski
    • ... Vladi Belperchinov-Shabanski
  • ... Newton, Philip
  • ... Santa Claus
  • ... Andrew . Savige
    • ... Yanick
      • ... Jeff 'japhy' Pinyan
        • ... Dave O'Neill

Reply via email to