Wildly off-topic perl discussion

Rob 'Feztaa' Park feztaa at shaw.ca
Mon May 20 10:55:21 PDT 2002


Alas! Stefan Krah spake thus:
> * Rob 'Feztaa' Park <feztaa at shaw.ca> wrote:
> > I've got a 14-digit number (it's a date, YYYYMMDDHHMMSS), how do you
> > guys figure is the best way to split it up into separate variables? (I
> > want a variable for year, month, day, hour, minute, second).
> 
> I throw in the following:
> 
> man perlfunc -> substr
> 
> A small demonstration:
> 
> perl -e '$DATESTRING = "20020510173501"; $year = substr($DATESTRING, 0, 4);
>  $month = substr($DATESTRING, 4, 2); print $year," ",$month,"\n"'

D'oh! I hate coding when I'm not thinking straight. I *knew* about
substr already! Didn't even cross my mind...

Thanks.

-- 
Rob 'Feztaa' Park
http://members.shaw.ca/feztaa/
--
BOFH excuse #204:
Just pick up the phone and give modem connect sounds. "Well you said we
Should get more lines so we don't have voice lines."
-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-chat' in the subject header of the message



More information about the lfs-chat mailing list