![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Apr 2001
Location: MTL, QC, CAN
Posts: 1,243
|
Anyone knows how to make a perl script read 1 line in a file?
Ok
I want to make a script that reads only the first line of a text file. The name of the text file is data.txt Does any of you, programmers, knows how to do it? The script is written in perl. Thanks, Steve |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
So Fucking Banned
Join Date: Jan 2001
Location: http://www.thefly.net/ --- Quit your job and live off steady traffic.
Posts: 11,856
|
get the book
visual quickstart guide perl and cgi for the world wide web elizabeth castro makes perl reaaaaaly easy btw you could do the code in php to read one line w/ less code ;) |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Apr 2001
Location: MTL, QC, CAN
Posts: 1,243
|
Thanks Fly, I'll try to find this book
![]() I actually have one called: Perl Visual Pro But there is nothing about what I ask into it ![]() Thanks again, Steve |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Aug 2001
Location: Sunny Florida
Posts: 171
|
There are lots of ways...here's one off the cuff
my $linecount = 0; open FILE,"<file.txt" || die "Unable to open file: $!"; my @lines = <FILE>; close(FILE); my $line; foreach $line(@lines) { $linecount++; while ($linecount<2) { print "$line"; } } should work in most contexts. |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Confirmed User
Join Date: Aug 2001
Location: Sunny Florida
Posts: 171
|
never mind...the board won't print the code correctly
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Apr 2001
Location: MTL, QC, CAN
Posts: 1,243
|
Well, I actually find a way to do it...
Thanks anyway guys ![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 |
Will code for food...
Join Date: Apr 2001
Location: Buckeye, AZ
Posts: 8,496
|
php code:
$stuff = file('filename.txt'); $line = $stuff[0]; |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 |
So Fucking Banned
Join Date: Jan 2001
Location: http://www.thefly.net/ --- Quit your job and live off steady traffic.
Posts: 11,856
|
yeah i can't believe how easy php is ;)
|
![]() |
![]() ![]() ![]() ![]() ![]() |