in reply to Re: retrieve data from array empty
in thread retrieve data from array empty

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: retrieve data from array empty
by karlgoethebier (Abbot) on May 24, 2015 at 11:31 UTC
    ...it is working fine.

    Very nice.

    But believe afoken and me, what you posted doesn't compile:

    karls-mac-mini:monks karl$ perl -c pverstraten.pl Missing right curly or square bracket at pverstraten.pl line 28, at en +d of line syntax error at pverstraten.pl line 28, at EOF pverstraten.pl had compilation errors.

    Hence it is not possible to indent it properly using Perltidy:

    karls-mac-mini:monks karl$ cat perltidy.ERR 28: final indentation level: 1 Final nesting depth of '{'s is 1 The most recent un-matched '{' is on line 12 12: { ^ 28: To save a full .LOG file rerun with -g

    I guess: what you posted isn't the code that works fine.

    Regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Re^3: retrieve data from array empty
by afoken (Chancellor) on May 24, 2015 at 13:28 UTC

    Let me explain the "may have $lastmonth set to nonsense values" issue:

    my $lastmonth=$mon-1;

    I assume that $mon represents a month. It must be numeric (unless overloaded). That usually means either 1..12 for January to December (as on any calendar) or 0..11 (as returned by localtime and gmtime). What happens when $mon represents January and you subtract 1? In the first case, you get 0, which is nonsense. In the second case, you get -1, which is exactly the same nonsense.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)