in reply to perl script to remove part of double quote

Hello sud100,

I did a very basic search using the following search text on Google "perl how to remove double quotes from string".

The first result that came up is How to remove double quotes?.

If I was you, in case that I have a problem and I want to learn a bit more about programming, I would search a bit more and I would test multiple possible solutions not just one.

I am pretty sure that it took you much more time to post this question on this forum than actually make a search and test the code for your self.

The following pieces of code are taken from the link above:

#!/usr/bin/perl use strict; use warnings; use Benchmark::Forking qw( timethese cmpthese ); # UnixOS # use Benchmark qw(:all) ; # WindowsOS my $string = q{asd" efg"}; sub Solution_1 { # Solution 1 $string =~ tr/"//d; # print $string . "\n"; # asd efg } sub Solution_2 { # Solution 2 $string =~ tr/"/'/; # print $string . "\n"; # asd efg } sub Solution_3 { # Solution 3 $string =~ s/^"(.*)"$/$1/; # print $string . "\n"; # asd efg } sub Solution_4 { # Solution 4 $string =~ s/"/'/g; # print $string . "\n"; # asd efg } my $results = timethese(10000000, { Solution_1 => \&Solution_1, Solution_2 => \&Solution_2, Solution_3 => \&Solution_3, Solution_4 => \&Solution_4, }, 'none'); cmpthese( $results ); __DATA__ $ perl test.pl Rate Solution_3 Solution_1 Solution_2 Solution_4 Solution_3 7352941/s -- -63% -65% -65% Solution_1 20000000/s 172% -- -6% -6% Solution_2 21276596/s 189% 6% -- 0% Solution_4 21276596/s 189% 6% 0% -- =comment Would anyone care to share why perl can do tr/"/'/ faster than s/"/'/? Because s/// has to be able to handle all RE syntax and specialness wh +ile tr/// just considers its input to (mostly) be a simple character class +. Much easier to deal with and, thus, much faster. =cut

Update: I read your question again, and I assume from the part of your explanation I tried with $_=~ s/"//g; but gives an error that the error is coming from somewhere else. Since $_=~ s/"//g; it does more or less of what you expect (removing the double quotes) as AnomalousMonk proved above is your error (Use of uninitialized value $_ in substitution (s///) at <your script> <line number>)?

Something like that?

#!/usr/bin/perl use strict; use warnings; sub test_subroutine { $_[0] =~ s/"//g; return $_[0]; } my $string = q{asd" efg"}; my $string_formatted = test_subroutine($string); print $string_formatted . "\n"; # asd efg

Help us to help you, provide us sample of your code that replicated the error.

Hope this helps.

Seeking for Perl wisdom...on the process of learning...not there...yet!