Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: This has me stumped, pattern matching, 2 files

by tsk1979 (Scribe)
on Nov 21, 2006 at 06:54 UTC ( [id://585204]=note: print w/replies, xml ) Need Help??


in reply to Re: This has me stumped, pattern matching, 2 files
in thread This has me stumped, pattern matching, 2 files

Thanks! the two files will always be in sync because file A is generated from a log of a code run over file B, and then parsed by a script which ensures this. One question though
$line{$.} = undef if /$X/;
Should it not be $line{$.} = undef if /X/? I dont want $X because the pattern can be anywhere. when I say $line{$.} = undef does this mean that this is undefined, but "exists"?

Replies are listed 'Best First'.
Re^3: This has me stumped, pattern matching, 2 files
by Zaxo (Archbishop) on Nov 21, 2006 at 07:03 UTC

    I used $X, $Y, and $Z just to indicate they can vary and that it doesn't matter where they come from. You didn't specify an actual source for the patterns. If you assign regexen and substitution strings to those variables, the code will work as written -- give or take an /e in the substitution.

    The $line{$.} = undef construction just creates a key in the %line hash without associating a value with it. Nothing of the actual file but line numbers is being stored.

    After Compline,
    Zaxo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found