Jack B. Nymbol has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I like to scope out perl things via perl -de 'print' then try out things in the debugger. But I guess that my scope isn't my idea of scope. Oh our, our. I hope the answer doesn't go toward my and our and is simple.
perl -de 'print' ... main::(-e:1): print DB<1> my $x = localtime DB<2> x $x 0 undef DB<3> p $x DB<4> $t = localtime DB<5> x $t 0 'Tue Jan 3 12:28:40 2012' DB<6> p $t Tue Jan 3 12:28:40 2012 DB<7>
Looking for the simplest answer. Thanks all.

Replies are listed 'Best First'.
Re: Oh my perl, oh why perl? Perl debugger idiosyncrasies?
by BrowserUk (Patriarch) on Jan 03, 2012 at 20:43 UTC

    Every time you run a command you are evaling that code. And each eval has its own scope. Ie. my vars created within it disappear as soon as the eval ends.

    But as you're just testing stuff, why worry about scoping?

    In my repl, which is effectively similar to running in the debugger, I just forget about my (and our). And when I've tested the idea I just ^C & restart the repl to get a clean slate.

    Definitely not recommended for real programs, but for just trying things it's fine. Less typing too :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?