Perl References/Dereferences


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl References/Dereferences
# 1  
Old 05-21-2010
Perl References/Dereferences

Can someone explain where can we actually used

Code:
print $var->[0];

or

print $$var[0]

When does the -> becomes necessary and when its optional.
# 2  
Old 05-21-2010
both does the same operation.

while removing the arrow, you are dereferencing using dollar, so by both you get the result...

arrows becomes unnecessary, when

Code:
if the arrow ends up between "subscripty kinds of things," such as square brackets, we can also drop the arrow

from Intermediate Perl.

Read references chapter for more clarification on the same.
This User Gave Thanks to thegeek For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sort references

I have the following entries and want to perform a sort. Each entry is separated by a newline, however each line should not be considired seperate. Maybe an awk program or similar, or a small script. Anderson, E.R., Duvall, T.L., Jr., and Jefferies, S.M., 1990. Modelling of Solar... (6 Replies)
Discussion started by: kristinu
6 Replies

2. Shell Programming and Scripting

awk Programming references

Hi all, I am new and I am very interested in Awk programming language and would like to know what references or books that really worked for you that was clear, concise with simple examples. much appreciated in advance. (1 Reply)
Discussion started by: Apollo
1 Replies

3. Shell Programming and Scripting

Query related to references in array in Perl

Hi All I have a doubt and want to be cleared I am using @array = (10, 20); $rarray = \@array; #print "$rarray\n"; #print "@$rarray\n"; $rr= \$array; #print $$rr; $rr++; print $$rr; As you can see the $rr contains the reference to the first element of the array , now as the... (5 Replies)
Discussion started by: parthmittal2007
5 Replies

4. Shell Programming and Scripting

Strip one of two Patch references

This log file is wacky. the syntax puts this in the Installation line: Installation PATCH75682.91 of PATCH75681 complete Installation PATCH76537.91 of PATCH76537 complete Installation PATCH92217.91 of PATCH92217 complete So I'm looking for a sed 's///' to remove the first PATCHxxxx... (6 Replies)
Discussion started by: dba_frog
6 Replies

5. Shell Programming and Scripting

perl - passing hash references to functions

hi there I have the following script in which i have created a PrintHash() function. I want to pass to this function the reference to a hash (in the final code i will be passing different hashes to this print function hence the need for a function). I am getting an error Type of arg 1 to... (1 Reply)
Discussion started by: hcclnoodles
1 Replies

6. Programming

Wanted: References on Sockets and Threads for C

I'm looking at http://www.opengroup.org/pubs/online/7908799/xsh/pthread.h.html trying to understand mutexs and semaphores. Windows makes a distinction between the two. Is a mutex and semaphore different in unix land? Is there a tutorial on threading in unix somewhere? I'm also looking at... (4 Replies)
Discussion started by: siegfried
4 Replies

7. UNIX for Advanced & Expert Users

Compound indirect variable references

Using bash, I'm trying to read a .properties file (name=value pairs), assigning an indirect variable reference for each line in the file. The trick is that a property's value string may contain the name of a property that occurred earlier in the file, and I want the name of the 1st property to... (5 Replies)
Discussion started by: tkrussel
5 Replies

8. AIX

AIX References?

Would like to know where or what is available to quickly develope my AIX skills. Training budget limited.. Thanks and have a great day! (1 Reply)
Discussion started by: lmwical
1 Replies

9. UNIX for Dummies Questions & Answers

IRIX books, manuals, references...

Does anyone out there know of ANY specific books pertaining to SGI's flavor of Unix - IRIX? I have been in contact with SGI directly and they have not supplied me with any usable reference material or manuals. I realize man pages are a good source for info, but I need to go a little deeper... (6 Replies)
Discussion started by: lozinit
6 Replies
Login or Register to Ask a Question