Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Oops, sorry about that. I'd given the answer in a /msg and totally forgotten that I hadn't given it in a node.

Recall that this is a fairly ambiguous question, and that my answer really just reveals what the source considers to be different scopes.

That answer is found in cop.h, line 360 as of recent perls.

#define CXt_NULL 0 #define CXt_SUB 1 #define CXt_EVAL 2 #define CXt_LOOP 3 #define CXt_SUBST 4 #define CXt_BLOCK 5 #define CXt_FORMAT 6

OK, the easy ones first

  • CXt_LOOP is for, e.g., while (<>) { ... }.
  • CXt_BLOCK is for regular old blocks, like do { ... } while <>.
  • CXt_EVAL is for eval STRING, not eval BLOCK, which is covered by CXt_BLOCK.
  • CXt_SUB is for a subroutine.

That leaves three: CXt_NULL, CXt_SUBST, and CXt_FORMAT. You can probably guess what CXt_SUBST and CXt_FORMAT do, even though the fact that they start new scopes may be surprising.

[~] $ perl -le'$_="foo";s/foo/my $x="bar"/e;print;print ">>>$x<<<"' bar >>><<<

There's s/// creating a new scope. Here's format:

[~] $ cat tmp/format format = @<<<<<<< my $x = "foo" . write; print ">>>$x<<<"; [~] $ perl -l !$ perl -l tmp/format foo >>><<<

OK, so what does that leave us with? CXt_NULL. CXt_NULL is the block passed to `sort', strangely enough. It's also referred to as a pseudo-block throughout the source.


In reply to (Answers) Re: Barstool Trivia by dchetlin
in thread Barstool Trivia by dchetlin

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [choroba]: I don't happen to have 5.10.0 nor 5.8.5 handy...
    [Corion]: Hmm - I would say the 5.8.5 is a broken installation / corrupt tarball download, and the 5.10.0 is really weird, and maybe a bug in that version of Perl
    [Corion]: I don't see how my $result = eval q{'abc' =~ ?b?}; could create a "Modification of read-only value" error
    [marto]: Discipulus the issue that should be adressed is that the page needs to be updated to reflect modern perl on Windows
    [Discipulus]: but is really necessary to support these ancient versions? from 5.14 onward is not enough?
    [Discipulus]: yes marto I understood
    [Corion]: Discipulus: I'm slowly migrating my code to require 5.8.x ;) Most of my code works on 5.6, but Filter::signatures requires 5.10 I think
    [Corion]: 5.14 is also a good target, widely available and fairly stable. Also, over five years old, which doesn't push people into a needless upgrade cycle
    [Discipulus]: yes I saw your efforts Corion but the pain is worth?

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (10)
    As of 2018-06-25 08:47 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.