Multiple variable in a variable in Perl

Hi All,

I am trying to convert the below Csh while loop into Perl while loop but the problem is that in this csh script, i have 2 variables inside a variable -> $count is a variable {SB$count} as a whole is another variable. Csh is able to assign values to such variable like the below but i do not know if this is possible in Perl.
Can any expert give some advice?

[code]
while ( $count <= 5 ) then
set SB$count = `cat $files_extracted.txt|grep -c "x= $count"`
@ count = $count + 1
end

[code]

This isn't a "variable inside a variable" (which is possible in Perl using references for example), but a bad excuse for an array. A literal translation of your code would be something like

for($i=0;$i<=5;$i++) {
    $SB[$count] = `grep -c "x=$count" $files_extracted.txt`;
}

Even shaved off a line and one unnecessary cat. Be prepared to do away with a lot of CSH workarounds now that you use a real scripting language.

Hi Pludi,

Thks for the advice.
But if my csh statement is the below. How can i convert the below to Perl ?

set SB$count = `cat $tester_dir/files_extracted.txt|grep "HARD_BIN:"|awk '{print ($2)}'|grep -c $count`
$SB1 = `cat $tester_dir/files_extracted.txt|grep "HARD_BIN:"|awk '{print \$2}'|grep -c $count`;

tyler_durden