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

Re: [FWP] Parsing (simple)



Jeff Boes <jboes@qtm.net> wrote:

> Elegant (fun) solution: use perl itself.
> 
> $snippet = "...";  # long, hairy code here.
> eval "package code; $^W=0; $snippet";
> @variables = keys %code::;

How about this?

    local $SIG{__WARN__} =
        sub {
            push @variables,
                $_[0] =~ /Global symbol "([^"]+)" requires/g;
        };
    eval "use strict; $snippet";

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC

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