http://www.perlmonks.org?node_id=1078633

GeorgMN has asked for the wisdom of the Perl Monks concerning the following question:

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";