Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple question 1

Status
Not open for further replies.

PhoenixDown

Programmer
Jul 2, 2001
279
CA
For my script control panel, I'm making the guestbook entries settings part and I'm having a little problem.

On my data file It prints a new line at the top. It looks like:

Code:
"
1|Calvin|<A HREF=&quot;mailto:calvin@puremadnezz.com&quot;>|<A HREF=&quot;[URL unfurl="true"]http://www.puremadnezz.com/&quot;>||12345678|xcloud0|xcloud2000x@hotmail.com|xcloud2000x|||||Test|06-22-2001|00:47:45|216.130.72.133|c-72-133-res1.mts.net&quot;[/URL]

To call all the entries I use:

Code:
open(DATA,&quot;<$vars_gen{'CGIPath'}/variables/vars_entries.cgi&quot;) or die (&quot;Unable to open guestbook entry file.&quot;);
@line = <DATA>;
close(DATA);
foreach $line (@line) {
 $line =~ s/\n//g;
 ($var1,$var2,$var3,$var4,$var5,$var6,$var7,$var8,$var9,$var10,$var11,$var12,$var13,$var14,$var15,$var16,$var17,$var18) = split(/\|/,$line);
if ( $line =~ //) {
	$line =~ s/\n//g;
} else {
	$line =~ s/\n//g;
}

It converts the new line to table format and I've tried using that if statement to strip it out of there and it's not working.

Here is an image of what it looks like:

gif.gif


Please tell me what I'm doing wronf! Thank you! :) - Go there!
 
Wow, Harvey, you dug up this thread from almost a year ago? You should really start a new thread for a new question. I'd say you should just put all the code for dealing with the line as the body of a conditional, like this:
Code:
open FH, &quot;filename&quot; || die &quot;IO error: $!&quot;;
while(<FH>)
{
	if($_ is good)
	{
		do a bunch of stuff
	}
}
while(<FH>) is really while($_ = <FH>). To read any single line from a file, just set a scalar variable equal to the file handle in pointy brackets, so you could do all this explicitly. ----------------------------------------------------------------------------------
...but I'm just a C man trying to see the light
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top