hghosh has asked for the wisdom of the Perl Monks concerning the following question:
Hello, Perl Monks. I'd like to know what $_ refers to in line 6. This script was written in 2010 by someone else who didn't use "use warnings" or "use strict." I'm aware split() no longer works in a void context. I'd like to know which value the $_ refers to. Does it refer to what is later called $line? Does it still mean the same thing in the second, strict version?
Here is my "strictured" version:#var $cutoff defined earlier in script open IN, "$filename.merged"; while (<IN>) {chomp; split(/\t/); if ($_[1] >= $cutoff){ $_[0] =~/(chr.+):(\d+)-(\d+)/; foreach ($2..$3) {$breakpoint{$1}{$_}=1;} #what is $_? } }
open IN, "$filename.merged"; while (<IN>) { chomp(my $line= $_); my @array = split(/\t/, $line); if ($array[1] >= $cutoff){ # cutoff is defined earlier in original + script $array[0] =~/(chr.+):(\d+)-(\d+)/; foreach ($2..$3) {$breakpoint{$1}{$_}=1;} #would it be $line?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Perl 5.10.1 or before)What does $_ refer to here?
by LanX (Saint) on Jun 10, 2019 at 00:46 UTC | |
by hghosh (Acolyte) on Jun 10, 2019 at 12:50 UTC | |
by Athanasius (Archbishop) on Jun 10, 2019 at 13:32 UTC | |
by LanX (Saint) on Jun 10, 2019 at 13:35 UTC | |
|
Re: (Perl 5.10.1 or before)What does $_ refer to here?
by ForgotPasswordAgain (Vicar) on Jun 13, 2019 at 13:41 UTC |