constant variable in perl

Discussion in 'Perl Misc' started by Alexander Jack, Aug 7, 2009.

  1. How to declare and use a constant variable in Perl ,
    please help me out ,

    thanx in Advance .
     
    Alexander Jack, Aug 7, 2009
    #1
    1. Advertising

  2. Alexander Jack

    News123 Guest

    Hi ALex,

    As so often.

    Perldoc would be your friend.
    or if you prefer web front ends
    (go to http://perldoc.perl.org/ and enter constant in the search field)


    One Alexander Jack wrote:
    > How to declare and use a constant variable in Perl ,
    > please help me out ,
    >


    There's multiple option:

    the one directly documented in the perl onine documentation can be seen with


    perldoc constant

    > =head1 NAME
    >
    > constant - Perl pragma to declare constants
    >
    > =head1 SYNOPSIS
    >
    > use constant PI => 4 * atan2(1, 1);
    > use constant DEBUG => 0;
    >
    > print "Pi equals ", PI, "...\n" if DEBUG;
     
    News123, Aug 7, 2009
    #2
    1. Advertising

  3. On Aug 7, 12:00 pm, News123 <> wrote:
    > Hi ALex,
    >
    > As so often.
    >
    > Perldoc would be your friend.
    > or if you prefer web front ends
    > (go tohttp://perldoc.perl.org/and enter constant in the search field)
    >
    > One Alexander Jack wrote:
    > > How to declare and use a constant variable in Perl ,
    > > please help me out ,

    >
    > There's multiple option:
    >
    > the one directly documented in the perl onine documentation can be seen with
    >
    > perldoc constant
    >
    > > =head1 NAME

    >
    > > constant - Perl pragma to declare constants

    >
    > > =head1 SYNOPSIS

    >
    > > use constant PI => 4 * atan2(1, 1);
    > > use constant DEBUG => 0;

    >
    > > print "Pi equals ", PI, "...\n" if DEBUG;


    Thank you news
     
    Alexander Jack, Aug 7, 2009
    #3
  4. On Aug 7, 11:39 am, Ben Morrow <> wrote:
    > Quoth Alexander Jack <>:
    >
    > > How to declare and use a constant variable in Perl ,
    > > please help me out ,

    >
    > use constant NAME => "value";
    >
    > or
    >
    > use Readonly;
    > Readonly my $var = "value";
    >
    > depending on which you prefer.
    >
    > Ben


    Don't think that I am too greedy , but I want to know what is the
    difference between constant and Readonly in perl .
     
    Alexander Jack, Aug 7, 2009
    #4
  5. On Aug 7, 11:39 am, Ben Morrow <> wrote:
    > Quoth Alexander Jack <>:
    >
    > > How to declare and use a constant variable in Perl ,
    > > please help me out ,

    >
    > use constant NAME => "value";
    >
    > or
    >
    > use Readonly;
    > Readonly my $var = "value";
    >
    > depending on which you prefer.
    >
    > Ben


    I didn't find any pragma like Readonly in my system , Can you tell me
    how to get this...
     
    Alexander Jack, Aug 7, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher M. Lusardi
    Replies:
    1
    Views:
    4,096
  2. Martin Magnusson
    Replies:
    2
    Views:
    510
    John Harrison
    Oct 8, 2004
  3. Afshar Mohebbi
    Replies:
    5
    Views:
    6,073
    Afshar Mohebbi
    Jun 26, 2006
  4. Immortal Nephi
    Replies:
    3
    Views:
    588
    Technical
    Aug 18, 2009
  5. zl2k
    Replies:
    3
    Views:
    292
Loading...

Share This Page