Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Explain difference between my and local ?

To explain the differences, there would have to similarities.

my creates a lexically scoped variable.

local temporarily saves a package variable, (Upd: array element or hash element. ) The previous value of the variable will be restored when the current scope is exited.

What is the purpose of -w , strict , -T ?

See perlrun for -w and -T.

strict detects errors that aren't detected by default for backwards compatibility reasons.

How do we set environment variables in perl ?

Assign to %ENV. See perlvar.

How to turn on perl warnings? Why is this important ?

use warnings; detects lots of situations which are very likely to have resulted from errors.

What are scalar data and scalar variables ?

"Scalar data" is by no means a formal term. I've never heard it. It probably refers to values that can be assigned to a scalar.

Scalar variables are one of Perl's variable types. They hold one* the following: a string, a signed integer, an unsigned integer, a floating point number, a string (array of 8-bit characters), a string (array of 32/64-bit characters), a reference or a glob.

(Upd: See perldata. )

* — Sometimes more than one, such as both the integer 123 and the string "123". These are optimisations or very special cases called "dualvars".

How do we read command line arguments with perl ?

They are provided in @ARGV. See perlvar.

Why does perl donot have overload functions ?

If there isn't, it's because noone coded a way of doing it.

How we sort a hash by the hash key ?

By definition, hashes can't be sorted. Their keys or values can be sorted.

(Upd: Magic can be used to alter their implementation. See reply for some modules that do this. )

How chomp( ) function and chop differs ?

chomp vs chop.

In reply to Re: My questions: new to perl by ikegami
in thread My questions: new to perl by Monk_perl

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (4)
    As of 2019-12-06 22:42 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (160 votes). Check out past polls.