lina wrote:
Hi,
Hello,
I don't know which is the best way to "check whether this file is open or not," Here it what I came out so far, #!/usr/bin/env perl use strict; use warnings; use autodie qw(open close); use 5.012; my $fn = "new_30.pdb"; open my $fh, '<', $fn; my $ofh; while(my $line =<$fh>){ if($line =~ /MODEL \s+(3|5|80|89|459)$/){ my $model = $1; open $ofh, '>', "extracted_$model.pdb"; print $ofh $_; } if($line =~ /ENDMDL/){ close($ofh) if ; ####### here I wish to check whether it's okay,
close $ofh if fileno $ofh;
if it's open, then close, if it's closed, then do nothing. } }
John -- Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction. -- Albert Einstein -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/