cgmd has asked for the wisdom of the Perl Monks concerning the following question:
The outcome from attempting this script is:#!/usr/bin/perl -w use strict; use File::Spec; print "Please enter a filename: "; chomp(my $old_name = <STDIN>); my $dirname = dirname $old_name; my $basename = basename $old_name; $basename =~ s/^/not/; my $new_name = File::Spec->catfile($dirname, $basename); rename ($old_name, $new_name) or warn "Can't rename '$old_name' to '$new_name': $!";
What error have I made in structuring this code? Thanks!Please enter a filename: testX Can't locate object method "dirname" via package "testX" (perhaps you +forgot to load "testX"?) at /home/cgmd/bin/learning_perl/test7.pl lin +e 9, <STDIN> line 1.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Script using File::Spec fails...
by Joost (Canon) on May 26, 2007 at 02:53 UTC | |
by cgmd (Beadle) on May 26, 2007 at 03:17 UTC | |
by blazar (Canon) on May 26, 2007 at 12:35 UTC | |
by cgmd (Beadle) on May 26, 2007 at 15:02 UTC | |
by syphilis (Archbishop) on May 26, 2007 at 16:03 UTC | |
| |
by blazar (Canon) on May 26, 2007 at 19:01 UTC |