in reply to puts vs say

The rationale is simple:
print "$hello\n";
say $hello;
Six less keystrokes!

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: puts vs say
by dgaramond2 (Monk) on Mar 04, 2009 at 12:40 UTC

    But puts() saves even more keystrokes. *Aside* from the above case, there's also the (quite common):

    print $hello, ($hello =~ /\n$/ ? "" : "\n");
    
    puts $hello;

    Anyway, I don't want to start a flamewar here. Obviously Larry et al didn't think puts-like behaviour attractive enough to make say() behave the same. Oh well. We can always define puts() ourselves.

Re^2: puts vs say
by Bod (Parson) on Feb 13, 2021 at 00:49 UTC
    Six less keystrokes!

    Using the 18 keystrokes in use feature 'say'; somewhat negates the saving really...

    I never think to use say - it seems as easy to use print and add a newline myself if I need one!

      You never have to type boilerplate if you use a template for new scripts. Command line is even better–

      perl -E 'say "What you will."'
        > type boilerplate if you use a template for new scripts

        even w/o template, overhead doesn't become bigger.

        use v5.12; makes the use strict; line obsolete

        c:\Strawberry>perl -e"use v5.12; say 'works'" works c:\Strawberry>perl -e"use v5.12; say $x" Global symbol "$x" requires explicit package name (did you forget to d +eclare "my $x"?) at -e line 1. Execution of -e aborted due to compilation errors. c:\Strawberry>

        update

        So it's actually one character less.

        Not sure why they didn't include "warnings" too.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery