in reply to extract a log file to filter previous dates

The key to your problem is 'interpolation'. The code that the Perl interpreter sees is:

print 2007-08-05;

which is some arithmetic (2007 - 08 - 05) containing two octal constants and a decimal constant. You need to quote the interpolated date so that the interpreter sees a string instead:

@Discon=$telnet->cmd("cat /data/pinpe.csv | nawk '{print \$4}' | perl +-ne 'print if \$_ lt \'$DATE[0]\''");

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: extract a log file to filter previous dates
by pinpe (Novice) on Aug 03, 2007 at 18:12 UTC
    Hi GrandFather,

    Tnx so much indeed for the hand. My script is now working.

    Now my problem is the extarction of the file is taking slow. How can I optimized the extraction of 1.2GB .txt file with 8M rows and 38 columns. Actually I create this script to filter only the informations that I need from this huge data. Any modules that can help to speed up the extraction? Tnx in advance.

    Cheers! :)

    Br, Pete

      You might get better advice if you show us what your data looks like and tell us what you want to extract from it. If you are dealing with a CSV file you may find Text::CSV or DBD::AnyData useful. AnyData will also handle fix width field data and a variety of other common file formats.


      DWIM is Perl's answer to Gödel
Re^2: extract a log file to filter previous dates
by pinpe (Novice) on Aug 03, 2007 at 18:36 UTC
    Hi GrandFather,

    Tnx so much indeed for the hand. My perl script is working now. =)

    But now my problem is the extraction of data is taking too slow. You know my data is 1.2 GB text file with 8M rows and 38 columns. Imagine how huge this data is.

    Is there a way I can optimixed the extraction of the data. That is why I created this script to filter only those informations that I need. Is there any modules available or any way to speed up the process of extraction? Tnx in advance.

    Cheers! :)

    Br, Pete