Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^3: Strange problem with Config::General

by Eily (Vicar)
on Nov 18, 2013 at 16:33 UTC ( #1063152=note: print w/replies, xml ) Need Help??

in reply to Re^2: Strange problem with Config::General
in thread Strange problem with Config::General

Try dumping your $conf object just to be sure the problem isn't on that side (I really don't think so). You could also try making list context even more explicit with : my (%config,) = ($conf->getall,); # Now that's overdoing it and see if it changes anything.

If you can't get any further, try to reduce your program as much as possible until you reach the minimum conditions to reproduce the defect. And tell us on which versions of Perl you work in both cases

Replies are listed 'Best First'.
Re^4: Strange problem with Config::General
by OfficeLinebacker (Chaplain) on Nov 18, 2013 at 17:17 UTC
    OK, I dumped the $conf object and found the data in there. So what was the matter?

    Well, at one point, being the guy I am who tries to write robust code, I had added

    my $conf = Config::General->new($cfgfile) || die "New config with $cfg +file failed: $!"; my %config = $conf->getall || die "config->getall with $cfgfile faile +d: $!";
    This somehow changed the context of probably the getall call, because when I changed it to
    my $conf = Config::General->new($cfgfile);# || die "New config with $c +fgfile failed: $!"; my %config = $conf->getall;# || die "config->getall with $cfgfile fai +led: $!";
    , it worked perfectly. Thanks for taking me down a proper debugging path.

      You nearly always want to use the low precedence or instead of || for this kind of statments. In your case, with precedence being what it is, you actually have : %config = ($conf->getall || die "message");. That probably doesn't look like what you meant.

      With or %config = $conf->getall or die; means (%config = $conf->getall) or die; so getall is called in list context.

      That would still mean that you would die on an empty config (%config = ()). And instead of using or you could just add parenthesis when needed, but I find it clearer when the low precedence operator are used for control flow, and high precedence ones are used when the return value is used.

      NB: your problem is, with a few meaningless differences, one of the exemples given in Logical or and Exclusive Or to show the meaning of both operators.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1063152]
[LanX]: qwiud you sthink so?
[LanX]: zxwqbd good idea! :)
LanX embraces his new habit spqopiwjdnq
[ambrus]: qQUkZTmHTuKxStGT- BzTIK9gdudif7TkTLI t3mnF144UaAZjkknXY 8nN-QM19wHBsTrp5vB lEYU_Kksa7X1RIBB4x EWLD5X7SW3jGX5ryfN OMn_yL5FTdQxzjhtyX mKN9sjUCzBNHK5Rrp0 S2WMUvIb1i9aZFgjtq VR0GH1bjPMvm1G16iz hBqc1U6toPd4FbJOFj VsOeT745AN1_pO88rD SRAYKtBZwCZedESZmN mvutrOTHiSNwflB- pRfn_k
[Eily]: so far it seems to work
Your Mother reminds the monks they should be grateful not to share an office, lest they be subjugated to constant inanities like, "Czech please!"
[LanX]: what's strange is that the "Cowboy you said this already" message is missing #dqiwd
[LanX]: YM: BTW learn to mute your humanity
[Your Mother]: Cumin? Now I want tacos...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2017-03-27 16:55 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.