[advanced search]
Results from the most recent live auction are here.
20 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Domain Name Industry Newsletter
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 12-03-2003, 09:39 AM   · #1
totalservers
NamePros Member
 
Location: UK
Trader Rating: (0)
Join Date: Nov 2003
Posts: 53
NP$: 0.00 (Donate)
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.

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!!


Please register or log-in into NamePros to hide ads
totalservers is offline   Reply With Quote
Old 12-03-2003, 09:57 AM   · #2
adam_uk
Senior Member
 
Trader Rating: (17)
Join Date: May 2003
Posts: 2,211
NP$: 6170.25 (Donate)
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   Reply With Quote
Old 12-09-2003, 04:37 PM   · #3
deadserious
Senior Member
 
Trader Rating: (13)
Join Date: Aug 2002
Posts: 1,300
NP$: 2.85 (Donate)
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   Reply With Quote
Old 12-10-2003, 12:49 PM   · #4
totalservers
NamePros Member
 
Location: UK
Trader Rating: (0)
Join Date: Nov 2003
Posts: 53
NP$: 0.00 (Donate)
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   Reply With Quote
Old 12-11-2003, 05:09 AM   · #5
totalservers
NamePros Member
 
Location: UK
Trader Rating: (0)
Join Date: Nov 2003
Posts: 53
NP$: 0.00 (Donate)
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   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Hunting Moon RealTechNetwork Proof is in the Parking
Advertise your business at NamePros
All times are GMT -7. The time now is 10:05 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0