Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Barstool Trivia

by extremely (Priest)
on Dec 25, 2000 at 05:27 UTC ( #48217=note: print w/ replies, xml ) Need Help??


in reply to Barstool Trivia

OK, i'm going nuts, what is the final list here? This one just dropped off radar but it is bugging me still!

--
$you = new YOU;
honk() if $you->love(perl)


Comment on Re: Barstool Trivia
(Answers) Re: Barstool Trivia
by dchetlin (Friar) on Dec 25, 2000 at 06:05 UTC
    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.

    -dlc

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://48217]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2014-10-01 01:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (386 votes), past polls