Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

FILE::PATH question

by erbin (Novice)
on Jan 05, 2010 at 09:56 UTC ( #815721=perlquestion: print w/ replies, xml ) Need Help??
erbin has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I met a problem when using modules FILE::PATH.

I try the code in perldoc as follow

#!/bin/perl use strict; use warnings; use File::Path qw(make_path remove_tree); make_path("E:\\Project\\Training Project\\Learning Perl\\modules\\FILE +\\Temp\\temp1");

Error occurred when compile

"make_path" is not exported by the File::Path module

"remove_tree" is not exported by the File::Path module

My OS is windows and the Perl is ActivePerl5.10

Could you help me? thanks!

Comment on FILE::PATH question
Download Code
Re: FILE::PATH question
by Ratazong (Prior) on Jan 05, 2010 at 10:17 UTC

    You might want to try

    use File::Path qw(mkpath rmtree);

    At least that are the names exported by Path.pm on my system...

Re: FILE::PATH question
by zwon (Monsignor) on Jan 05, 2010 at 10:53 UTC

    Perhaps you're using the wrong File::Path. What is the output of the following:

    use strict; use warnings; use File::Path; use Data::Dumper; warn File::Path->VERSION; warn Dumper \%INC;

    Update: note that make_path and remove_tree are available only since File::Path version 2.07

      From File::Path VERSION 2.08, the SYNOPSIS section:

      # legacy (interface promoted before v2.00) mkpath('/foo/bar/baz'); mkpath('/foo/bar/baz', 1, 0711); mkpath(['/foo/bar/baz', 'blurfl/quux'], 1, 0711); rmtree('foo/bar/baz', 1, 1); rmtree(['foo/bar/baz', 'blurfl/quux'], 1, 1); # legacy (interface promoted before v2.06) mkpath('foo/bar/baz', '/zug/zwang', { verbose => 1, mode => 0711 + }); rmtree('foo/bar/baz', '/zug/zwang', { verbose => 1, mode => 0711 + });
Re: FILE::PATH question
by ikegami (Pope) on Jan 05, 2010 at 19:51 UTC
    You want
    use File::Path 2.07 qw( make_path remove_tree ); make_path("...");
    or
    use File::Path qw( mkpath rmtree ); mkpath("...");

    The first will provide a better error message if the desired module is not available.

    $ perl -e'use File::Path 2.07 qw( make_path remove_tree );' File::Path version 2.07 required--this is only version 2.04 at -e line + 1. BEGIN failed--compilation aborted at -e line 1.

    The second is backwards compatible.

Re: FILE::PATH question
by erbin (Novice) on Jan 06, 2010 at 02:57 UTC

    Thank you all,

    My File:Path version is 2.04

    So I come to the "mkpath" and "rmtree" prototype.

    My further question is how to update the module?

    I try the perl package manager, but it doesn't update the FILE::PATH

      I ran into this problem too, a script I had written using File::Path suddenly stopped working. The problem turned out to be the glibc libraries had been updated since I had installed the Perl package so I need to re-compile and install the package.

        I ran into this problem too, a script I had written using File::Path suddenly stopped working. The problem turned out to be the glibc libraries had been updated since I had installed the Perl package so I need to re-compile and install the package.

        File::Path is a pure-perl module, so it shouldn't depend on anything gcc :)

        But I too have run into trouble using mingw gcc 4.5.2 toolchain on win32, i can't launch the perl debugger :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-07-06 08:39 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 (70 votes), past polls