note
farang
<p>I'm <b>guessing</b> that the reason for the <tt>open</tt>
failure is that the correct path should be something like this.
<c>
/Users/lomSpace/Desktop/Pipelines/
</c>
I'll assume that below.
The advice other monks have given is excellent if you are using
the traditional <tt>open</tt> function, but in the spirit of "there
is more than one way to do it" here is another approach.</p> <p>The
module [mod://Path::Tiny] is great, and I tend to look to it first when
opening files. After installing it, the following could be done.
<c>
...
use Path::Tiny;
my $in = path('/Users/lomSpace/Desktop/Pipelines/fungi.1.aa.hypothetical.faa')->slurp;
my $out = path('/Users/lomSpace/Desktop/Pipelines/fungi.1.aa.hypothetical50.faa')->openw;
my @chunks = split(/>/, $in);
...
</c>
The <tt>slurp</tt> method on the input file path eliminates the
need for <tt>local $/ = undef;</tt> in your code and the readline, that is
the angle bracket pair inside the split. It does mean that <tt>$in</tt>
is no longer a filehandle while <tt>$out</tt> still is so it might
be worth renaming one of the variables to make that clear.</p>
<p>[mod://Path::Tiny] also croaks automatically on failure with good error
messages. One small downside to it may be that it is not
in the core and must be installed from CPAN. Besides opening files,
Path::Tiny performs other useful functions as well.</p>
1085370
1085370