in reply to Printing an array

It fails at the print command because you have not declared @data (and you haven't called the subroutines, either).

#!/usr/bin/perl -w use strict; my @data = readdata(); print "@data"; writedata(@data); # # Subroutine for reading prev.txt into an array # sub readdata { open (PH, "prev.txt") || die "Cannot open prev.txt: $!"; my(@DATA)=<PH>; chomp @DATA; close (PH); return(@DATA); } # # Subroutine for writing array into prev.txt # sub writedata { my(@DATA)=@_; open (PH, ">prev.txt") || die "Cannot open prev.txt: $!"; foreach(@DATA) { print PH "$_\n"; } close (PH); }

Of course, what this does is read the data in, chomp it, and then write it back out with newlines to the same file. Your file will likely remain unchanged. Is that what you wanted? I'm assuming this was simply a test.

Cheers,
Ovid

New address of my CGI Course.