CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Storing a line



May 15, 2001, 12:51 PM

Post #1 of 3 (1850 views)
Storing a line Can't Post

open(MAIN, ">$index_file") || die "Can't open MAIN: $index_file\n";
foreach $line (@main) {
if ($line =~ //) {
print NUM "$new_num";


May 15, 2001, 1:43 PM

Post #2 of 3 (1848 views)
Re: Storing a line [In reply to] Can't Post

umm is this a question or a statement?

Anyways if it is a question i found some errors in it...

open(MAIN, ">$index_file") || die "Can't open MAIN: $index_file\n";
foreach $line (@main) {
if ($line =~ //) {
print MAIN "$new_num";

Corrections are in red. You used two different filehandles when you only opened one filehandle.

Otherwise i have no idea what in the world you are talking about

People Engrossed by a Reliable Language


May 15, 2001, 2:32 PM

Post #3 of 3 (1846 views)
huh? [In reply to] Can't Post

wha wha what is this? some practical joke, right? well, for one, this program will not actually start.

>>open(MAIN, ">$index_file") || die "Can't open MAIN: $index_file\n";
why do you need ">$index_file"?? to overwrite everything in there?? smart

>>foreach $line (@main) {
say what now? can I ask silly question, what in the world is @main?? Had thought of assigning file to an array first ever crossed your mind? I mean something like @main=<MAIN>; 'coz in your version @main is undefiend

>>if ($line =~ //) {
Now this one is just killing me. "IF LINE EXIST DO THAT"...what kind of statement is that? it's like to do someting to every single line in the file.

>>print NUM "$new_num"; }
print WHERE???? pro_4 is right, you don't even have this opened

again, close what? you never opened it...

Generally speaking, I never thought it is possible to make that many mistakes in so little program :)))
Anyway, would you please tell us why would you want anything like that


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives