Hi,

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,
if it's open, then close, if it's closed, then do nothing.
        }
        

}

Thanks with best regards,

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to