-
-
Save Ovid/e0778e99f188341726df to your computer and use it in GitHub Desktop.
Can we get a version of .perl which forces string context?
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
# Given: | |
# $ cat plans.csv | |
# this,that | |
# one,two | |
# same,same | |
#!/usr/bin/env perl6 | |
# vim: ft=perl6 | |
my $fh = open('plans.csv', :r); | |
my %pairs = gather for $fh.lines { | |
if /^^ (\w+) ',' (\w+) $$/ { | |
take $0 => $1; | |
} | |
} | |
say %pairs.perl; | |
# ("this" => Match.new(orig => "this,that", from => 5, to => 9, ast => Any, list => ().list, hash => EnumMap.new()), "same" => Match.new(orig => "same,same", from => 5, to => 9, ast => Any, list => ().list, hash => EnumMap.new()), "one" => Match.new(orig => "one,two", from => 4, to => 7, ast => Any, list => ().list, hash => EnumMap.new())).hash | |
# If I force string context (~$1), I get this: | |
# ("same" => "same", "one" => "two", "this" => "that").hash | |
# I don't want to force string context when I put it in the hash because I might want the Match data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment