Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: parsing a space-separated filename in a line with fields separated by spaces

by jwkrahn (Abbot)
on Aug 15, 2007 at 22:30 UTC ( [id://632872]=note: print w/replies, xml ) Need Help??


in reply to parsing a space-separated filename in a line with fields separated by spaces

Assuming that file names can also have leading and/or trailing spaces in them, for example ' file name ' then you may want something like this:
while ( <$in> ) { chomp; my %field; # remove and capture leading fields s/^ *(\S+) (\S+) +(\d+) ([\d:]+) (\d+) (\d+) ([\d.]+) (\d+) // and @field{ qw/ day_name month day current_time year transfer_time + remote_host file_size / } = ( $1, $2, $3, $4, $5, $6, $7, $8 ); # remove and capture trailing fields s/ (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+)$// and @field{ qw/ transfer_type special_action_flag direction access +_mode username service_name authentication_method authenticated_user_ +id completion_status / } = ( $1, $2, $3, $4, $5, $6, $7, $8, $9 ); # only thing left is file name $field{ filename } = $_; print "$_ = '$field{$_}'\n" for keys %field; print "\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (2)
As of 2024-04-20 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found