Lesson 06 of 55
8 mins readPython Standard I/O: print, say & chomp
In Plain English
Use `print` for flexible stream output, `say` (from `use feature "say";`) to append an automatic newline, and `chomp` to cleanly strip trailing record separators.
Deep Dive: How It Works
say Function: Equivalent to print with an automatic trailing newline `\n`.
STDIN: Standard input filehandle reading lines via `<STDIN>`.
chomp Function: Removes trailing `\n` (or whatever `$/` is set to) from a scalar in-place.
Multiple Arguments: `print "A", "B", "C\n"` prints items consecutively without separators.
Core Rules to Remember

say Feature: Enable with `use feature "say";` or `use v5.10;` for cleaner code.

chomp In-Place: `chomp($input)` mutates the variable in-place by removing the ending newline.
Live Interactive Example
Hit Run Code to see it liveUsing say and chomp Simulation
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
Output Console
Click "Run Code" to view the rendered output.
How it works: chomp removed the newline so the brackets wrap directly around the text.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Use say and chomp
Enable `use feature "say";`
Declare `my $raw = "Perl Pipeline\n";` and `chomp($raw);`
Output it using `say "Processed: $raw";`
1
2
3
4
5
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.