in reply to Substring Syntax Check

Here's a date I'm having the user enter in to get the month and the year, so I can create a folder with the month name and year.

Is it the current month and year?

my ($y,$m) = (localtime)[5,4]; $m+=1; $y+=1900;

I tried using split, but it didn't like the / as a delimitter.

split first argument is a regular expression. / has a special meaning in regular expressions, so you need to escape it.
split /\//

Update: Said | where I meant /. Fixed.

Replies are listed 'Best First'.
Re^2: Substring Syntax Check
by jwkrahn (Abbot) on Sep 27, 2008 at 02:19 UTC
    / has a special meaning in regular expressions

    No, it doesn't.

    $ perl -le' $_ = "one/two/three/four"; print m,/, ? "true" : "false"; $re = "/"; print $_ =~ $re ? "true" : "false"; ' true true

    Only ?, *, +, [, {, (, ), | and . have special meaning in a regular expression.

      ack, the post originally said | was special, cause I thought the OP said |. I fixed the post rather blindly. True, / is only special if / is the delimiter.
        That hood sometimes gets in the way :)
Re^2: Substring Syntax Check
by drodinthe559 (Monk) on Sep 26, 2008 at 22:38 UTC
    Unfortunely, it isn't the the current month. I always have to take the last month to create the directory. For example, if I had to run it today, it would make a folder in the users directory labeled Aug08. However, I could take the current month and subtract one from it, but I'm thinking the results may potentially be incaccurate when I have to run this in January. It seems like your helping me again. I appreciate your help. I'll give the split a shot. Dave
      the results may potentially be incaccurate when I have to run this in January
      I agree. So, your choice is to add code to handle the corner case for January, or to use one of the CPAN modules that can probably do this cleanly for you. It looks like you can subtract a month using the Add_Delta_YM function from Date::Calc.