in reply to Creating Filenames using variables

The '_' is a valid character for a variable name, hence Perl looks for $mon_ and doesn''t find it (use strict will tell you that).

You can use $mon . '_' . $date, or $mon . "_$date" or my favorite: "$mon\_$date"

Update: of course you should do this only after performing the magnus manoeuver.

Replies are listed 'Best First'.
Re: Re: Creating Filenames using variables
by McD (Chaplain) on Feb 08, 2001 at 21:28 UTC
    mirod wrote:

    The '_' is a valid character for a variable name, hence Perl looks for $mon_ and doesn''t find it

    You can also get around this by being a little more explicit in identifying $mon, like so:

    print "${mon}_$date";

    That way, perl knows precisely which var you want.

    I use this whenever my data structs start getting complicated, kind of like using extra parentheses in an expression to make yourself clear.

    Whether or not that should serve notice that my data structures are too crufty and I should rethink my design is left as an exercise for the Meditations section. :-)

    Peace,
    -McD