finddata has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to read directories from the text file using perl?
by poj (Abbot) on Mar 23, 2017 at 07:09 UTC
    I couldnt make the correct code for the above requirements
    #!/usr/bin/perl; use strict; # I have the text file named as data.txt. my $infile = 'data.txt'; # Now i like to read the line from data.txt open IN,'<',$infile or die "$!"; print "Reading from '$infile'\n"; my $dir; while (<IN>){ chomp; # in which the line # starts with ZERO # contains the directory path? if (/^ZERO:(.*)/){ $dir = $1; } } close IN; print "Directory is '$dir'\n";

    What's the problem, which part couldn't you do ?

    poj
Re: How to read directories from the text file using perl?
by davido (Cardinal) on Mar 23, 2017 at 06:04 UTC

    FindBin is probably a more appropriate choice than Cwd for this purpose.


    Dave

      But the FindBin will read the folders directly from the location.How it will read from one text file?
        Why not copy/paste from your previous programs or perlintro?