Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: extracting data from an input file and associated errors

by jwkrahn (Monsignor)
on Feb 02, 2012 at 23:47 UTC ( #951559=note: print w/ replies, xml ) Need Help??


in reply to extracting data from an input file and associated errors

open (DATA, "< C:/Perl_Scripts/InputFile.txt");

You should verify that open worked correctly:

open my $DATA, '<', 'C:/Perl_Scripts/InputFile.txt' or die "Cannot ope +n 'C:/Perl_Scripts/InputFile.txt' because: $!";


my @array_of_data = <DATA>; close (DATA); foreach my $line (@array_of_data) {

There is no need to read the entire file into memory first:

while ( my $line = <$DATA> ) {


if ( $line =~ m/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\.csv$/g ) { print "Match $1"; }

The pattern is anchored at the end of the line so the /g option is superfluous.    You are not using capturing parentheses in the pattern so there is nothing in $1 to print out.


Comment on Re: extracting data from an input file and associated errors
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2015-07-30 17:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls