in reply to What does $_ = qq~"$_"~ do?
Hi,
You can try it!
It's forcing the string to include leading and trailing double quotations marks as part of the string. The use of the tilde character to define the start and end of what's passed to qq) is just a style choice and doesn't affect the code. ($ perl -Mstrict -wE '$_ = q{foo}; $_ = qq~"$_"~; say $_' "foo"
In this case, the code is doing so if the string contains a comma, so it is undoubtedly a misguided attempt to manually escape values in a delimited file. You should never attempt to do that yourself, as it's more complicated that it might seem. Instead, use a module designed for handling delimited files, such as Text::CSV.
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What does $_ = qq~"$_"~ do?
by AnomalousMonk (Archbishop) on May 27, 2019 at 18:55 UTC | |
|
Re^2: What does $_ = qq~"$_"~ do?
by Tux (Canon) on May 27, 2019 at 20:51 UTC | |
|
Re^2: What does $_ = qq~"$_"~ do?
by mkj (Initiate) on May 28, 2019 at 03:39 UTC | |
by haukex (Archbishop) on May 28, 2019 at 07:55 UTC | |
by Fletch (Bishop) on May 28, 2019 at 14:32 UTC | |
by haukex (Archbishop) on May 28, 2019 at 20:28 UTC | |
by AnomalousMonk (Archbishop) on May 28, 2019 at 21:19 UTC | |
| |
by LanX (Saint) on May 28, 2019 at 21:51 UTC | |
|