Here:
The bare block is to restrict the dynamic scope of $" and the lexical scope of $fh. That makes $fh be closed as soon as the block is exited. $" contains the element spacer text used for stringifying arrays.#!/usr/bin/perl use warnings; use strict; print "enter the 1st number: \n"; chomp( my $number1 = <STDIN>); print "enter 2nd number: \n"; chomp( my $number2 = <STDIN>); my @list=($number1..$number2); { local $" = "\n"; open my $fh, '>', "$ENV{HOME}/number_list.txt" or die $!; print $fh "@list\n"; }
I've added warnings and strict to help you in future.
After Compline,
Zaxo
In reply to Re: making a list
by Zaxo
in thread making a list and saving results
by surfbass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |