http://qs1969.pair.com?node_id=591214


in reply to Adding Default Values [for BEGINNERS]

$file0 is not blank. It contains \n. Just use chomp to remove the newline before checking if the variable is "empty".

my $file = <STDIN>; chomp($file); $file ||= "somelist";

The above will also use the default if 0 (zero) is entered. The following avoids that problem:

my $file = <STDIN>; chomp($file); $file = "somelist" if not length $file;

By the way, you really, really, really should use use strict; and use warnings;.