Hello monks, I need to seek your help again. What i am trying to accomplish is to read through a text file and grab values from strings (values from a certain, non-fixed line position in a file with non-fixed index position. What i would like to accomplish is the end up with a new array containing the values i am trying to match. I seem to be unable to break the strings into pieces in either @ or $ format. Can you please help me? Thank you in advance!

#!/usr/bin/perl -w use warnings; use strict; #use diagnostics; use Data::Dumper qw (Dumper); my $inputfile = $ARGV[0]; my @filedata; my $pattern = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4 +][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25 +[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/[0-9]?[0-9]$/; my @temps; my $counter = 0; open (INPUT, "<$inputfile") or die "no file for proccessing provided o +r existing"; while (<INPUT>) { push (@filedata, $_); } foreach (@filedata) { if ($_ =~ /$pattern/) { $counter++; #my $temp = (split ' ', $_); push (@temps, (split /\s/,$_)); } } close INPUT; #print "@temps\n"; # foreach (@temps) { if ($_ =~ /$pattern/) { print "$_\n"; } } print "Found $counter matches!\n";

In reply to Section of $string into new array by GeorgMN

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.