in reply to Meaning of 'use constant USAGEMSG = > ...'

Hi please can any one explain me what does the following code does , what is the use of USAGEMSG or USAGE
use constant USAGEMSG => <<USAGE; Usage:ftp.pl [options] host:/path/to/directory
Having a 'Seekers of Perl Wisdom' IMHO is not an excuse for not trying to search for obvious info by oneself. In particular since you see use constant you should really check perldoc constant. Then you would find out that 'USAGEMSG' is a constant (a sub, really, you may have done
sub USAGEMSG () { ... }
instead).

'USAGE' is "nothing but" a "tag", but this is basic perl syntax. Please check perldoc perlop and look for "here-document".

Replies are listed 'Best First'.
Re^2: Meaning of 'use constant USAGEMSG = > ...'
by Mutant (Priest) on Feb 08, 2005 at 17:03 UTC
    Having a 'Seekers of Perl Wisdom' IMHO is not an excuse for not trying to search for obvious info by oneself.

    I disagree to some extent. While it would be nice if people spent a bit more time searching documentation for the answer, some beginners may not even know perldoc exists, or that answers to these questions could be found there. Perl is so diverse that a piece of code that looks 'simple' and 'fundamental' to you may seem completely foreign to someone else.

    You can get a long way in Perl without using (or possibly even knowing about) constants and here docs.

      I disagree to some extent. While it would be nice if people spent a bit more time searching documentation for the answer, some beginners may not even know perldoc exists, or that answers to these questions could be found there. Perl is so diverse that a piece of code that looks 'simple' and 'fundamental' to you may seem completely foreign to someone else.
      And in turn I partly agree with your disagreement! To reply to your cmt: in fact I think (and I heartily hope!) that I have kindly pointed him to the correct entry points in the documentation, underlining clearly enough that most of what he may need to know is already there...
Re^2: Meaning of 'use constant USAGEMSG = > ...'
by herveus (Prior) on Feb 08, 2005 at 17:34 UTC
    Howdy!

    While RTFM can be a productive activity, 'perldoc constant' would have only gotten half the answer. If you aren't familiar with here-documents, you might not even recognize the construct, let along have the vocabulary. Finding here-document fu in perldoc is not as straightforward as it might be as well.

    In short, I don't think the question at hand is necessarily as obvious as you make it out to be.

    yours,
    Michael
      Finding here-document fu in perldoc is not as straightforward as it might be as well.
      I must admit this is true. In some sense it is true of all quote-like operators...
      In short, I don't think the question at hand is necessarily as obvious as you make it out to be.
      I think you're right, in fact I didn't give him a completely RTFM kinda answer, but I explained which two constructs were involved in that statement and pointed to the possibly not so obvious entry points in the docs for both.