Home: Perl Programming Help: Intermediate:
$var =~ s|,$|| command



TClayJ
New User

May 24, 2016, 11:37 AM


Views: 3793
$var =~ s|,$|| command

I've been given the job of supporting some perl applications and I'm trying to figure out what this line of code is trying to do given this type of input. A tar file is being processed and give this code what is suppose to be assigned to $var based on the tar file looking like...

dir1/
dir1/file1.gz
dir1/file2.gz
dir1/file3.gz
dir1/file4.gz

open ( T, "tar -xvf test.tar" ) || die "cannot open";
while(<T>) {
my ( $x, $var ) = split();
$var =~ s|,$||;
}


(This post was edited by TClayJ on May 24, 2016, 11:49 AM)


Laurent_R
Veteran / Moderator

May 24, 2016, 2:01 PM


Views: 3790
Re: [TClayJ] $var =~ s|,$|| command

It seems that it is trying to remove any comma at the end of the $var string.