Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re5 (-l): I don't use printf enough

by dragonchild (Archbishop)
on Oct 25, 2003 at 02:42 UTC ( #302019=note: print w/ replies, xml ) Need Help??

in reply to Re: Re: Re2 (-l): I don't use printf enough
in thread I don't use printf enough

Going down that road means that eventually somebody is going to argue that every single subroutine should localize all the global variables because of similar reasons.

Personally, I think there should be a switch, similar to strict, that will do this for you within a scope. Most modules shouldn't be depending on the globals anyway. It just causes craziness. Is there a use localize_globals; or some such? Ideally, one would add a use line at the top of the module and that would be it. Could this work? (Untested)

package Filter::LocalizeGlobals; use Filter::Simple; # Add things to be localized here. my $locals = 'local (' . join ',', qw( $_ $\ $/ ); FILTER_ONLY code => sub { s/(\bsub\b\s*\w+{)/$1 $locals /g; }; 1;

We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Comment on Re5 (-l): I don't use printf enough
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-05-28 04:15 GMT
Find Nodes?
    Voting Booth?