in reply to Re: Problems with Variable Scope in Perl
in thread Problems with Variable Scope in Perl

Thank you very much Graff! Yes, saving the @SCOPclass array is intentional. One more question though: could you kindly explain:

$pdbString[$#pdbString] .= $_;

What do the $ followed by # represent? As I am still new at Perl I get confused between these symbols! Thanks for all your help :)

Replies are listed 'Best First'.
Re^3: Problems with Variable Scope in Perl
by ruzam (Curate) on Nov 03, 2008 at 02:34 UTC
    The string contained in $_ is being joined to the string in the last element of @pdbString This code could also be written as:
    $pdbString[@pdbString - 1] .= $_;
    or
    $pdbString[-1] .= $_;
    Which I find simpler to read (negative index references the array starting from the end).
Re^3: Problems with Variable Scope in Perl
by ig (Vicar) on Nov 03, 2008 at 02:16 UTC

    $#pdbString is the index of the last element in array @pdbString. There are more examples and explanations in perldata.

Re^3: Problems with Variable Scope in Perl
by graff (Chancellor) on Nov 03, 2008 at 03:20 UTC
    Yes, saving the @SCOPclass array is intentional.

    ... and so the fact that you never use the saved values would seem to be unintentional?

      I have saved the @SCOPclass array but I am still figuring out what I want to do with it in the scope of my work! So yes, saving the values is intentional, but where I want to output the variable and how I want to use the saved values remains unintentional :)