Nikhil Hegde Nikhil Hegde - 3 months ago 19
Perl Question

Not sure of the reason for output value

I have these two statements in a perl code that I'm trying to understand.

our $CSITOOLS=`/x/eng/csitools/netapp_menu/common/`;
print "${CSITOOLS}\n";



How does
work? (In this case



From perldata:

As in some shells, you can enclose the variable name in braces to disambiguate it from following alphanumerics (and underscores).

That is:

If you have a variable like $foo and you want to interpolate that whithin a string:

my $string = "This is $foobar";

then Perl would look for the variable $foobar. To make clear your variable's name is just $foo you need to write

my $string = "This is ${foo}bar";

This is the way to delimit the variable's name. In your particular case the curlies {} aren't needed because "$CSITOOLS\n" already is unambiguous. However, it does no harm.