Reading your description, here is my *UNTESTED* code that I think (minus the possibility of small typos) to do what you are requesting:

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use File:Basename; use File::Spec; use Getopt::Long; $| = 1; # Next 3 lines are my preference for debugging srand(); $Data::Dumper::Deepcopy = 1; $Data::Dumper::Sortkeys = 1; my %configuration = ( x => 0, y => 0, data_directory => q{g:/Frames as bitmap/}, file_extension => q{txt}, output_file => $0 . q{.output}, delimiter => q{,}, ); GetOptions( q{x_coordinate:s} => \$configuration{x}, q{y_coordinate:s} => \$configuration{y}, q{data_directory:s} => \$configuration{data_directory}, q{file_extension:s} => \$configuration{file_extension}, q{output_file:s} => \$configuration{output_file}, q{help} => \&help_output, ); sub help_output { print qq{Usage:\n\t$0 } . qq{--x_coordinate=nnn --y_coordinate=nnn } . qq{--data_directory=path/to/data/files } . qq{--file_extension=file.extension.to.match } . qq{--output_file=output.file.name\n\n} . qq{\t\t--x_coordinate, --y_coordinate } . qq{\t\t\t- pixel coordinate to match\n} . qq{\t\t--data_directory} . qq{\t\t\t- directory containing data files\n} . qq{\t\t--file_extension } . qq{\t\t\t- file extension to glob(), such as 'txt'\n} . qq{\t\t\t\t(assumes leading '.')\n} . qq{\t\t--output_file - file name to write data to\n\n}; exit; } my @files = sort { $a cmp $b } glob File::Spec->catfile( $configuration{data_directory}, q{*} . q{.} $configuration{file_extension}, ); open my $outf, q{>}, $configuration{output_file} or die $!; my $format_string = join( $configuration{delimiter}, q{%s}, q{%d}, q{%d}, q{%d} ) . qq{\n}; foreach my $fn ( @files ) { my $f_id = File::Basename::basename $fn; $f_id =~ s/\.$configuration{file_extension}.*$//g; open my $inf, q{<}, $fn or die $!; while ( my $line = <$inf> ) { chomp $line; my @data = split /\s+/, $line; # Example input data (x y r g b): # 0 0 113 0 255 next if ( $data[0] != $configuration{x_coordinate} ); next if ( $data[1] != $configuration{y_coordinate} ); # Example output data: nnnnn,nnn,nnn,nnn # 12345,255,032,127 print $outf sprintf $format_string, $f_id, @data[2-4]; last; } close $inf; } close $outf;

Please comment if that does indeed do so, or if your expectations differed from those I understood.

Hope that helps.


In reply to Re: need logic, police edited video by atcroft
in thread need logic, police edited video by AwsedreswA

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.