Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: divide one file into multiple arrays

by Preceptor (Deacon)
on Jun 25, 2013 at 17:31 UTC ( [id://1040634]=note: print w/replies, xml ) Need Help??


in reply to divide one file into multiple arrays

I'm not entirely sure what's going on, but I note when you do your pattern match, you don't include an operator (usually - you need 'm' for 'match' 's' for substitute, or tr for transliteration). I don't know if that should work or not. How does this work:

if ( m/$site/ ) { print "$_ matched $site\n"; push ( @bad_log, $_ ); }

Replies are listed 'Best First'.
Re^2: divide one file into multiple arrays
by kcott (Archbishop) on Jun 26, 2013 at 03:29 UTC
    "usually - you need 'm' for 'match' ..."

    You don't need it for /pattern/ or 'pattern'. You also don't need it for ?pattern?; however, that construct is deprecated.

    #!/usr/bin/env perl use strict; use warnings; my $x = 'abc'; if ($x =~ /b/) { print "y\n" } else { print "n\n" } if ($x =~ 'b') { print "y\n" } else { print "n\n" } if ($x =~ ?b?) { print "y\n" } else { print "n\n" }

    Output:

    $ junk Use of ?PATTERN? without explicit operator is deprecated at ./junk lin +e 7. y y y

    See perlop - Regexp Quote-Like Operators for details.

    -- Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 08:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found