Hey,
    Why don't you rely more on the operating system.  That is
nothing more than a response from a dir call.  So it looks like
your doing:

    @lines = qx(dir *.*);

    When you should really be doing:

    @lines = qx(dir /b *.*);

    Or for full directory tree;

    @lines = qx(dir /b /s *.*);

    - Justin Rogers, CEO DigiTec Web Consultants
    [COOP]DigiTec - Half-Life, Q3A, Unreal Tournament
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Perl-Win32-Users Mailing List" <[EMAIL PROTECTED]>
Sent: Monday, May 01, 2000 12:30 PM
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: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to