Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: divide one file into multiple arrays

by LanX (Saint)
on Jun 25, 2013 at 18:07 UTC ( [id://1040642]=note: print w/replies, xml ) Need Help??


in reply to Re^2: divide one file into multiple arrays
in thread divide one file into multiple arrays

here some suggestions to improve your code

use strict; use warnings; use Data::Dumper qw(Dumper); my @sites=qw/ www.yahoo.com www.google.com www.comcast.com /; my @bad_log; LINE: while (my $line = <DATA>) { my $www = (split / /,$line)[5]; foreach my $site (@sites) { next if $site eq ""; if ( $www =~ /\Q$site/ ) { push @bad_log, $line; next LINE; } } } print Dumper \@bad_log; __DATA__ X456 TV-yes DB-no 123.12.23.45 dealio3 www.google.com-------- FX-yes d +53 Y-03 X123 TV-yes DB-yes 34.154.43.21 dealio1 www.ask.com-------- FX-no d01 +Y-03 X412 TV-no DB-no 192.365.25.23 rayovac2 www.microsoft.com--- FX-yes d1 +3 Y-07

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-19 09:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found