timvzid1 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.
  • Comment on Hi Perlmonks, I have need to write a script to do the following

Replies are listed 'Best First'.
Re: Hi Perlmonks, I have need to write a script to do the following
by moritz (Cardinal) on Jun 05, 2008 at 06:23 UTC
    Well, do it then. If you have problems with a particular step, you can ask us. But perlmonks is no "we write the code for you" service.
Re: Hi Perlmonks, I have need to write a script to do the following
by grinder (Bishop) on Jun 05, 2008 at 07:39 UTC

    Thanks to the power of CPAN, this is an easy problem to solve.

    #! /usr/local/bin/perl -w use Acme::DonMartin; sittzle klikrunk snork blooma shlikle crugazunch stroinggoink kik praw +k shik fip skroinch glika skribble gloydoip aaak sklerch tear gloot sput +z pat shlikle whomp krakkle spmam fush pwadak shpork bluka flork skwako oof shploip paf kridit zizzak fliff bahoo tip bap gashplutzga snikker aaak blut pluf rrrrrr glont snat shklink fwaddapp tippity sklukle schlip shpishle klang tear plapf pluf sklortch flut kaboomm gloochle pflap blapple sazzikk phoon dakkadak spamamp glomp thloop skrak aaak kik pittooie shnip tood skreee shklizzortch glomp skluk swizap vroon swizap fween skapasch pam spopple stroinggoink slurp zazik deebe koong fashklork zazik sworf fwap kik gloydoip dubba shpishle shpliple teeoo phwam glink glink pwadak floba wink kaheeee dugga twong zlitz fidip zlitz foomp mabbit tok skroik sput

    Explaining the algorithm is left as an exercise to the student. Or teacher.

    • another intruder with the mooring in the heart of the Perl

Re: Hi Perlmonks, I have need to write a script to do the following
by andreas1234567 (Vicar) on Jun 05, 2008 at 07:50 UTC
Re: Hi Perlmonks, I have need to write a script to do the following
by Anonymous Monk on Jun 05, 2008 at 06:27 UTC
Re: Hi Perlmonks, I have need to write a script to do the following
by Gangabass (Vicar) on Jun 05, 2008 at 06:18 UTC

    Homework?

Re: Hi Perlmonks, I have need to write a script to do the following
by rovf (Priest) on Jun 05, 2008 at 08:45 UTC
    Have a look at the perlop man page, in particular to the usage of the operators .. and ... in scalar context. They have examples which apply neatly to your problem.
    -- 
    Ronald Fischer <ynnor@mm.st>

      sry guys and thnx for reponding ....I am very new to perl scripting and Here is my code

      I can get $day, $time1,$time2,$time3,$time4 from command line arguements

      $log="output.txt"

      open(FILE,$log);

      open(DATA,">>capdata.txt");

      while(<FILE>)

      {

      if ($_ ge "$day $time1:time2" && "$day $time3:$time4")

      {

      print DATA;

      }

      }

      I worte the script..but this is working for these kind of logs(log starting with timestamp

      2006-04-06 09:22:00|Mike|USA

      2006-04-06 09:23:99|Steve|Canada

      2006-04-06 09:22:44|Bond|japan

        Sorry, my previous remark on .. and ... was silly. These operators won't help you here, since you don't know whether there actually is an entry in the log file with the very starting/ending times of the interval you are checking for.

        In this case, I would proceed as follows:

        Convert your string timestamp (2006-04-06 09:22:44) into a numeric value. You can do this forexample by extracting the respective fields by a regexp, and then use the functions in Time::Local to convert them into a time value. If you do the same with the starting/ending time, you can use numeric comparision to see whether the record falls within the range.

        If you don't want to fiddle around with regular expressions (though in your case, they will be simple, because the timestamp always looks alike, doesn't it?), you could maybe use Date::Parse from CPAN. I have never worked with Date::Parse though, so I can't really say how useful it is for your application.

        -- 
        Ronald Fischer <ynnor@mm.st>

        small correction in if condition

        if ($_ ge "$day $time1:time2" && $_ le "$day $time3:$time4")
Re: Hi Perlmonks, I have need to write a script to do the following
by timvzid1 (Initiate) on Jun 05, 2008 at 18:18 UTC

    Guys someone please help me...never heard about CPAN and all..if possible can anyone thorw some more light
      CPAN stands for Comprehensive Perl Archive Network
      Give CPAN a closer look for more info.
      Also check out some documentation HERE.


      Es gibt mehr im Leben als Bücher, weißt du. Aber nicht viel mehr. - (Die Smiths)"