Can someone please tell me what's wrong with this?

my $time = "12/Jan/2008:13:38";
my ($day, $month, $year, $hour, $minute) = $time =~ /(\d+)\/(\w)\/(\d+)\:(\d+)\:(\d+)/;

I've tried a hundred different things including not escaping the colons, putting parenthesis around ($time...[regex]), splitting up the assignments to $day = $1, $month = $2, etc...

Nothing is working...:-(

Figured it out \w matches one "word character" not one "word" -_-

you could consider using

\W+

instead of

\/ and \:

\W+ is any amount of non-alphanumerics. as opposed to \w+ which is any amount of alphanumerics (ie, 'A-Z' plus 'a-z' plus '0-9' plus '_' )

that way you wont be locked into certain exact type and amount of separators between your date and time elements. give you a little more flexibility to handle irregular input (inconsistency between users, and the like)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.