[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Quine and idea



&{$e=sub{
    require(B::Deparse);
    print '&{$e=sub' . 'B::Deparse'->new->coderef2text($e) . "}\n";
}}

__END__

#!/usr/bin/perl -w

# Has this been done already?

sub UNIVERSAL::new {
  my ($meth) = +(caller(0))[3] =~ /::([^:]*)$/;
  my $class = shift;
  (my $file = $class . ".pm") =~ s#::#/#g;
  !$INC{$file}
    or require Carp, Carp::croak(qq{Can't locate object method "$meth"}
    .qq{ via package "$class"});
  eval "require $class"
    or require Carp, Carp::croak(qq{Can't locate object method "$meth"}
    .qq{ via package "$class" (no module with that name)});
  return $class->$meth(@_);
}

print IO::File->new;

__END__


-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe