Hello Athanasius
It seems that we have the same name.
1. I am applying this condition to check if the file is empty otherwise to break. I am not trying to the file after, unless I do not understand what you mean with write.
2. You are absolutely right about that I did not even think about it since I am putting the whole file into an array what is the point of the While () condition. Thanks
3. I was not aware for that thanks for telling me. I am still on the learning curve. :D
Seeking for Perl wisdom...on the process...not there...yet!
| [reply] |
...unless I do not understand what you mean with write.
The line in question is:
print READ "is empty!\n";
This syntax has the form print FILEHANDLE LIST, as documented in print, and it says: print the string “is empty!”, followed by a newline, to the filehandle READ. But, as I pointed out, the READ filehandle has been opened for reading (input), not writing (output). The only reason you are not seeing this die is that the files you are testing aren’t empty, so the condition never evaluates to true and the print statement is never actually called.
You probably meant to write just print "is empty!\n"; which is equivalent to print STDOUT "is empty!\n";, but you should also consider using warn "is empty!"; which is equivalent to print STDERR "is empty!\n"; (see warn).
Hope that helps,
| [reply] [d/l] [select] |
Hello Athanasius,
Oh my mistake you are absolutely right, I do not notice that believe it or not. I was thinking something completely different, because I copied this part of another script that I used and I had in my mind by READ the name of the file.
Thanks for pointing out, I should modify it now. :D
Seeking for Perl wisdom...on the process...not there...yet!
| [reply] |
print READ "is empty!\n";
as Athanasius points out: this tries to write "is empty!" to the file READ.
Probably what you intended was to print the file name with that message instead of (mis)using the file handle - should look like
print "$arg is empty!\n";
| [reply] [d/l] [select] |
Hello soonix,
Apologies, my brain was not working at the moment. I was really thinking how to solve a problem that I have with arrays of arrays and I completely forgot the meaning of the print READ. I had in my mind the name of the file as you correctly pointed out.
Thanks for your time and effort to clear it out though.
Seeking for Perl wisdom...on the process...not there...yet!
| [reply] [d/l] |