Skip to content

Instantly share code, notes, and snippets.

@araraloren
Created December 28, 2015 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save araraloren/8e91279a76868b5810eb to your computer and use it in GitHub Desktop.
Save araraloren/8e91279a76868b5810eb to your computer and use it in GitHub Desktop.
Perl6
# 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