Change a directory : chdir « File « Perl






Change a directory

    

#!/usr/bin/perl -w

use strict;

print "please enter a directory name: ";
chomp(my $dir = <STDIN>);

mkdir $dir, 0777 or die "failed to make directory $dir: $!\n";
print "made the directory $dir ok!\n";

chdir $dir or die "failed to change into $dir: $!\n";
print "changed into $dir ok!\n";

   
    
    
    
  








Related examples in the same category

1.Using chdir to change the current directory
2.Change dir with chdir