CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Significance of ::_

 



abhinandantn
New User

Aug 13, 2012, 6:13 AM

Post #1 of 5 (4873 views)
Significance of ::_ Can't Post

I came across a code where in they had used a code similar to below

my $code= \@{"::_<$file"};

i understood that the above code reads each line of the $file and references each line as index and we can access each of those line as $code->[10]. what i did not get here is,

what is the use of ::_ here, what is it doing to the input from the file.


BillKSmith
Veteran

Aug 14, 2012, 8:02 AM

Post #2 of 5 (4860 views)
Re: [abhinandantn] Significance of ::_ [In reply to] Can't Post

This does not appear to make sense to me. Perhaps you could post a working subset of the code. I believe that the statement is creating a hard reference to an array which is referenced by a symbolic reference. (The double quotes cause $file to be interpolated into the string. The two colins at the beginning of that string say that the symbolic reference uses the main:: symbol table.) The function of the remaining characters "_>" remains a mystery. The use of 'my' is also strange. It is seldom used without 'use strict;' which would prohibit the use of symbolic reference.
Good Luck,
Bill


abhinandantn
New User

Aug 14, 2012, 8:10 AM

Post #3 of 5 (4858 views)
Re: [BillKSmith] Significance of ::_ [In reply to] Can't Post

I saw this code in Trace.pm present in perl/lib/Devel


BillKSmith
Veteran

Aug 15, 2012, 6:39 AM

Post #4 of 5 (4822 views)
Re: [abhinandantn] Significance of ::_ [In reply to] Can't Post

This code is beyond my skill level. I can safely make a few more observations. Note that the next statement is a print to STDERR. This statement clearly prints the lines described in the DESCRIPTION section of the POD in the same file. From this, we can infer that $code is a reference to an array which contains the source code of the program being debugged, $l is the number of the line being executed and $f contains the name of that program (apparently preceded by '/.'). Also note that "use strict' is not in effect. Both of these observations support my previous comments about a symbolic reference. I still cannot figure out the purpose of the special characters in the symbolic reference.
Good Luck,
Bill


rovf
Veteran

Aug 16, 2012, 12:34 AM

Post #5 of 5 (4799 views)
Re: [BillKSmith] Significance of ::_ [In reply to] Can't Post

Though seldom used, Perl variable names can contain virtually any combination of characters (AFIK, variable names consisting of digits only are forbidden). I guess the purpose is here to create a variable with a very "unlikely" name, i.e. one which likely doesn't exist yet in the main package.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives