@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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.