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