Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: perl can find the file but can not open the file

by toolic (Chancellor)
on Mar 10, 2013 at 02:30 UTC ( #1022637=note: print w/ replies, xml ) Need Help??


in reply to perl can find the file but can not open the file

perlcritic can identify such errors:

[ValuesAndExpressions::RequireInterpolationOfMetachars] String *may* require interpolation at line 12, near \'FH0, \'<./$file\ +'\'. (Severity: 1)'


Comment on Re: perl can find the file but can not open the file
Download Code
Re^2: perl can find the file but can not open the file
by ShermW0829 (Acolyte) on Mar 10, 2013 at 22:24 UTC

    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

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1022637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (14)
As of 2014-08-21 14:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls