DomX has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks!
This is the first time I write something here. Mostly I found solutions in documentations, existing entries here or platforms like stackoverflow.This time I wasn't able to find a similar problem anywhere, so I decided to ask myself.
(There may be already the question answered anywhere I have, but I didn't get it, it was the same problem.)
When this part of code is executed it tells meforeach my $file ( @files ) { open(my $fh, ">>", $file->{full_path}); # or return(0); print $fh $file->{content}; close($fh); # or return(0); chmod(0755, $file->{full_path}); print "Created \"$file->{full_path}\" with $file->{line_counte +r} line" , ( $file->{line_counter} > 1 ) ? "s" : "" , "\n"; }
print() on closed filehandle $fh at ./Make.pl line 223. Can't open perl script "../Path/to/file.pm": File or directory not fou +nd
First I didn't get it, because the returns just omitted writing the next files.
How can I do multiple open within the foreach, without print() failing?
I feel as if the open() wasn't executed every time as I expected
The loop is executed within a subroutine.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: foreach a writing open fails through not found file
by haukex (Archbishop) on Jun 23, 2019 at 13:05 UTC | |
by DomX (Novice) on Jun 23, 2019 at 14:29 UTC | |
by haukex (Archbishop) on Jun 23, 2019 at 15:03 UTC | |
by DomX (Novice) on Aug 05, 2020 at 20:25 UTC |
Back to
Seekers of Perl Wisdom