Re: Parsing file names with spaces



On Wed, 30 Jun 2010 23:53:13 GMT, James Egan <jegan473@xxxxxxxxxxx>
wrote:

I want to take these three array elements and extract the file names which
include spaces:

-rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip


This works for me:

#!/usr/bin/perl

open DATA, 'data';
@files = <DATA>;
foreach (@files) {

my $file;
(undef, undef, undef, undef, undef, undef, undef, undef, $file) = split ' ', $_, 9;
$file =~ / / and print "$file";

}


--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php

.



Relevant Pages