Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Easy question i'm sure about formatting

by DamnDirtyApe (Curate)
on Apr 06, 2004 at 00:44 UTC ( #342800=note: print w/replies, xml ) Need Help??


in reply to Easy question i'm sure about formatting

mvram, please post your code thus far. What your attempting should be a trivial task, so showing us exactly what you've got so far will make it easy for us to help.


_______________
DamnDirtyApe
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
            --Friedrich Nietzsche
  • Comment on Re: Easy question i'm sure about formatting

Replies are listed 'Best First'.
Re: Re: Easy question i'm sure about formatting
by mvam (Acolyte) on Apr 06, 2004 at 16:14 UTC
    here is my form:
    format STDOUT = URI Date Seconds Fil +e Size ----------------- --------------------- ------- --- +------ @<<<<<<<<<<<<<<<<< @|||||||||||||||||||||||||||| @|||||| @|| +|||||| $URL, $Date, $Time, $Si +ze, . write STDOUT;
    as for the question of being easy or not, i've yet to find much documentation about this with the exception of Perl 6.
      Now, I'm just going to generate some bunk data to give you the idea. But I think this is what you want.
      I've never figured out a good way to make this type of code indent well for readability, so you'll have to deal with that yourself.
      my @URI = ("/profileQuery1","/profileQuery2","/profileQuery3"); my @DATE = ("05/Apr/2004:16:33:02", "05/Apr/2004:16:36:31", "05/Apr/20 +04:16:37:48"); my @FILESIZE = ("889","224", "345"); my $i = 0; while($i <= $#URI){ format top = URI DATE Seconds Filesize -------------- -------------------------- ------- ------- . format STDOUT = @<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<< @<<<<<<< $URI[$i],$DATE[$i],"1", $FILESIZE[$i] . write; $i++; }

      This code outputs

      URI                 DATE                   Seconds  Filesize
      -------------- --------------------------  -------  --------
      /profileQuery1   05/Apr/2004:16:33:02        1        889
      /profileQuery2   05/Apr/2004:16:36:31        1        224
      /profileQuery3   05/Apr/2004:16:37:48        1        345
      


      And I'm fairly sure that's what you wanted.
        actually, Jaco.. you gave me a good idea. i decided to split my form out into a top and STDOUT and it did what i wanted it to do. the only bug i have is that if i do a new URI search w/o exiting the script first, it wont reprint the top of the form again.
        thats the output format i'm looking for, just that the data is coming from a logfile. the script takes a URI from STDIN and parses the file based upon the fields of each line. so if i typed in: /profileQuery i get these results:
        URI Date Seconds Fil +e Size ----------------- --------------------- ------- --- +------ /profileQuery [06/Apr/2004:13:40:36 0 +893 URI Date Seconds Fil +e Size ----------------- --------------------- ------- --- +------ /profileQuery [06/Apr/2004:13:41:12 0 +867 URI Date Seconds Fil +e Size ----------------- --------------------- ------- --- +------ /profileQuery [06/Apr/2004:13:41:23 0 +883
        while that is ok if there are just a few entries for that URI in the log, not so much if there are several hundred. i found some documentation for the field specifiers.. but those were for Perl 6 and didnt work. here is a snip of the code that looks at the log fields
        while(<DB>) { $Recs = $_; chomp($Recs); ($IP, $Host, $Dash, $Date, $TZ, $Method, $URL, $Pro, $Status, $Tim +e, $Size) = split(' ', $Recs); if($URL eq $SearchFor) { $SuccessCount = $SuccessCount + 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://342800]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2020-06-03 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (22 votes). Check out past polls.

    Notices?