@ikegami thanks your reply. Now it gives an error:
Scalar value @fields11 better written as $fields11 at ./analysis.pl line 40. And my input files are like this:Harmonic frequencies (cm**-1), IR intensities (KM/Mole), Raman scatte +ring activities (A**4/AMU), depolarization ratios for plane and unpolarize +d incident light, reduced masses (AMU), force constants (mDyne/A), and normal coordinates: 1 2 3 A A A atom -- 23.5214 40.9023 56.78 +56 Red. masses -- 6.7793 1.0546 5.56 +74 Frc consts -- 0.0022 0.0010 0.01 +06 IR Inten -- 2.4504 0.2236 0.61 +52
New version:
#!/usr/bin/env perl use strict; use warnings; use File::Path qw/make_path/; use Cwd; my $dir = cwd(); opendir (my $dh, $dir) or die "Unable to open current directory! $!\n" +; my @subdirs = grep { /^\.\.?\z/ } readdir($dh) or die "Unable to read +directory! $!\n"; closedir $dh; my $result_path = "$dir/results"; make_path("$result_path"); for my $subdir ( sort @subdirs ) { chdir($dir); next unless -d $subdir; make_path("$result_path/$subdir"); my $search_text1 = qr/atom/; my $infile1="$subdir/input.txt"; my $in_fh1; if (!open $in_fh1, '<', $infile1) { goto NEXT if $!{ENOENT}; die qq{Failed to open "$infile1" for reading: $!}; } my $outfile1="$result_path/output"; open $in_fh1, '<', $infile1 or die qq{Failed to open "$infile1" f +or writing: $!}; open my $out_fh1, '>', $outfile1 or die qq{Failed to open "$outfil +e1" for writing: $!}; while (<$in_fh1>) { next unless /$search_text1/; my @fields1 = split; print $out_fh1 join("\t", @fields1[1]), "\n"; } close($in_fh1); close($out_fh1); NEXT: chdir(".."); }
In reply to Re^2: Scalar value @array better written as
by erhan
in thread Scalar value @array better written as
by erhan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |