•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 456,597 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,453 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 2448 | Replies: 5 | Solved
![]() |
•
•
Join Date: Sep 2007
Location: Near Arctic Circle
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Hi all,
I am in a situation where I don't know much PERL/CGI, but am frantically reading through the learn Perl/learnCGI in 24 hour books. I just got done programing in dbase for some climatology work and now have to switch gears quickly.
My mission: to read in a (comma-delimited)web file with no extension:
http://147.241.74.132/cgi-bin/model/...fdda/&BIAS=OFF
The problem is, that I want to skip down 14-16 lines to get to the first line of data.
What is the easiest way to read in the lines of data, into an array?
A friend sent me this link: CGISCRIPTER
Is this along the lines of what I need? i will be placing simple (~50)Excel line equations probably into an array as well to perform calculations with the read in values. I will output the answers to a simple HTMl page.
HELP! I don't know much in the realm of CGI scripting, but I have been learning MySQL. I read in one message board that you can use "LOAD DATA INFILE 'C:\Documents and Settings\d~1\Desktop\test.csv' INTO TABLE x; " or something along those lines? Could MySQL be used or is just faster just to have PERL do all the reading, writing and arithmetic?
Anyways, thanks to anyone who would lend a helping thought,
Dave
PS- In the perl books, where should I concentrate my reading? using the "OPEN" command?
I am in a situation where I don't know much PERL/CGI, but am frantically reading through the learn Perl/learnCGI in 24 hour books. I just got done programing in dbase for some climatology work and now have to switch gears quickly.
My mission: to read in a (comma-delimited)web file with no extension:
http://147.241.74.132/cgi-bin/model/...fdda/&BIAS=OFF
The problem is, that I want to skip down 14-16 lines to get to the first line of data.
What is the easiest way to read in the lines of data, into an array?
A friend sent me this link: CGISCRIPTER
Is this along the lines of what I need? i will be placing simple (~50)Excel line equations probably into an array as well to perform calculations with the read in values. I will output the answers to a simple HTMl page.
HELP! I don't know much in the realm of CGI scripting, but I have been learning MySQL. I read in one message board that you can use "LOAD DATA INFILE 'C:\Documents and Settings\d~1\Desktop\test.csv' INTO TABLE x; " or something along those lines? Could MySQL be used or is just faster just to have PERL do all the reading, writing and arithmetic?
Anyways, thanks to anyone who would lend a helping thought,
Dave
PS- In the perl books, where should I concentrate my reading? using the "OPEN" command?
You can certainly use the open() command to read a file, any file, as long as your script has permission to open the file. We will assume it does.
There are perl modules for reading CSV files too:
http://search.cpan.org/~hmbrand/Text...0.31/CSV_XS.pm
This gets into the "you need to install the module" discussion though. But if you can tackle the installation problem the above module works well.
You may very well be able to use MySQL but you need to ask on the MySQL forum.
There are perl modules for reading CSV files too:
http://search.cpan.org/~hmbrand/Text...0.31/CSV_XS.pm
This gets into the "you need to install the module" discussion though. But if you can tackle the installation problem the above module works well.
You may very well be able to use MySQL but you need to ask on the MySQL forum.
•
•
Join Date: Sep 2007
Location: Near Arctic Circle
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation:
Rep Power: 2
Solved Threads: 20
•
•
•
•
Hi all,
I am in a situation where I don't know much PERL/CGI, but am frantically reading through the learn Perl/learnCGI in 24 hour books. I just got done programing in dbase for some climatology work and now have to switch gears quickly.
My mission: to read in a (comma-delimited)web file with no extension:
http://147.241.74.132/cgi-bin/model/...fdda/&BIAS=OFF
The problem is, that I want to skip down 14-16 lines to get to the first line of data.
What is the easiest way to read in the lines of data, into an array?
A friend sent me this link: CGISCRIPTER
Is this along the lines of what I need? i will be placing simple (~50)Excel line equations probably into an array as well to perform calculations with the read in values. I will output the answers to a simple HTMl page.
HELP! I don't know much in the realm of CGI scripting, but I have been learning MySQL. I read in one message board that you can use "LOAD DATA INFILE 'C:\Documents and Settings\d~1\Desktop\test.csv' INTO TABLE x; " or something along those lines? Could MySQL be used or is just faster just to have PERL do all the reading, writing and arithmetic?
Anyways, thanks to anyone who would lend a helping thought,
Dave
PS- In the perl books, where should I concentrate my reading? using the "OPEN" command?
First I must warn you - you can't 'learn' any programming language in 24 hours. And forget about using MySQL for solving your problem. It's enough you have one learning curve to learn.
To address your immediate question 'to skip down 14-16 lines', Perl has a special variable called $. - that is a dollar sign with a dot immediately following it.
It is the current line counter, and is used something like this:
open IN ,'<', $somefile or die "Can't open $somefile: $!\n"; # ALWAYS check open result
while (defined ($line = <IN>))
{
print "Current line = $.\n";
}
close IN or die "Can't close $somefile: $!\n"; # and check the close resultSo, in your case you want to read the file until $. equals 14 or 16. I leave that as an exercise for you.
You will have to provide more details to determine whether to read 14, 15, or 16 lines.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
"Others make web sites. We make web sites work!"
•
•
Join Date: Sep 2007
Location: Near Arctic Circle
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Thanks for your help everyone. It pointed me to some new options in the coding. I didn't see the last post by trudge until now. I ended up ingesting the webfile into an array and then using:
@temparray= split/([,' '])/, $hours[$i];
which tells it whenever there is a comma and/or a space then split it. It took me forever to find this code, but it works great!
@temparray= split/([,' '])/, $hours[$i];
which tells it whenever there is a comma and/or a space then split it. It took me forever to find this code, but it works great!
![]() |
•
•
•
•
•
•
•
•
DaniWeb Perl Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- How to compare folders of XML files in Perl using ExamXML (Perl)
- Reading and Displaying a comma delimited text file to a table. (ASP)
- Beginner working with tab-delimited text file (Perl)
- Perl CSV question (Perl)
- qb 4.5 and comma-delimited data (Legacy and Other Languages)
- I've got Trojan.Holax... is this bad? (Viruses, Spyware and other Nasties)
- not-a-virusadware (Viruses, Spyware and other Nasties)
- How to write files to an Excel application (Visual Basic 4 / 5 / 6)
Other Threads in the Perl Forum
- Previous Thread: code to activate submit button
- Next Thread: Converting date problem ( I have spent hours trying to fix it)


Linear Mode