Gossamer Forum
Home : General : Perl Programming :

Help with Split Function

Quote Reply
Help with Split Function
Hello there,
can anybody tell me how to use the split function so that the file coming in will be displayed into the table.

Script below..

#!/usr/bin/perl

print "Content-type: text/html\n\n";
use CGI qw(:standard -debug);
use strict;

my @records;
open( INFILE, "courses.txt" ) or die( "Error opening courses.txt $!, stopped");
print while(<INFILE>);
#@records = < INFILE >;
close( INFILE );

#foreach my $rec (@records)
# {
# chomp($rec);
# }
#generate HTML acknowledgment

#print "<HTML><HEAD><TITLE>Individual Results</TITLE></HEAD>\n";
#print "<BODY>\n";
#print "<H2>Student Survey Results</H2>\n";
#print "<TABLE><B>\n";
#print "<TR><TD>$name</TD><TD>$program</TD><TD>@courses</TD></TR>\n";
#print "</TABLE><BR>\n";
#print "</B></TABLE>\n";
print "</BODY></HTML>\n";


Thanks in advance
Hawk
Quote Reply
Re: [learningHawk] Help with Split Function In reply to
Hi Hawk,

Supported the "|" char is used as field delim
--
my @records;
open( INFILE, "courses.txt" ) or die( "Error opening courses.txt $!, stopped");
print while(<INFILE>);
@records = < INFILE >;
close( INFILE );

print "<HTML><HEAD><TITLE>Individual Results</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Student Survey Results</H2>\n";
print "<TABLE><B>\n";

foreach my $rec (@records)
{
chomp($rec);
my ($name,$program,@courrses) = slplit('|',$rec);
print "<TR><TD>$name</TD><TD>$program</TD><TD>@courses</TD></TR>\n";
}
#generate HTML acknowledgment


print "</TABLE><BR>\n";
print "</B></TABLE>\n";
print "</BODY></HTML>\n";

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] Help with Split Function In reply to
slplit Wink
Quote Reply
Re: [Paul] Help with Split Function In reply to
Oh, my fault. It should be split. I was on Linux and my monitor so bad so that I did not see the typed in text clearlyTongue

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog