Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

parsing from text - to output doc

by Anonymous Monk
on Jan 15, 2002 at 18:33 UTC ( [id://138899]=perlquestion: print w/replies, xml ) Need Help??

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

i'm using a command wget for getting a testfile from a server. it writes a output: --09:00:49-- http://www......:80/testfile.tst => `testfile.tst' Connecting to www........:80... connected! HTTP request sent, awaiting response... 200 OK Length: 1,123,328 [application/octet-stream] 0K -> .......... .......... .......... .......... .......... [ 4% +] 50K -> .......... .......... .......... .......... .......... [ 9% +] 100K -> .......... .......... .......... .......... .......... [ 13% +] 150K -> .......... .......... .......... .......... .......... [ 18% +] 200K -> .......... .......... .......... .......... .......... [ 22% +] 250K -> .......... .......... .......... .......... .......... [ 27% +] 300K -> .......... .......... .......... .......... .......... [ 31% +] 350K -> .......... .......... .......... .......... .......... [ 36% +] 400K -> .......... .......... .......... .......... .......... [ 41% +] 450K -> .......... .......... .......... .......... .......... [ 45% +] 500K -> .......... .......... .......... .......... .......... [ 50% +] 550K -> .......... .......... .......... .......... .......... [ 54% +] 600K -> .......... .......... .......... .......... .......... [ 59% +] 650K -> .......... .......... .......... .......... .......... [ 63% +] 700K -> .......... .......... .......... .......... .......... [ 68% +] 750K -> .......... .......... .......... .......... .......... [ 72% +] 800K -> .......... .......... .......... .......... .......... [ 77% +] 850K -> .......... .......... .......... .......... .......... [ 82% +] 900K -> .......... .......... .......... .......... .......... [ 86% +] 950K -> .......... .......... .......... .......... .......... [ 91% +] 1000K -> .......... .......... .......... .......... .......... [ 95% +] 1050K -> .......... .......... .......... .......... ....... [100% +] 09:00:57 (182.83 KB/s) - `testfile.tst' saved [1123328/1123328] i want write out to a doc file or txt file todays date , start time (09:00:49) , end time (09:00:57) and avg down +load rate (182.83 KB/s) if i run it it the next time it need to be append to the file thank you for helping or giving examples Jimmy

Replies are listed 'Best First'.
Re: parsing from text - to output doc
by joealba (Hermit) on Jan 15, 2002 at 19:31 UTC
    1. Print the time.
    print scalar localtime(time) , "\n";

    2. Run the program from your Perl script. Get the output of that program into a variable.
    my $output = qx(wget http://URL);

    3. Munge the data to get what you want.
    my ($time, $kb_s) = $output =~ /^(\d+:\d+:\d+)\s+\(([\d.]+)\s+/m; print "TIME: $time\nKB/S: $kb_s\n\n";
    4. Repeat step 1.

    Step 0. RTFM. Thanks for this great link, cacharbe! (I stole it from 138902.)
Re: parsing from text - to output doc
by gav^ (Curate) on Jan 16, 2002 at 10:04 UTC
    You could just do it within perl without using wget:
    use LWP::Simple; if (getstore($url, $dest) == RC_OK) { print "Downloaded file - ", -s $dest, " bytes\n"; } else { print "Error!\n"; }

    gav^

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://138899]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-18 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found