in reply to Re^3: Script using File::Spec fails...
in thread Script using File::Spec fails...
Then a 2nd example, to show additional functionality provided by File::Spec:#!/usr/bin/perl -w use strict; use File::Basename; 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 = "$dirname/$basename"; rename ($old_name, $new_name) or warn "Can't rename '$old_name' to '$new_name': $!";
My question is... What additional functionality has the second script provided? Both scripts run effectively on both unix and windows systems. I'm missunderstanding the advantage that File::Spec should be adding. Also, thanks for the tip about turning module names into clickable links!#!/usr/bin/perl -w use strict; use File::Basename; 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': $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Script using File::Spec fails...
by syphilis (Archbishop) on May 26, 2007 at 16:03 UTC | |
by jdporter (Paladin) on May 26, 2007 at 17:32 UTC | |
|
Re^5: Script using File::Spec fails...
by blazar (Canon) on May 26, 2007 at 19:01 UTC |