Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Favourite modules April 2003

by barbie (Deacon)
on Jun 03, 2003 at 12:30 UTC ( #262634=note: print w/ replies, xml ) Need Help??


in reply to Re: Favourite modules April 2003
in thread Favourite modules April 2003

File::Spec -- portability, damn I like it

Except when it makes your life hell due to incompatability with other modules, as you have to regex everything into Unix style to get modules like File::Basename to work with it. Or try using with a file upload from an OS that isn't the same as the server. As a consequence I now avoid it like the plague.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Barbie
Birmingham Perl Mongers
Web Site: http://birmingham.pm.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Comment on Re: Re: Favourite modules April 2003
Re: Re: Re: Favourite modules April 2003
by zby (Vicar) on Jun 03, 2003 at 12:45 UTC
    Could you add some more information about the incompatabillity prolem? I thought File::Spec was the way to go and I use it in one of my projects.
Re^3: Favourite modules April 2003
by PodMaster (Abbot) on Aug 18, 2004 at 09:52 UTC
    The trouble you seem to be having is because you haven't read the fileparse_set_fstype portion of the File::Basename docs. Anyway, I know its been a year since you wrote this, but I finally wrote fileparse (just for completeness) and thought I'd share.
    sub File::Spec::dirname { my $self = shift; return $self->catpath( ( $self->splitpath(shift) )[ 0, 1 ] ); } sub File::Spec::basename { my $self = shift; my $name = shift; return ($self->fileparse($name, map("\Q$_\E",@_)))[0]; } sub File::Spec::fileparse { my $self = shift; my( $suffix, $path, $name ) = $self->splitpath(shift); $path = $self->catpath( $suffix, $path, '' ); for my $s(@_){ $self =~ s/($s)$//i and last; } $suffix = $1 ? $1 : undef; wantarray ? ( $name, $path, $suffix ) : $name; }
    Check out file.spec.basename.txt to test the above with the File::Basename test suite.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re^3: Favourite modules April 2003
by kwilliams (Sexton) on Feb 09, 2005 at 20:59 UTC
    Maybe you'd like Path::Class better. I sure do, and I hope it isn't just because I wrote it. -Ken
      This only hides File::Spec underneath the covers. I expect I'd still encounter the same problems as I did before, as it will still stringify to the OS you're on. As I use Windows mostly, it doesn't integrate with Find::Find and others without some meddling.

      I have most problems with code written by others who aren't aware of the problems. Whether they use File::Spec or Path::Class, I don't see any difference between the return values being Windows style and then breaking when used directly in Find::Find or File::Basename. For them to work correctly you'll need to have:

      $file->as_foreign('Unix')
      all over the place, which kind of defeats the object of using Path::Class in the first place :(

      --
      Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://262634]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2015-07-05 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls