richz has asked for the wisdom of the Perl Monks concerning the following question:

I'm reading someone else's code and came across this code:
sub usage() { print <<"END_USAGE"; Usage: -f <file> END_USAGE }
This is used in conjunction with GetOpt::Long so I'm wondering how that print syntax works. Is it something specific to GetOpt or what? I couldn't find any mention of it in the perldoc page for GetOpt::Long. Thanks.

Replies are listed 'Best First'.
Re: Please explain: print <<"END_USAGE";
by Fletch (Bishop) on Feb 15, 2008 at 18:01 UTC

    Because it's a here-doc which has nothing to do with Getopt::Long specifically. Search for "<<EOF" in perlop in the section on quote-like operators, but basically it means create a string from everything following this line up to the next line beginning with the terminator string given after the "<<".

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Thanks, it was hard finding help searching for print <<, but now I know where to look!
        Cause it has nothing to do with print.
        my ($var1, $var2) = (<<'EOI', <<'EOI'); ... EOI ... EOI