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

i am unable read content of file from other dirdectory

Replies are listed 'Best First'.
Re: Reading file from other directory
by Discipulus (Abbot) on Dec 30, 2019 at 12:00 UTC
    Hello sara1612 and welcome to the monastery and to wonderful world of Perl!

    Remember to show always what are you trying before asking (so short) questions: clear questions and runnable code get best answers is on of our mottos.

    Generally to read from file in other than current directory you need to specify a full path or a relative, correct one: see Cwd and File::Spec

    Show us more to get more help back!


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
Re: Reading file from other directory
by davido (Cardinal) on Dec 30, 2019 at 16:17 UTC

    What did you try?

    The way your brief question is worded leaves the impression that you assume there is only one obvious answer. But the fact is there are numerous ways to read a file from some other directory, and in fact, numerous meanings of "other directory." The guessing game is inefficient. So please ask a complete question.


Re: Reading file from other directory
by soonix (Canon) on Dec 31, 2019 at 16:13 UTC
    Hello sara1612, perhaps it will help, if you understand what absolute and relative paths are. You are probably referring to the files simply by their name, which is (the most common form of) a "relative path". If you use "full" paths, you can access them regardless of your current working directory.
Re: Reading file from other directory
by AnomalousMonk (Bishop) on Dec 30, 2019 at 22:57 UTC
Re: Reading file from other directory
by karlgoethebier (Abbot) on Dec 30, 2019 at 16:26 UTC

    Too bad. See Path::Tiny for some inspiration.

    «The Crux of the Biscuit is the Apostrophe»

    perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help