Update: I'll add a bit more for you...split() is a function that parses a scalar value (here its just one line) and creates a list. In this case we "split" on any sequence of one (or more) comma's or space characters (\n\t\r\s\f). These go into the @tokens list. Perl has a very cool syntax called a "list slice", here I say give the first and fourth things which are the day and the year. "my @tokens =" is an intermediate variable that doesn't need to exist, I put it there so you could see the effect of the split.#!/usr/bin/perl -w use strict; my $string= "Wednesday, May 20, 2009 2:09 PM"; my ($day, $year) = (my @tokens = split(/[,\s]+/,$string))[0,3]; print "@tokens \n"; print "day =$day year =$year\n"; __END__ PRINTS: Wednesday May 20 2009 2:09 PM day =Wednesday year =2009
Give some examples of what need...short thing with couple of input lines and couple of output lines.
In reply to Re: Date String Conversion
by Marshall
in thread Date String Conversion
by Lunitech
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |