in reply to parsing a space-separated filename in a line with fields separated by spaces
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"; }
|
|---|