in reply to changing date format in and out

If you have thousands of Unix epoch times (which is what you sure appear to have -- the number of seconds since midnight January 1st 1970 UTC) then why do you think you can process them all without... well, processing them all? The loop over thousands will be simpler and take less time that you think.

while ( <> ) { chomp; print (gmtime $_); }

See localtime and gmtime, although there's nothing wrong with ctime().

Replies are listed 'Best First'.
Re^2: changing date format in and out
by gio001 (Acolyte) on Feb 14, 2009 at 00:23 UTC
    Thanks,
    well I understand and I agree that I will have to execute in a loop, what I am trying to learn is a way to create the while loop inside the perl world and not issue thousands of invocations to perl from a straight unix ksh loop, if you understand what I mean.
    So can you please illustrate for me how can I structure an invocation statement(s) to perl with an incoming file name, an output file name and the real while loop as the core of what I will ask perl to execute for me?
    Thanks !
      The example that was given to you is the guts of what you are asking for.

      Take the code that was given to you by mr_mischief, and save it in a file (lets call it foo.pl). Then just pass your input file through that, ie:

      perl foo.pl < infile > outfile
      Although, you will probably want to change the line:
      print (gmtime $_);
      to read:
      print scalar gmtime($_);
      Or alternatively, if you want your output in local time, then:
      print scalar localtime($_);
      Hope this helps,
      Darren
        Great, thanks a lot!
        I hope not to impose on you for a very last favor, how would it be possible to consolidate this logic into a single perl line command (a one liner)?
        I hope you can show me, thanks again!
      Abandon KSH