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

Re: Pragma inside grep block

by RMGir (Prior)
on Jul 08, 2009 at 12:08 UTC ( #778216=note: print w/ replies, xml ) Need Help??


in reply to Pragma inside grep block

Good question.

5.10.0 has the same problem:

$ perl -e'use strict; use warnings; grep { no strict "refs"; }qw(x); ' "no" not allowed in expression at -e line 2, at end of line BEGIN not safe after errors--compilation aborted at -e line 2. $ perl -e'use strict; use warnings; grep { 0; no strict "refs"; }qw(x); ' $
Of course,
{ no strict "refs"; grep {0;} qw(x); }
would work fine, so at least there's a workaround...

Mike


Comment on Re: Pragma inside grep block
Select or Download Code
Re^2: Pragma inside grep block
by Anonymous Monk on Jul 08, 2009 at 12:16 UTC
    Workaround is to add ;
    grep { ;no strict 'refs'; } qw(x);
    but that confuse Deparse :D
    perl -MO=Deparse use strict; use warnings; grep { ;no strict 'refs'; } qw(x); ^D use warnings; use strict 'refs'; grep {();} 'x'; - syntax OK
    Also works
    grep { do{ no strict 'refs'; } } qw(x)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2014-09-22 21:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (205 votes), past polls