Ask a Question related to PERL Beginners, Design and Development.
-
Harshal borade #1
my in the perl syntax
Well I am very new to Perl. I have read Oreily's
Camel book, but haven't found any thing about
my that is used in any of the code.
e.g
my $var
What is my supposed to be over here?
__________________________________________________ ______________________
Yahoo! India Mobile: Download the latest polyphonic ringtones.
Go to [url]http://in.mobile.yahoo.com[/url]
Harshal borade Guest
-
Perl Syntax Highlighting
Greetings fellow members, I am in search for Perl/CGI definitions for use within CodeColoring.xml and Colors.xml. Perl syntax highlighting would... -
[ANNOUNCE] Apache::Syntax::Highlight::Perl 1.00
The uploaded file Apache-Syntax-Highlight-Perl-1.00.tar.gz has entered CPAN as file:... -
How to Implement a BNF syntax in perl?
Hi, I have a long BNF (Backus-naur form) for parsing a protocol message. Suppose I want to implement a BNF like this Response = Status-line... -
Simple Perl code/syntax question
> Hallo everyone and thank you for your previous help Well there is the FAQ about case statements: perldoc -q 'switch or case' In your case... -
Perl Math Syntax
Hello peoples, Needs some help getting a ... well ... pretty basic math script working but the solution eludes me .... I have a text file called... -
Robert #2
Re: my in the perl syntax
Harshal borade wrote:
I am new as well and by lurking in the groups I can tell you with great> Well I am very new to Perl. I have read Oreily's
> Camel book, but haven't found any thing about
> my that is used in any of the code.
>
> e.g
> my $var
>
> What is my supposed to be over here?
certainty to use "perldoc". It is wonderful. In your case you would type
the following: perldoc -f my
perldoc -f my
my EXPR
my TYPE EXPR
my EXPR : ATTRS
my TYPE EXPR : ATTRS
A "my" declares the listed variables to be local (lexically) to
the enclosing block, file, or "eval". If more than one value is
listed, the list must be placed in parentheses.
The exact semantics and interface of TYPE and ATTRS are still
evolving. TYPE is currently bound to the use of "fields" pragma,
and attributes are handled using the "attributes" pragma, or
starting from Perl 5.8.0 also via the "Attribute::Handlers"
module. See "Private Variables via my()" in perlsub for details,
and fields, attributes, and Attribute::Handlers.
HTH
Robert
Robert Guest
-
Jan Eden #3
Re: my in the perl syntax
There is definitely an explanation in the Camel (Chapter 4.8.1, Scoped variable declarations).
my $var declares a lexical variable, i.e. a variable with limited scope (where the scope is limited by an enclosing block, such as a subroutine, a conditional loop etc.).
HTH,
Jan
Harshal Borade wrote:
-->Well I am very new to Perl. I have read Oreily's
>Camel book, but haven't found any thing about
>my that is used in any of the code.
>
>e.g
>my $var
>
>What is my supposed to be over here?
Common sense is what tells you that the world is flat.
Jan Eden Guest
-
Gabor Urban #4
Re: my in the perl syntax
From: Robert <bobx@linuxmail.org>
Subject: Re: my in the perl syntax
Date: Fri, 06 Feb 2004 07:57:39 -0500
Hi the best to understand is like in the next code snippet:
sub SubA
{
my $var1 ;
}
In this function the var $var will be local and so can not be accessed
from outside. (Or if you have a global variable $var, it's actual
value will be totally different.)
Gurus will explain better..
> Harshal borade wrote:
>> I am new as well and by lurking in the groups I can tell you with great> > Well I am very new to Perl. I have read Oreily's
> > Camel book, but haven't found any thing about
> > my that is used in any of the code.
> >
> > e.g
> > my $var
> >
> > What is my supposed to be over here?
> certainty to use "perldoc". It is wonderful. In your case you would type
> the following: perldoc -f my
>
> perldoc -f my
>
> my EXPR
> my TYPE EXPR
> my EXPR : ATTRS
> my TYPE EXPR : ATTRS
> A "my" declares the listed variables to be local (lexically) to
> the enclosing block, file, or "eval". If more than one value is
> listed, the list must be placed in parentheses.
>
> The exact semantics and interface of TYPE and ATTRS are still
> evolving. TYPE is currently bound to the use of "fields" pragma,
> and attributes are handled using the "attributes" pragma, or
> starting from Perl 5.8.0 also via the "Attribute::Handlers"
> module. See "Private Variables via my()" in perlsub for details,
> and fields, attributes, and Attribute::Handlers.
>
> HTH
>
> Robert
>
> --
> To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
> For additional commands, e-mail: [email]beginners-help@perl.org[/email]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>Gabor Urban Guest
-
Wiggins D Anconia #5
Re: my in the perl syntax
> Well I am very new to Perl. I have read Oreily's
Since the Camel is a reference more than a tutorial and because it is> Camel book, but haven't found any thing about
> my that is used in any of the code.
>
> e.g
> my $var
>
> What is my supposed to be over here?
>
>
already a pretty thick tome many of the examples in it will not include
'my' as that is really a best practice not an absolute necessity to
demonstrating code in a reference setting, so to make example code
shorter and easier to understand. Having said that, it *is* a best
practice and you *should* be doing,
use strict;
use warnings;
In all of your code, which will necessitate the use of 'my' very often.
[url]http://perl.plover.com/FAQs/Namespaces.html[/url]
Is an excellent article on scoping in Perl, and should clear things up
with regards to 'my'.... come back if you have further questions,
[url]http://danconia.org[/url]
Wiggins D Anconia Guest
-
John W. Krahn #6
Re: my in the perl syntax
Harshal borade wrote:
Perhaps this article will help you understand:>
> Well I am very new to Perl. I have read Oreily's
> Camel book, but haven't found any thing about
> my that is used in any of the code.
>
> e.g
> my $var
>
> What is my supposed to be over here?
[url]http://perl.plover.com/FAQs/Namespaces.html[/url]
John
--
use Perl;
program
fulfillment
John W. Krahn Guest
-
Harshal borade #7
Re: my in the perl syntax
I certainly appreciate the pain you have gone through
in writing that mail, but I haven't understood about
"perldoc -f my". I went through a book , How to Perl
5, last night. And it says that every variable
declared gets into main, a default package. To avoid
the namespace pollution it says that, its a good way
to hide names from collision.
Tell me if I have misunderstood it.
Well infact if u could send me a a small code which
uses the perl -f doc or the later thing mentioned by
you, would help me a lot.
--- Gabor Urban <gabaux@rubin.hu> wrote: > From:
Robert <bobx@linuxmail.org>__________________________________________________ ______________________> Subject: Re: my in the perl syntax
> Date: Fri, 06 Feb 2004 07:57:39 -0500
>
> Hi the best to understand is like in the next code
> snippet:
>
> sub SubA
> {
> my $var1 ;
>
> }
>
> In this function the var $var will be local and so
> can not be accessed
> from outside. (Or if you have a global variable
> $var, it's actual
> value will be totally different.)
>
> Gurus will explain better..
>> Oreily's> > Harshal borade wrote:
> >> > > Well I am very new to Perl. I have read> can tell you with great> > I am new as well and by lurking in the groups I> > > Camel book, but haven't found any thing about
> > > my that is used in any of the code.
> > >
> > > e.g
> > > my $var
> > >
> > > What is my supposed to be over here?> your case you would type> > certainty to use "perldoc". It is wonderful. In> be local (lexically) to> > the following: perldoc -f my
> >
> > perldoc -f my
> >
> > my EXPR
> > my TYPE EXPR
> > my EXPR : ATTRS
> > my TYPE EXPR : ATTRS
> > A "my" declares the listed variables to> more than one value is> > the enclosing block, file, or "eval". If> parentheses.> > listed, the list must be placed in> and ATTRS are still> >
> > The exact semantics and interface of TYPE> use of "fields" pragma,> > evolving. TYPE is currently bound to the> "attributes" pragma, or> > and attributes are handled using the> "Attribute::Handlers"> > starting from Perl 5.8.0 also via the> in perlsub for details,> > module. See "Private Variables via my()"> Attribute::Handlers.> > and fields, attributes, and> [email]beginners-unsubscribe@perl.org[/email]> >
> > HTH
> >
> > Robert
> >
> > --
> > To unsubscribe, e-mail:> [email]beginners-help@perl.org[/email]> > For additional commands, e-mail:> <http://learn.perl.org/first-response>> > <http://learn.perl.org/>
>
> --
> To unsubscribe, e-mail:
> [email]beginners-unsubscribe@perl.org[/email]
> For additional commands, e-mail:
> [email]beginners-help@perl.org[/email]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
>
>
Yahoo! India Education Special: Study in the UK now.
Go to [url]http://in.specials.yahoo.com/index1.html[/url]
Harshal borade Guest
-
Jan Eden #8
Re: my in the perl syntax
Harshal Borade wrote:
"perldoc -f my" refers to Perl's built-in documentation. You can enter thiscommand at your prompt to get a description of my ("perldoc -f grep" givesa description of grep etc).>I certainly appreciate the pain you have gone through
>in writing that mail, but I haven't understood about
>"perldoc -f my". I went through a book , How to Perl
>5, last night. And it says that every variable
>declared gets into main, a default package. To avoid
>the namespace pollution it says that, its a good way
>to hide names from collision.
>Tell me if I have misunderstood it.
>Well infact if u could send me a a small code which
>uses the perl -f doc or the later thing mentioned by
>you, would help me a lot.
But you already got several descriptions (as well as the output of perldoc -f my on this list), including mine.
I do not see your problem.
- Jan
--
If all else fails read the instructions. - Donald Knuth
Jan Eden Guest
-
R. Joseph Newton #9
Re: my in the perl syntax
Harshal Borade wrote:
It is meant to be entered exactly as written on the command-line. It is the> I certainly appreciate the pain you have gone through
> in writing that mail, but I haven't understood about
> "perldoc -f my".
same way we call Perl programs:is a call to the perldoc program or [in Windows, batch file/program]. This>perldoc -f my
program searches for information
relating to the keywords offered. Since the call in question used the -f
switch, it searches for information
about built-in Perl functions by the name "my". Then it displays the
information found in formatted text.
Use perldoc first to find out about perl keyword, functions, general
question, modules, etc.
There is no way to tell, really. It sounds like you are almost quoting the> I went through a book , How to Perl
> 5, last night. And it says that every variable
> declared gets into main, a default package. To avoid
> the namespace pollution it says that, its a good way
> to hide names from collision.
> Tell me if I have misunderstood it.
text. Try restating this in your
own words. What you say here does seem to make sense, but what does it mean
to you? Can you
see the connection between scoping and the process of breaking programs into
manageable chunks?
As you work with these concepts, we will be happy to point you along the
way.
No. This is something you have to get in the habit of doing for yourself.>
> Well infact if u could send me a a small code which
> uses the perl -f doc
You should get used to
working at the command-line. It will be critical as you start writing and
testing your code.
Joseph
R. Joseph Newton Guest



Reply With Quote

