What is the difference between $array[1] and @array[1]?



What is the difference between $array[1] and @array[1]?..

Answer / kiruthikau

$array[1] represents a scalar value.
@array[1] represents array slicing.

@array[1] returns a list with one scalar value.

We should use $ when we want a scalar value.
If we want a list we need to use @.

If we use 'use warnings' then @array[1] will give the warnings
like ,Scalar value @array[1] better written as $array[1].

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More CGI Perl Interview Questions

Is perl a case sensitive language?

0 Answers  


what is the main function of fork() in cgi programming?

0 Answers  


When would you not use Perl for a project?

1 Answers   IBM,


What is cpan in perl?

0 Answers  


Why do you use Perl?

0 Answers  






Perl uses single or double quotes to surround a zero or more characters. Are the single(' ') or double quotes (" ") identical?

0 Answers  


Explain perl one-liner?

0 Answers  


What does 'do' statement do in perl?

0 Answers  


what are the three groups involved in information sharing?

0 Answers  


Explain lists in perl?

0 Answers  


You want to connect to sql server through perl. How would you do that?

0 Answers  


What are scalar data and scalar variables?

0 Answers  


Categories