what is difference of decalation and and defination in perl ?

I am assuming in
my $x = 5;

$x is declared with my
and $x is defined with value 5.

Am i getting it right? Thanks! :-)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kim RyanIT ConsultantCommented:
It is just the same as saying
my $x;
$x = 5;

But if you just did
use strict;
$x = 5;

You would get an error saying undeclared variable $x

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
my $x; # x is declared
$x = 5; # x is assigned and has now a defined value
For subroutines:
declaration is saying "this is the name of my routine and these are its inputs"
definition is saying "this is the code to be executed when my routine is called"

so, this is a declaration:
sub count_people(@people);

and this is a definition
sub count_people(@people) { return $#people; }

For variables:
declaration is saying "I am going to use this variable"
assignment is saying "this variable now contains this value"
definition really doesn't apply to variables.
beer9Author Commented:
Thank you :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.