← Back to Perl Course | Chapter 1: Introduction | Lesson 4 of 7

Comments और POD

Comments मनुष्यों के लिए notes हैं जिन्हें Perl ignore करता है।

In this page:

  1. Comments और POD

Comments और POD

एक hash sign # एक comment शुरू करता है जो line के अंत तक चलता है। Perl में कोई block comment syntax नहीं है, लेकिन POD (Plain Old Documentation) blocks लंबे text के लिए इस्तेमाल हो सकते हैं: =pod या =begin comment जैसी एक line से शुरू होकर और =cut से खत्म होने वाला एक block interpreter skip कर देता है। POD Perl modules document करने का standard तरीका भी है।

Note: एक quoted string के अंदर एक # बस एक character है, comment नहीं।

उदाहरण: Comments and POD

perl
use strict;
use warnings;

# This is a single-line comment
print "Step one\n";    # comment after code

=begin comment

This whole block is ignored by Perl,
so it works like a multi-line comment.

=end comment

=cut

print "Step two # not a comment\n";

# Output:
# Step one
# Step two # not a comment
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह उम्मीद करना कि C-style /* */ block comments काम करेंगे
  2. एक POD block को खत्म करने वाली =cut line भूल जाना
  3. =pod जैसी POD directives को एक line की शुरुआत के अलावा कहीं और शुरू करना
चैप्टर सारांश
  • # एक comment शुरू करता है
  • POD blocks कई lines hide कर सकते हैं
  • एक POD block =cut से खत्म होता है
  • एक string के अंदर एक # comment नहीं है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.