Try
my ( $attribs, $size, $day, $mon, $date, $time, $year, $file ) =
split(/\s+/,
$line,8);
Ed Ewen
(404) 575-3531
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
-----Original Message-----
From: [EMAIL PROTECTED]
[SMTP:[EMAIL PROTECTED]]
Sent: Monday, May 01, 2000 3:31 PM
To: Perl-Win32-Users Mailing List
Subject: Splitting out a filename
ok, let's say you have a file where each line looks like this:
--a-- 430 Fri Mar 19 18:32:47 1999 D:\Program Files\Common
Files\Adobe\Web\AwePrefs.txt
and you want to get the filename (and every other field) out of it,
the obvious
thing to split on is whitespace (\s+) which give something like the
following:
my ( $attribs, $size, $day, $mon, $date, $time, $year, $file ) =
split(/\s+/,
$line);
but of course that fails when files contain spaces, as in the above
line.
Later on I'm trying to get JUST the filename out of the line and
using:
($file = (split( /\s+/, $line ))[7]) =~ s/\*//g;
that little sub at the end strips '*' off the ends of filenames,
again this
works great as long as there are no spaces in the filename/folders
Can anyone think up a slick way to extract the full filename from
the above
line, in all cases? the file cannot be reformatted (ie. I cannot
change the
'bad' spaces into '|' or something else) My first thought was to
split to an
array, shift out the first 7 values, then shift the rest into the
file variable
concatenating tham as I went, but that seems un-perlish to me,
anyone have a
better way?
Chuck
---
You are currently subscribed to perl-win32-users as:
[EMAIL PROTECTED]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]
---
You are currently subscribed to perl-win32-users as: [[email protected]]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]