# gb.pl 07.07.21 use strict; use IO::File; my(%t,$f_ref,@fld); # Read raw data open(FH,"shipGB1.txt") or die "Can't open the file shipGB1.txt\n"; while(<FH>){ @fld = split; next until $fld[1]; $$f_ref{line1} = $_; if (/^GB/ or /^SY/ or /^DL/) { $$f_ref{f1} = 'gb.txt'; ($f_ref) = write_file($f_ref); } elsif (/^NF/ ) { $$f_ref{f1} = 'nf.txt'; ($f_ref) = write_file($f_ref); } elsif (/^ASTM/ or /^ANSI/ or /^ASME/ or /^UL/ ) { $$f_ref{f1} = 'astm.txt'; ($f_ref) = write_file($f_ref); } elsif (/^EN/ or /^prEN/) { $$f_ref{f1} = 'en.txt'; ($f_ref) = write_file($f_ref); } elsif (/^BS/ ) { $$f_ref{f1} = 'bs.txt'; ($f_ref) = write_file($f_ref); } elsif (/^DIN/ ) { $$f_ref{f1} = 'din.txt'; ($f_ref) = write_file($f_ref); } elsif (/^IEC/ or /^PD/) { $$f_ref{f1} = 'iec.txt'; ($f_ref) = write_file($f_ref); } elsif (/^ISO/ ) { $$f_ref{f1} = 'iso.txt'; ($f_ref) = write_file($f_ref); } elsif (/^JIS/ ) { $$f_ref{f1} = 'jis.txt'; ($f_ref) = write_file($f_ref); } else { $$f_ref{f1} = 'others.txt'; ($f_ref) = write_file($f_ref); } } close(FH); sub write_file { my($f_ref) = @_; my($fh); $fh = new IO::File ">> ./doc/$$f_ref{f1}"; if (defined $fh) { print $fh $$f_ref{line1}; $fh->close; } return($f_ref); } __END__