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: Beginner:
declaration or what?

 



Tehmina Iqbal
Novice

Mar 22, 2011, 6:04 AM

Post #1 of 4 (1776 views)
declaration or what? Can't Post

hi,

i am a beginner in perl and i have to implement VSM in perl. i got some code while googling but as i am new, i cannot understand the meaning of simple statements for example i dont know what the following stataement is doing:

my (%keywordNums, $numKeywords, @doc, @docVector);

somebody plz help


Karazam
User

Mar 22, 2011, 8:12 AM

Post #2 of 4 (1773 views)
Re: [Tehmina Iqbal] declaration or what? [In reply to] Can't Post


Quote
my creates lexically scoped variables [..] The variables are scoped to the block [..] in which they are defined.

http://perldoc.perl.org/perlintro.html#Variable-scoping


Xploit
Novice

Mar 23, 2011, 12:03 PM

Post #3 of 4 (1763 views)
Re: [Tehmina Iqbal] declaration or what? [In reply to] Can't Post

to declare a variable in perl one uses the "my" command for example:

my $scalar;
my @array;
my %hash;

this will declare each of these variables.


my (%keywordNums, $numKeywords, @doc, @docVector);

is simply declaring all the variables in 1 simple line. rather than spreading them out on seperate lines like my example.

does this answer ur question?
cheers.

In Reply To



(This post was edited by Xploit on Mar 23, 2011, 12:04 PM)


Tehmina Iqbal
Novice

Mar 24, 2011, 9:06 AM

Post #4 of 4 (1752 views)
Re: [Tehmina Iqbal] declaration or what? [In reply to] Can't Post

thats exactly what i was trying to know... thanks alot

 
 


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

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