Created
December 28, 2015 14:57
-
-
Save araraloren/8e91279a76868b5810eb to your computer and use it in GitHub Desktop.
Perl6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some comment .... | |
EN -> value1 | |
CN -> value2 | |
EN -> value3 | |
CN -> value4 | |
-------------------above is inputfile content | |
###sample code | |
my $pattern = "value1"; | |
my @lines = "inputfile".IO.lines; | |
my ($cn, $en); | |
for @lines -> $line { | |
# ignore comment line | |
if $line ~~ / EN \s '->' $<env> = \s (.*)/ { | |
$en = $<env>; | |
$line = @lines.shift; | |
if $line ~~ / CN \s '->' $<cnv> = \s (.*)/ { | |
$cn = $<cnv>; | |
# when match $cn or $en | |
if $cn ~~ $pattern || $en ~~ $pattern { | |
# do something | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment