
PGScooter
stranger
Apr 5, 2009, 4:37 PM
Post #1 of 5
(9607 views)
|
using a substitution with a map
|
Can't Post
|
|
Hi, I have a list of items like this "one" "two" "three" in an array @countrylines. Note that the quotation marks are in the actual list items. I want to remove the quotation marks. I have two questions: 1. What is the quickest way to do this? 2. How can I do this by mapping a substitution? I ended up doing the following:
my @unquoted=map { /"(.*)"/ } @countrylines; but I would like to know how to use a substitution within a map. I tried to do the following:
my @unquoted=map { s/"//g } @countrylines; I do kind of understand why this doesn't work. I believe it's equivalent to doing something like this for a string: $unquoted = ($countrylines=~s/"/g); which I think returns the number of substitutions made. thanks! The more you teach me, the more I learn. The more I learn, the more I teach.
|