develooper Front page | perl.perl5.porters | Postings from May 2004

Re: Minor copy-paste bug in File::Spec::Win32->splitpath()

Thread Previous
From:
Ken Williams
Date:
May 30, 2004 14:54
Subject:
Re: Minor copy-paste bug in File::Spec::Win32->splitpath()
Message ID:
00BADE0B-B24B-11D8-87F5-000A95BD9874@mathforum.org

On May 28, 2004, at 10:27 AM, <Alexander.Farber@nokia.com> wrote:

> Hi Ken and others,
>
> shouldn't the backslash in the last character class:
>
> 	$path =~
>             m{^ ( (?: [a-zA-Z]: |
>                       (?:\\\\|//)[^\\/]+[\\/][^\\/]+
>                   )?
>                 )
>                 ( (?:.*[\\\\/](?:\.\.?\Z(?!\n))?)? )
>                 (.*)
>              }xs;
>
> be better listed just once?
>
> 	$path =~
>             m{^ ( (?: [a-zA-Z]: |
>                       (?:\\\\|//)[^\\/]+[\\/][^\\/]+
>                   )?
>                 )
>                 ( (?:.*[\\/](?:\.\.?\Z(?!\n))?)? )
>                 (.*)
>              }xs;

Sure, looks good.


>
> Also, may I ask you a File::Spec related real-life question?
>
> In the attached script I'm trying to convert a list
> of Windows paths to a list of Unix paths (I'm trying to
> convert some weird build system to plain Unix Makefiles).
> Please just run it and you'll see how it works.
>
> Unfortunately this input line is wrongly parsed:
>
> 	..\inc\cmmphonebookstoremesshandler.h	\tcf
>
> The destination path \tcf is being parsed by
> splitpath() as a dir ("\") and a file ("tcf").


In this case, you might be happier using Path::Class than File::Spec.  
It has a class for files and a class for directories, so you can 
unambiguously specify at creation time what it is.

  -Ken


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About