develooper Front page | perl.perl6.users | Postings from September 2017

help with map and regexp

Thread Next
From:
Luca Ferrari
Date:
September 19, 2017 10:39
Subject:
help with map and regexp
Message ID:
CAKoxK+6AOzZU5DKi=0Xfrd5Xii9pYdojTz=K4t7_QJdUOMf1JQ@mail.gmail.com
Hi all,
I'm trying to understand how to use map correctly to apply several
regexps at once, something like:

my @fields = $line.split( ',' ).map: {  s:g/\'//; s:g/^\"|\"$//;  $_ };

while the first regexp works, the second fails with "Cannot modify an
immutable Str", but the topic variable should be considered, not a
literal string.
I would replace it with the S operator, but I believe it would not do
what I want since a new string will be created as output of any
regexp.
Any suggestion?

Luca

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About