Help for this page
Select Code to Download
Select
or
download this
#!/usr/local/bin/perl
Select
or
download this
use strict;
Select
or
download this
use File::Path;
Select
or
download this
use File::Basename;
Select
or
download this
print"enter the path\n";
Select
or
download this
my $ans=<STDIN>;
Select
or
download this
chomp($ans);
Select
or
download this
my $path= dirname($ans);#I dont have to use this I know.I am just checking here.
Select
or
download this
my $file= basename($ans);#I dont have to use this I know.
Select
or
download this
$ans=~ s/\\/\//gi;#All my file open statements worked well #with c:/bla/bla instead of c:\bla\bla;
Select
or
download this
print $ans; #to make sure that I am replacing all "\" with "/";
Select
or
download this
open(FH,"<$ans") or die $!;
Select
or
download this
@lines=<FH>;
Select
or
download this
print "\n@lines-bla\n";#bla is to check the print statement:Just prints bla there,not printing file contents;
Select
or
download this
Here is the output: