Help for this page

Select Code to Download


  1. or download this
    #!/usr/local/bin/perl
  2. or download this
    use strict;
  3. or download this
    use File::Path;
  4. or download this
    use File::Basename;
  5. or download this
    print"enter the path\n";
  6. or download this
    my $ans=<STDIN>;
  7. or download this
    chomp($ans);
  8. or download this
    my $path= dirname($ans);#I dont have to use this I know.I am just checking here.
  9. or download this
    my $file= basename($ans);#I dont have to use this I know.
  10. or download this
    $ans=~ s/\\/\//gi;#All my file open statements worked well #with c:/bla/bla instead of c:\bla\bla;
  11. or download this
    print $ans; #to make sure that I am replacing all "\" with "/";
  12. or download this
    open(FH,"<$ans") or die $!;
  13. or download this
    @lines=<FH>;
  14. or download this
    print "\n@lines-bla\n";#bla is to check the print statement:Just prints bla there,not printing file contents;
  15. or download this
    Here is the output: