Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Hacking perl

by robin (Chaplain)
on Oct 20, 2005 at 23:29 UTC ( #501844=perlmeditation: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    cd build
    mkdir perl-current
    cd perl-current
    rsync -avz rsync://ftp.linux.activestate.com/perl-current/ .
    
  2. or download this
    sh Configure -Doptimize='-g' -Dusethreads -Dusedevel -Dprefix=/local/p
    +erl
    -ders && make
    
  3. or download this
    perl -e 'my *x'
    
  4. or download this
    syntax error at -e line 1, near "my *x"
    
  5. or download this
    /* "my" declarations, with optional attributes */
    myattrterm:     MY myterm myattrlist
    ...
           |       ary     %prec '('
                           { $$ = $1; }
           ;
    
  6. or download this
    scalar  :       '$' indirob
                            { $$ = newSVREF($2); }
    ...
    hsh     :       '%' indirob
                            { $$ = newHVREF($2); }
            ;
    
  7. or download this
    star    :       '*' indirob
                            { $$ = newGVREF(0,$2); }
            ;
    
  8. or download this
           |       star    %prec '('
                           { $$ = $1; }
    
  9. or download this
      perl regen_perly.pl
      make perl
    
  10. or download this
      $ ./perl -e 'my *x'
      Can't declare ref-to-glob cast in "my" at -e line 1, at EOF
    
  11. or download this
    $ ./perl -MO=Concise -e 'my $x; my @y; my %z' 
    8  <@> leave[1 ref] vKP/REFC ->(end)
    ...
    6     <;> nextstate(main 3 -e:1) v ->7
    7     <0> padhv[%z:3,4] vM/LVINTRO ->8
    -e syntax OK
    
  12. or download this
    $ diff -u opcode.pl{.orig,}
    --- opcode.pl.orig      2005-10-18 19:07:24.000000000 +0100
    ...
     padany         private value           ck_null         d0
     
     pushre         push regexp             ck_null         d/
    
  13. or download this
    --- op.c.before 2005-10-18 19:13:33.000000000 +0100
    +++ op.c        2005-10-18 19:33:09.000000000 +0100
    ...
            return newUNOP(OP_NULL, 0, o);
         return ref(newUNOP(OP_RV2GV, OPf_REF, o), type);
     }
    
  14. or download this
    --- pp.c.orig   2005-10-18 19:16:07.000000000 +0100
    +++ pp.c        2005-10-18 19:17:51.000000000 +0100
    ...
     PP(pp_padany)
     {
         DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
    
  15. or download this
    $ ./perl -MO=Concise -e 'my *x'
    Can't declare ref-to-glob cast in "my" at -e line 1, at EOF
    ...
    2     <;> nextstate(main 1 -e:1) ->3
    4     <1> rv2gv sKR/1 ->5
    3        <#> gv[*x] s ->4
    
  16. or download this
    $ gdb --args ./perl -e 'my *x'
    ...
    ...
    $1 = {op_next = 0x81ccc50, op_sibling = 0x0, 
      op_ppaddr = 0x80e2c0c <Perl_pp_const>, op_targ = 0, op_type = 5, op_
    +opt = 0, 
      op_static = 0, op_spare = 0, op_flags = 2 '\002', op_private = 16 '\
    +020'}
    
  17. or download this
    $ grep OP_PADANY *.c
    ...
    toke.c:            yylval.opval = newOP(OP_PADANY, 0);
    toke.c:            yylval.opval = newOP(OP_PADANY, 0);
    
  18. or download this
    ...
    if (PL_pending_ident)
      return REPORT(S_pending_ident(aTHX));
    ...
    
  19. or download this
    --- toke.c.orig 2005-10-18 19:47:57.000000000 +0100
    +++ toke.c      2005-10-18 19:48:43.000000000 +0100
    ...
                if (!*PL_tokenbuf)
                    PREREF('*');
                TERM('*');
    
  20. or download this
    syntax error at ../lib/vars.pm line 29, near "*$sym "
    
  21. or download this
    $ ./miniperl -DT -ce '*$x'
    ### 0:LEX_NORMAL/XSTATE "\n;"
    ...
    
    syntax error at -e line 1, next char $
    -e had compilation errors.
    
  22. or download this
    $ ./miniperl -DT -ce '%$x'
    ### 0:LEX_NORMAL/XSTATE "\n;"
    ...
    EXECUTING...
    
    -e syntax OK
    
  23. or download this
    --- toke.c.orig 2005-10-18 19:47:57.000000000 +0100
    +++ toke.c      2005-10-18 20:16:52.000000000 +0100
    ...
                TERM('*');
            }
            s++;
    
  24. or download this
    Global symbol "%DELETE" requires explicit package name at lib/Config_h
    +eavy.pl line 1158
    
  25. or download this
    *DELETE = \&STORE;
    
  26. or download this
    $ ./miniperl -ce '*foo'
    -e syntax OK
    $ ./miniperl -ce 'use strict; *foo'
    Global symbol "%foo" requires explicit package name at -e line 1.
    -e had compilation errors.
    
  27. or download this
    $ fgrep 'explicit package name' *.c
    gv.c:            "Global symbol \"%s%s\" requires explicit package nam
    +e",
    
  28. or download this
    $ gdb --args ./miniperl -e '*foo'
    (gdb) br Perl_gv_fetchpvn_flags
    ...
    #7  0x0804baeb in main (argc=3, argv=0xbffff3f4, env=0xbffff404)
        at miniperlmain.c:101
    #8  0x42015704 in __libc_start_main () from /lib/tls/libc.so.6
    
  29. or download this
        gv_fetchpv(PL_tokenbuf+1, PL_in_eval ? (GV_ADDMULTI | GV_ADDINEVAL
    +) : TRUE,
                   ((PL_tokenbuf[0] == '$') ? SVt_PV
                    : (PL_tokenbuf[0] == '@') ? SVt_PVAV
                    : SVt_PVHV));
    
  30. or download this
    --- toke.c.1    2005-10-18 20:53:32.000000000 +0100
    +++ toke.c      2005-10-18 20:54:34.000000000 +0100
    ...
                     : SVt_PVHV));
         return WORD;
     }
    
  31. or download this
    $ ./perl -MO=Concise -e 'my *foo'
    Can't declare private glob in "my" at -e line 1, at EOF
    ...
    1     <0> enter ->2
    2     <;> nextstate(main 1 -e:1) ->3
    3     <0> padgv[*foo:1,2] ->4
    
  32. or download this
    $ fgrep "Can't declare" *.c
    op.c:               "Can't declare class for non-scalar %s in \"%s\"",
    ...
    opmini.c:                   "Can't declare class for non-scalar %s in 
    +\"%s\"",
    opmini.c:           yyerror(Perl_form(aTHX_ "Can't declare %s in %s",
    opmini.c:       yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"",
    
  33. or download this
        else if (type != OP_PADSV &&
                 type != OP_PADAV &&
    ...
                              PL_in_my == KEY_our ? "our" : "my"));
            return o;
        }
    
  34. or download this
    --- op.c.1      2005-10-18 21:03:51.000000000 +0100
    +++ op.c        2005-10-18 21:04:11.000000000 +0100
    ...
                 type != OP_PUSHMARK)
         {
            yyerror(Perl_form(aTHX_ "Can't declare %s in \"%s\"",
    
  35. or download this
    $ ./perl -e 'my *foo'
    OP_PADGV NOT YET IMPLEMENTED at -e line 1.
    
  36. or download this
    --- pp.c.orig   2005-10-18 19:16:07.000000000 +0100
    +++ pp.c        2005-10-18 22:23:28.000000000 +0100
    ...
     PP(pp_padany)
     {
         DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
    
  37. or download this
    $ ./perl -e 'my *foo = *bar'
    Can't modify private glob in scalar assignment at -e line 1, at EOF
    
  38. or download this
    $ fgrep "Can't modify" *.c
    op.c:   yyerror(Perl_form(aTHX_ "Can't modify %s in %s",
    
  39. or download this
    --- op.c.2      2005-10-18 21:43:38.000000000 +0100
    +++ op.c        2005-10-18 21:44:12.000000000 +0100
    ...
            PL_modcount++;
            if (!type) /* local() */
                Perl_croak(aTHX_ "Can't localize lexical variable %s",
    
  40. or download this
    $ ./perl -we 'my *foo = *bar; print *foo, "\n"'
    Name "main::bar" used only once: possible typo at -e line 1.
    *main::bar
    
  41. or download this
    $ ./perl -we 'my *foo = *bar; $bar = "Hello, world!\n"; print ${*foo}'
    Hello, world!
    
  42. or download this
    $ ./perl -we 'my *foo; print *foo{NAME}'
    Segmentation fault
    
  43. or download this
    --- pp.c.1      2005-10-18 22:30:22.000000000 +0100
    +++ pp.c        2005-10-19 00:47:33.000000000 +0100
    ...
    +    XPUSHs(SvRV(TARG));
         RETURN;
     }
    
  44. or download this
    $ ./perl -wle 'print my *x'
    *lexical::_GEN_0
    ...
    $ ./perl -wle 'my *x = \23; *foo = *x; print $foo; $foo = 24'
    23
    Modification of a read-only value attempted at -e line 1.
    
  45. or download this
    sub foo {
      my *foo = shift;
    ...
    
    my $y = foo(\23);
    print $y->();
    
  46. or download this
    $ ./perl -wle 'for(1..10) {my *x} print sort keys %lexical::'
    _GEN_0_GEN_1_GEN_2_GEN_3_GEN_4_GEN_5_GEN_6_GEN_7_GEN_8_GEN_9
    
  47. or download this
    $ ./perl -e 'while (1) {my *foo}'
    
  48. or download this
    --- pp.c.3      2005-10-19 01:26:19.000000000 +0100
    +++ pp.c        2005-10-19 01:34:42.000000000 +0100
    ...
            SAVECLEARSV(PAD_SVl(PL_op->op_targ));
         }
         XPUSHs(SvRV(TARG));
    
  49. or download this
    $ ./perl -wle 'for (1..10) {print \my *foo}'
    GLOB(0x81b22d8)
    ...
    GLOB(0x81b22f8)
    GLOB(0x81b22b8)
    GLOB(0x81b22d8)
    
  50. or download this
    #!./perl
    
    ...
    my @foo = map foo($_), \(17, 23);
    is($foo[0]->(), 17, 'Closure test ($foo[0] == 17)');
    is($foo[1]->(), 23, 'Closure test ($foo[1] == 23)');
    
  51. or download this
      
    --- ext/Opcode/Opcode.pm.orig   2005-10-19 01:08:11.000000000 +0100
    +++ ext/Opcode/Opcode.pm        2005-10-19 01:08:28.000000000 +0100
    ...
    +    padsv padav padhv padgv padany
     
         rv2gv refgen srefgen ref
    
  52. or download this
    --- ext/Safe/t/safeops.t.orig   2005-10-19 02:13:20.000000000 +0100
    +++ ext/Safe/t/safeops.t        2005-10-19 02:13:52.000000000 +0100
    ...
     SKIP (not implemented) # padany
     SKIP split /foo/ # pushre
     *x # rv2gv
    
  53. or download this
    --- ext/B/t/optree_concise.t.orig       2005-10-19 02:16:20.000000000 
    ++0100
    +++ ext/B/t/optree_concise.t    2005-10-19 02:16:37.000000000 +0100
    ...
    +#         UNOP (0x812fc20) null [16] 
     #             SVOP (0x812fc00) gvsv  GV (0x814692c) *a 
     EONT_EONT
    
  54. or download this
    --- patchlevel.h.orig   2005-10-19 03:31:04.000000000 +0100
    +++ patchlevel.h        2005-10-19 03:32:24.000000000 +0100
    ...
            ,NULL
     };
     
    
  55. or download this
      ...
      Locally applied patches:
            DEVEL25746
            LEXGLOB001 - lexically scoped globs!
      ...
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://501844]
Approved by GrandFather
Front-paged by itub
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-07-12 19:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (241 votes), past polls