Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Puzzled about strict

by converter (Priest)
on Oct 30, 2002 at 05:13 UTC ( #208977=note: print w/ replies, xml ) Need Help??


in reply to Puzzled about strict

Check the eval block in your FETCH method. You're doing:

next if ($@);

The code you're evaluating is violating one of the restrictions imposed by strict.pm and is causing a fatal exception, meaning that the code isn't doing what you expect it to.

update
There is only one eval expression, changed "eval blocks" to "eval block"

Replies are listed 'Best First'.
Re: Re: Puzzled about strict
by djantzen (Priest) on Oct 30, 2002 at 05:23 UTC

    Specifically, the error is:

    "Can't use string ("a") as a subroutine ref while "strict refs" in use + at line [eval { $result .= &{$_}(@time); };]"

    If you must, you can turn off strict ("no strict 'refs'") immediately before that eval and turn it back on immediately after.

    Update: Just another thought, why not store your subroutines in a hash where the format strings are the keys? Something like:

    my %method_map = (a => sub { ... }, A => sub { ... } ); my $token = 'a'; # or 'A', 'D', etc. my $result .= $method_map{$token}->(@args);

    This is strict compatible and IMO is more maintainable code.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2016-06-26 00:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (327 votes). Check out past polls.