I have no idea what a $yday is!
If you just need some tokens from this line like day and year:
#!/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
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.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.