Hi Colin It looks like your file contains two blank lines to start with. The data from your hash should be appended to it after the run. Try dumping your array with:
print "<<$_>>\n" foreach @participants; then you can see where each record starts and ends. HTH, Rob "Colin Johnstone" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Gidday all, > > Im having trouble reading and writing to this file, It's probably just > something silly. > Heres my code. I have set the permissions on the file to 775. > > <code> > my ($filename); > > $filename = > "/home/bdweb8083m/johnstonefamily.com/cgi-bin/hp_data/participants.txt"; > > if( -e $filename ){ > print "Yeah - File exists<br>"; > } > > my @participants; > > open IN, "<$filename" || die( "Cannot Open: $!" ); > while( my $line = <IN> ){ > chomp $line; > push( @participants, $line ); > } > close IN; > > print "Num elements array participants = ".scalar( @participants )."<br>"; > > my $outString; > $outString = ""; > $outString .= $fields{'SelectCity'} . ","; > $outString .= $fields{'Workshop1'} . ","; > $outString .= $fields{'Workshop2'} . ","; > $outString .= $fields{'Salutation'} . ","; > $outString .= $fields{'FirstName'} . ","; > $outString .= $fields{'LastName'} . ","; > $outString .= $fields{'Title'} . ","; > $outString .= $fields{'CompanyName'} . ","; > $outString .= $fields{'CompanyAddress'} . ","; > $outString .= $fields{'Suburb'} . ","; > $outString .= $fields{'State'} . ","; > $outString .= $fields{'PostCode'} . ","; > $outString .= $fields{'PhoneNumber'} . ","; > $outString .= $fields{'Mobile'} . ","; > $outString .= $fields{'EmailAddress'}; > > print "Out string =$outString<br>"; > > push( @participants, $outString ); > > print "Num elements array participants = ".scalar( @participants )."<br>"; > > print "@participants\n\n"; > > open( OUTFILE, '>$filename') or die( "Cannot open file: $!"); > while( @participants ){ > my $val = shift( @participants ); > print( OUTFILE "$val\n" ); > } > close( OUTFILE ) or die( "Cannot close file: $!"); > </code> > > Here is a sample of the output I get on the screen > > <output> > Yeah - File exists > Num elements array participants = 2 > Out string =Melbourne,Next Generation Alpha Servers - Simplifying Cluster > Management with Single System Image,HP Single Server Strategy - Itanium is > real,vcxzvcxzv,vcxzvcxz,vxzcvcxz,zxcvcxzvxc,vzcxvzcx,xczvcxzv,vzxcvzcxv,vcxv > zcxv,vzxcvzcxv,vzcxvxzcv,vzxcvzxcvz,[EMAIL PROTECTED] > Num elements array participants = 3 > Melbourne,Next Generation Alpha Servers - Simplifying Cluster Management > with Single System Image,HP Single Server Strategy - Itanium is > real,vcxzvcxzv,vcxzvcxz,vxzcvcxz,zxcvcxzvxc,vzcxvzcx,xczvcxzv,vzxcvzcxv,vcxv > zcxv,vzxcvzcxv,vzcxvxzcv,vzxcvzxcvz,[EMAIL PROTECTED] > </output> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]