Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^3: How to sovle this, if i use strict i'm getting error.

by jhourcle (Prior)
on Dec 06, 2005 at 09:26 UTC ( #514382=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to sovle this, if i use strict i'm getting error.
in thread How to sovle this, if i use strict i'm getting error.

They think it's a bad idea because 'use strict' complains ... but if you know that what you're trying to do is correct, you can shut off 'use strict' for the specific complaint that it has:

use strict; use warnings; for my $i ( 1 .. 2 ) { $a = 'test'.$i; no strict 'refs'; &$a; } sub test1 { print 'test1'; } sub test2 { print 'test2'; }

So where's the problem with that? None, really. I mean, it doesn't propogate, so you're still protected in the subroutine you're calling:

use strict; use warnings; for my $a qw( test1 test2 ) { no strict 'refs'; &$a; } sub test1 { print 'test1'; } sub test2 { my $x='test3'; &$x }

PS. For the original poster -- it's convention that you don't use $a and $b as variable names, unless you're dealing with sorting.

Replies are listed 'Best First'.
Re^4: How to sovle this, if i use strict i'm getting error.
by BUU (Prior) on Dec 06, 2005 at 09:32 UTC
    You don't actually need to change the current strictures:
    use strict; sub foo { print "Foo"; } sub bar { print "bar"; } main->can("foo")->();

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://514382]
help
Chatterbox?
[prathap keerthipati]: how to update perl in unix
[hippo]: yum update perl
[hippo]: Other package managers are available
LanX wouldn't update system Perl!
[Discipulus]: prathap keerthipati might be it is better to install an alternative Perl instead and do not touch the system one
[LanX]: see perlbrew for alternative Perl installations
[marto]: unless you know exactly what you're doing an often saner option is to simply build another Perl rather than replace the system one

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (16)
As of 2017-03-23 10:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (285 votes). Check out past polls.