Home > Archive > PERL CGI Beginners > May 2004 > Not reading the whole file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Not reading the whole file
|
|
| Richard Heintze 2004-05-22, 11:32 am |
| This code is not reading the entire file. It is my
intent that it read the entire file. Can somone help
me remedy this problem?
Thanks,
Siegfried
open (INFILE, "data.txt");
my $backgr_data=<INFILE>;
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
| |
| Andrew Gaffney 2004-05-22, 11:32 am |
| Richard Heintze wrote:
> This code is not reading the entire file. It is my
> intent that it read the entire file. Can somone help
> me remedy this problem?
>
> Thanks,
> Siegfried
>
> open (INFILE, "data.txt");
> my $backgr_data=<INFILE>;
First, please don't reply to an unrelated post to start a new thread. This throws off
things for people who have threading support in their mailreaders.
Second, the <> operator is the same as calling 'readline'. It only reads one line of the
file. Try:
open INFILE, "< data.txt";
my $backgr_data;
while(<INFILE> ) {
$backgr_data .= $_;
}
--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548
| |
| Paul Archer 2004-05-22, 11:32 am |
| 3:01pm, Richard Heintze wrote:
> This code is not reading the entire file. It is my
> intent that it read the entire file. Can somone help
> me remedy this problem?
>
> Thanks,
> Siegfried
>
> open (INFILE, "data.txt");
Are you sure your file opened properly? Did you check?
open (INFILE, "data.txt") or die "Couldn't open file: $!";
> my $backgr_data=<INFILE>;
>
Reading from a filehandle in scalar context reads one line at a time. Sounds
like you want to slurp the whole file in at once, so you want
my @backgr_data=<INFILE>;
Paul
| |
| Richard Heintze 2004-05-22, 11:32 am |
| I think I solved my own problem.
I'm using a
my @backgr_data=<INFILE>;
to read everything. Is the above less efficient than
below?
read INFILE, $backgr_data, $some_really_big_number;
Thanks,
Siegfried
>This code is not reading the entire file. It is my
>intent that it read the entire file. Can somone help
>me remedy this problem?
> Thanks,
> Siegfried
>
> open (INFILE, "data.txt");
> my $backgr_data=<INFILE>;
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs
http://hotjobs.sweepstakes.yahoo.com/careermakeover
| |
| Jan Eden 2004-05-22, 11:32 am |
| Richard Heintze wrote on 04.05.2004:
>I think I solved my own problem.
>
>I'm using a=20
>
>my @backgr_data=3D<INFILE>;
>
Or use
my $backgr_data =3D join '', <INFILE>;
- Jan
--=20
There are two major products that come out of Berkeley: LSD and UNIX. We do=
n't believe this to be a coincidence. - Jeremy S. Anderson
| |
| Christopher G Tantalo 2004-05-22, 11:32 am |
| Jan Eden wrote:
>Richard Heintze wrote on 04.05.2004:
>
>
>
>Or use
>
>my $backgr_data = join '', <INFILE>;
>
>- Jan
>
>
The dbi module would be the best solution, as the quote method supports
any number of quotes in the string itself.
--
-------------------------------
Just Your Friendly Neighborhood
_SPIDEY_
-----------------------------------------
The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipie
nt, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your
computer.
Thank you. Paychex, Inc.
| |
| Christopher G Tantalo 2004-05-22, 11:32 am |
| Christopher G Tantalo wrote:
> Jan Eden wrote:
>
> The dbi module would be the best solution, as the quote method
> supports any number of quotes in the string itself.
>
wrong thread.. i am sorry.
--
-------------------------------
Just Your Friendly Neighborhood
_SPIDEY_
-----------------------------------------
The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipie
nt, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your
computer.
Thank you. Paychex, Inc.
|
|
|
|
|