Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Re: Easy question i'm sure about formatting

by mvam (Acolyte)
on Apr 06, 2004 at 16:14 UTC ( #342998=note: print w/replies, xml ) Need Help??

in reply to Re: Easy question i'm sure about formatting
in thread Easy question i'm sure about formatting

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.

Replies are listed 'Best First'.
Re: Re: Re: Easy question i'm sure about formatting
by jaco (Pilgrim) on Apr 06, 2004 at 19:32 UTC
    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?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2020-07-08 15:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found