cancel
Showing results for 
Search instead for 
Did you mean: 

Help on Perl Script.

SOLVED
Go to solution
Junior C.
Frequent Advisor

Help on Perl Script.

I'm trying to delete all " from file. Following are a snippet of perl script.

my @MYFILE=;
foreach my $value (@MYFILE)
{
$value =~ s/\"//g;
print "$value";
}
close (OUT);


Output:
"LastName FirstName" 76

Output I'm trying to get
LastName FirstName 76

Appreciate all help


JC

2 REPLIES
Stuart Browne
Honored Contributor
Solution

Re: Help on Perl Script.

This one-liner does the job:

perl -pi -e 's/"//g' file

Does it in-place, and quickly.
One long-haired git at your service...
James R. Ferguson
Acclaimed Contributor

Re: Help on Perl Script.

Hi:

As Stuart showed:

# perl -pi -e 's/"//g' file

...eliminates a double quote (globally).

The file is updated "in-place". If you want to preserve a backup (old) version, simply specify an argument after the "i" switch like:

# perl -pi.old -e 's/"//g' file

...which will preserve the original "file" as "file.old".

You can process multiple files at once by listing all their names as the script's arguments:

# perl -pi -e 's/"//g' file1 file2 file3 ...

Regards!

...JRF...