in reply to making a list and saving results
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: making a list
by surfbass (Initiate) on May 29, 2005 at 20:33 UTC | |
by polettix (Vicar) on May 29, 2005 at 23:16 UTC | |
by Zaxo (Archbishop) on May 29, 2005 at 20:38 UTC |