Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^3: Undesirable parent hash keys (concept?)

by CountZero (Bishop)
on Jan 11, 2013 at 10:25 UTC ( #1012855=note: print w/replies, xml ) Need Help??

in reply to Re^2: Undesirable parent hash keys (concept?)
in thread Undesirable parent hash keys

Then the only practical solution is to switch off autovivification. But take care to do it only in a limited scope because many other modules may still need it and could break unexpectedly if it is switched off.;

It is probably more safe to do a no autovivification 'exists'; as this turns off autovivification for dereferencing expressions that are parts of an exists only, such as :

exists $arrayref->[1][2][$idx] exists $hashref->{this}{that}{$key};
and then make sure you change your tests to include the exists function.


A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^4: Undesirable parent hash keys (concept?)
by tobyink (Abbot) on Jan 11, 2013 at 10:34 UTC

    autovivification has lexical scope, so if other modules rely on autovivification, then using no autovivification in your script/module shouldn't harm them. (The only exception I could think of would be modules that play with B::Hooks::Parser, etc, to do weird stuff within your lexical scope.)

    I don't see much value in explicitly specifying the 'exists' option for the autovivification pragma, as the default options are pretty sane: when no autovivification is in effect, autovivification will still be allowed for "store" operations...

    use strict; use warnings; no autovivification; # default options use Data::Dumper; my $ref = undef; $ref->{foo}[0]{bar}[0] = 42; # store print Dumper $ref;
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012855]
[james28909]: and i need to format those special instances into an absolute date instead of "yesterday"
[stevieb]: ask a question on SoPW, and include at least a half-dozen examples of the input, and at least one example of expected output
[davido]: Exactly: SoPW. This isn't going to be solved easily in the CB.
[james28909]: in need "yesterday" and so on, to be absolute like "1" or "31"
[stevieb]: ...and throw some of your existing code into the equation as well, just so readers know you've given a try at it ;)
[james28909]: ok
[stevieb]: davido thanks for the link ;) I was being the typical lazy
[davido]: date parsing is hard. The more examples you can provide of the input (within reason) and expected output, the better.
[stevieb]: agreed. That's why I said at least a half-dozen. If enough of the different formats are present, the date/time folk may not have to request more. If they do, then at least there was a decent base to start with
[stevieb]: I do date and time transformations in both Perl and Python, but not frequently enough to not have to search for the format params etc ;)

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2017-04-29 02:38 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.