Wildly off-topic perl discussion

James Cozine jmcozine at yahoo.com
Mon May 20 01:52:12 PDT 2002


feztaa at shaw.ca (Rob 'Feztaa' Park) writes:

> 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).
> 
> As it stands now, I'm splitting up the string into an array (each digit
> is an element in the array), and then concatenating each element into
> the appropriate string. It's about 7 lines long, which is really too
> many for something that should be fairly simple.


(ARRG!  I did it again.  I hit R instead of F...  And split was parsing
the wrong variable anyways...  )

  my $longdate = "20020520002904";
  my @shortdate = split /(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)/,$longdate;

For elements of @shortdate > 0

Sorry about mailing instead of posting.  I'll get it right eventually...

-- 
print 'pack("C*",45,106,99),"\n";'
-- 
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