Mr Andrej, I think the following code will work for u, open INPUT,"<$ARGV[0]"; while (<INPUT>){ @array=$_; }
foreach $i(@array){ print $i; } Regards Mazhar On 1/23/06, Thomas Bätzler <[EMAIL PROTECTED]> wrote: > > Andrej Kastrin <[EMAIL PROTECTED]> asked: > > I wrote simple script, which have to concatenate multiple > > lines into array and then print each element of tihis array: > > > > open INPUT,"<$ARGV[0]"; > > while ($line=<INPUT>){ > > I would instead suggest you use the <> special filehandle. > This automagically opens any file whose name is passed as > a command line parameter. If @ARGV is empty, it uses STDIN > instead. Very hand indeed! > > I also recommend you use strict and warnings and declare > all of your variables. > > #!/usr/bin/perl -w > use strict; > > my @array; > > while( my $line = <> ){ > push (@array,$line); > } > > If you don't intend to process the lines while you're reading > them you could go ahead and slurp all of them in one go: > > my @array = <>; > > This loop should only run after you're done reading the file. > Otherwise it'll print the parts that have been read already > again and again. > > > foreach $i(@array){ > > print $i; > > } > > HTH, > Thomas > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > >