in reply to Re: perl can find the file but can not open the file
in thread perl can find the file but can not open the file

Thank you to everyone. This has been an informative experience. It all started because I ran the script I created and somehow it took the text file I was reading from and emptied it which I didn't notice. So I ran the script again without any errors but without any returns either. So I thought the script was bad which it was but I have since fixed. But since I didn't know exactly what the script was doing I wrote a smaller try script which is the one we are talking about. It returned no errors but no results either since I was still working with the null text file. So I searched the internet and found the site that suggested the single quotes and so here we now are.

Installing Perl::Critic was fun since I had to find and install numerous modules to get it past the make test. Is there a way to find all the dependencies before I try to install a module from CPAN?

Again thank you to all. Sherman

  • Comment on Re^2: perl can find the file but can not open the file

Replies are listed 'Best First'.
Re^3: perl can find the file but can not open the file
by 7stud (Deacon) on Mar 11, 2013 at 05:23 UTC

    So I searched the internet and found the site that suggested the single quotes

    So your question boils down to: "In the following code, I used the exact same string for a file test and in open(), yet my code doesn't work as expected:

    if ( -e "$file" ) open ( FH0, '<./$file' )

    Stripping away the code, one can only wonder why you think the two strings:

    "$file"
     '<./$file' 
    

    ...are the same. There are several differences.

    So I searched the internet and found the site that suggested the single quotes

    You can learn about the difference between double quotes and single quotes, as well as many other useful things, like how to properly open() a file, which you aren't doing, in "Learning Perl 6th".

    Is there a way to find all the dependencies before I try to install a module from CPAN?

    Well, most people don't install from source. Instead, they just type:

    $ cpan Some::Module

    and the cpan command handles downloading and installing all the dependencies. However, the first time you try to use the cpan command, you have to do some setup, which may or may not go smoothly.

    More recent versions of perl come with the cpanm command, which stands for cpan minus, which is like cpan, but with no setup required:

    $ cpanm Some::Module

    And if you don't have cpan minus, you can download the App::cpanminus module from cpan.

    There are two kinds of perl, modern perl and the shite that existed before that. You seem to be learning the shite. I suggest you alter course.

      Thank you, 7stud. Poker player? That is what I started with in 1968 and have been a poker fan since. Played for a living in Las Vegas for two years. Loved it.

      I found that I have cpan cpanm and cpanp by using the which command. I also found that an update is available for cpan so I installed that by using sudo cpan install CPAN. Sherman