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

print और say

print text को exactly दिए गए रूप में लिखता है, और say वही करता है लेकिन एक newline add करता है।

In this page:

  1. print और say

print और say

print values की एक list बिना separator और बिना automatic newline के output करता है। say function, जो use feature say या use v5.10 से enable होता है, आपके लिए एक newline append करता है। दोनों STDERR जैसे एक filehandle में print कर सकते हैं जब आप handle को पहले रखें, इसके बाद कोई comma नहीं।

Note: print items के बीच separator बदलने के लिए $, set करें और हर print के अंत में कुछ add करने के लिए $\।

उदाहरण: print and say

perl
use strict;
use warnings;
use feature 'say';

print "one", "two", "three";
print "\n";
say "hello";
say "a", "b", "c";
{
    local $, = "-";
    say "x", "y", "z";
}
print STDOUT "to STDOUT\n";

# Output:
# onetwothree
# hello
# abc
# x-y-z
# to STDOUT
{# 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. यह भूल जाना कि print कोई newline add नहीं करता
  2. feature enable किए बिना say call करना
  3. print STDERR, "text" में filehandle के बाद एक comma लगाना
चैप्टर सारांश
  • print कोई newline add नहीं करता
  • say एक newline add करता है
  • say को use feature say चाहिए
  • एक filehandle के बाद कोई comma नहीं
🔒

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.