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

आपका पहला Perl Program

एक Perl program एक text file है जो आप perl command को देते हैं।

आपका पहला Perl Program

अपना code एक ऐसी file में save करें जो .pl से खत्म हो, फिर इसे perl filename.pl से चलाएँ। हर statement एक semicolon से खत्म होता है, और print screen पर text भेजता है। एक string के अंत में special sequence \n एक नई line शुरू करती है।

Note: Unix-like systems पर आप #!/usr/bin/perl जैसी पहली line add कर सकते हैं और file को executable बना सकते हैं, ताकि आप इसे perl type किए बिना चला सकें।

उदाहरण: Your first Perl program

perl
#!/usr/bin/perl
use strict;
use warnings;

print "Hello, World!\n";
print "My first Perl program\n";
print "Script name: $0\n";

# Output:
# Hello, World!
# My first Perl program
# Script name: script.pl
{# 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. एक statement के अंत में semicolon भूल जाना
  2. \n भूल जाना ताकि सारा output एक line में आ जाए
  3. जब script executable न हो perl command के बिना इसे चलाना
चैप्टर सारांश
  • Scripts को .pl files की तरह save करें
  • इन्हें perl script.pl से चलाएँ
  • Statements semicolons से खत्म होते हैं
  • print text लिखता है और \n एक line खत्म करता है
🔒

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.