> Hi > > I have the following script that sucks in a file and converts > unix timestamp to human readable.. > > The Goal is to do a search and replace of unix time to the > format i need. But I'm just trying to get it to print in the > format i need first... > > I cant get localtime to print in "mm-dd-yyyy hh:mm:ss" , I > keep getting it like so "Sun Dec 28 03:35:19 2003"
That's what it returns in scalra context. You can call it in array context and get the specifc values you want. You may have to modify them a bit ( add 1900 to the year for instance) Take a look at perldoc -f localtime to seee which parts of the array are which values you want in which format. HTH Dmuey > > > #!/usr/bin/perl > use strict; > # > #my $timestring = localtime(); > > open (FILE, "ip.txt") || die ("Open Failed: $!\n"); > > my @lines = <FILE>; # file into array > > foreach (@lines) { > next if /^S/; > next if /^-/; > > my @line = split(/\t/, $_); > > my @time = split(/\n/, $line[0]); > > foreach (@time) { > > my ($sec,$min,$hour,$mday,$mon,$year) = localtime($_); > > # need to print like mm-dd-yyyy hh:mm:ss > my $timestring = localtime($_); > > # but prints like "Sun Dec 28 03:35:19 2003" > print "$timestring\n"; > } > > } > > close FILE; > # > > more ip.txt: > > Start header header > ----- ----- ----- > 1072611319 rrr rrrr rrrr > 1072611319 rrr rrrr rrrr > 1072611319 rrr rrrr rrrr > 1072611319 rrr rrrr rrrr > > > Thanks > Rob > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>