7

When I started with variables to print a variable $foo in a string

I used print ${foo}s but when I used print "$(foo)s" it gave me

1000 4 24 27 30 46 108 125 1000)s . When I printed $( or $) it gives me the sequence 1000 4 24 27 30 46 108 125 1000 . Also $[ gave 5.014002 and $] gave 0 . What do they mean?

1
  • 3
    perldoc -v $( (use quoting appropriate for your system if necessary) is a quick way to look up built-in variables.
    – TLP
    Dec 5, 2013 at 11:42

2 Answers 2

10

$( = The real gid of this process.

$[ = This variable stores the index of the first element in an array, and of the first character in a substring. The default is 0.

$) = The effective gid of this process.

$] = Perlversion

seen here: http://perldoc.perl.org/perlvar.html

1
  • 1
    Actually if you have use 5.16.0 (or later) in your code $[ can only ever be 0, unless you load arybase with use feature qw'arybase'; or explicitly with use arybase;. Dec 5, 2013 at 20:18
7

See perldoc perlvar (in fact, see it any time you have a question about $ followed by a symbol).

$( and $) give the real and effective gids of the process.

You get a space separated list of gids if the system supports membership in multiple groups simultaneously.

$[ is the index considered to be the first element of an array.

$] is an old way to get the version of Perl being used to run the program.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.