NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Perl Scripters - Please Help Me!!

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-03-2003, 09:39 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Nov 2003
Location: UK
Posts: 53
totalservers is an unknown quantity at this point
 



Perl Scripters - Please Help Me!!


Are there any genius perl scripters out there?

If there are can you give me some help.....I have no idea how to create perl scripts

My task is as follows:

I need to create a script that will read a text file line by line and print the data into a HTML page and format in appropriate tables.
????: NamePros.com http://www.namepros.com/programming/15734-perl-scripters-please-help-me.html

The script must read each line and store it in a suitable data contruct. The file consist of line of comments beginning with # and lines of data. A valid data line consists of 6 space delimited fields in the following order:

Surname (case insensitive)
Forename (case insensitive)
Subject (case insensitive)
Mark1 (integer between 0 - 100)
Mark2 (integer between 0 - 100)
Mark3 (integer between 0 - 100)

For example a data line would read as follows:
Yates Ian,Bob Science 75 54 45

In other words how do i parse the data from the text file to a properly formatted HTML pages with tables?

Any help will be appreciated!!
totalservers is offline  
Old 12-03-2003, 09:57 AM   #2 (permalink)
Senior Member
Join Date: May 2003
Posts: 2,187
adam_uk is a jewel in the roughadam_uk is a jewel in the roughadam_uk is a jewel in the rough
 


Breast Cancer
to me looks like ud need something similar to phps explode or something like that
adam_uk is offline  
Old 12-09-2003, 04:37 PM   #3 (permalink)
Senior Member
Join Date: Aug 2002
Posts: 1,255
deadserious has a spectacular aura aboutdeadserious has a spectacular aura about
 



Hey just noticed this post. I don't know if you've figured it out yet or not, but you can use a foreach loop and split in Perl http://www.perldoc.com/perl5.8.0/pod/func/split.html to loop through the text file and split the strings into separate variables and then display them. It would make it a whole lot easier if your text file only had one delimiter and didn't contain any other content besides the delimited data.

Here's a little snippet you may be able to use that reads a space delimited text file and then displays html output for each line which is what I think you want to do.

Code:
#!/usr/bin/perl

    $file= "file.txt";
    open(FILE, "$file") || die "Couldn't open file: $file: $! n";
    my @list = <FILE>;
    close (FILE);

    print "Content-type: text/htmlnn";
    print "<html>n";
    print "<body>n";

    foreach my $var (@list) {
    chop($var);
    ($one,$two,$three,$four,$five,$six)=split(/ /, $var);


my $results  = <<__W__D__T__;

$one $two $three $four $five $six<br>

__W__D__T__

print $results;
    }
print "</body>n";
print "</html>n";
deadserious is offline  
Old 12-10-2003, 12:49 PM THREAD STARTER               #4 (permalink)
NamePros Member
Join Date: Nov 2003
Location: UK
Posts: 53
totalservers is an unknown quantity at this point
 



Please could someone have a look at the file attached within the zip file and run the .pe file as a command line thru linux:

perl -w assig1.pe 3a8.txt 6a1.txt

There are errors occuring - if anyone can help me debug it i will be grateful....
Attached Files
File Type: zip assign1.zip (2.0 KB, 0 views)
totalservers is offline  
Old 12-11-2003, 05:09 AM THREAD STARTER               #5 (permalink)
NamePros Member
Join Date: Nov 2003
Location: UK
Posts: 53
totalservers is an unknown quantity at this point
 



i have sorted out the error that was occuring - but now the script does not read the txt file or create and write to the html file....
totalservers is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 05:13 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger