Hi! Thanks for the comment! I have corrected that. Here is the upated script:
sonya$ vi sorting.pl #!/usr/bin/perl use strict; use warnings; use Getopt::Long; my $version="0.2"; my $files_match=""; my $files_dir=""; my $file_name=""; my $help_flag=""; my $version_flag=""; GetOptions( 'm|match=s' => \$files_match, 'd|directory=s' => \$files_dir, 'h|help' => \$help_flag, 'v|version' => \$version_flag, ); sub sorting { my @lines = @_; my @sorted = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { my ($x) = $_ =~ /VerNumber:\((\d+)/i; [$_, $x]; } @lines; print FILE for @sorted; } if (($files_match ne "") and ($files_dir ne "")) { chdir("$files_dir") or die "$!"; opendir (DIR, ".") or die "$!"; my @files = grep {/$files_match/} readdir DIR; my $files_size = $#files + 1; my $index_file = 1; print "Files to process: $files_size\n"; close DIR; foreach (@files) { open(FILE, ">./sorted/$_.sort") or die $!; my @singlefile = $_; print "Processing $index_file of $files_size files: $_ ++\n"; local @ARGV = @singlefile; while(<>){ sorting($_); } close(FILE); $index_file++; print "OK: Sorted @singlefile \n"; } } elsif ((!$help_flag) and (!$version_flag)){printHelp();} "sorting.pl" [New] 49L, 1391C written
However, I am still getting the unchanged files as a result:
sonya$ ./full.pl -d /home/sonya/test/ -m file Files to process: 3 Processing 1 of 3 files: file1.txt+ OK: Sorted file1.txt Processing 2 of 3 files: file2.txt+ OK: Sorted file2.txt Processing 3 of 3 files: file3.txt+ OK: Sorted file3.txt sonya$ diff /home/sonya/test/file1.txt /home/sonya/test/sorted/file1.t +xt.sort sonya$ sonya$
The standalone sorting script is working so there is something wrong with my code.

In reply to Re^2: Use Schwartzian transform across multiple files by Sonya777
in thread Use Schwartzian transform across multiple files by Sonya777

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.