in reply to Re: changing date format in and out
in thread changing date format in and out

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 !

Replies are listed 'Best First'.
Re^3: changing date format in and out
by McDarren (Abbot) on Feb 14, 2009 at 02:12 UTC
    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 Then just pass your input file through that, ie:

    perl < 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,
      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!
        perl -ne 'print scalar localtime' < infile > outfile
        - the "-n" switch, causes perl to assume a "while <>" loop (see perldoc perlrun)
        - the $_ can be dropped, because it is implicit
        - there is no need to chomp, as you probably want the newline anyway

        Darren :)

Re^3: changing date format in and out
by Anonymous Monk on Feb 14, 2009 at 01:08 UTC
    Abandon KSH