Re: writing get_script as an external routine callable by C
- From: "Uri Guttman" <uri@xxxxxxxxxxxxxx>
- Date: Thu, 14 May 2009 00:17:04 -0400
"BM" == Ben Morrow <ben@xxxxxxxxxxxx> writes:
>> my $filename = 'book1.txt';
>> open(my $fh, '<', $filename) or
>> die "cannot open $filename for reading: $!";
>> my @books;
BM> chomp( my @books = <$fh> );
BM> If you prefer, you can expand that to three statements:
BM> my @books;
BM> @books = <$fh>;
BM> chomp @books;
BM> You can also use File::Slurp::read_file, which will handle opening the
BM> file, chomping the lines and closing the file for you.
read_file doesn't (yet) chomp lines. that option is in the todo
list. but it does make it easier to read in a file as lines. this should
work fine:
use File::Slurp ;
chomp( my @books = read_file( $file_name ) ) ;
uri
--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.
- Follow-Ups:
- Re: writing get_script as an external routine callable by C
- From: Franken Sense
- Re: writing get_script as an external routine callable by C
- References:
- writing get_script as an external routine callable by C
- From: Franken Sense
- Re: writing get_script as an external routine callable by C
- From: Jürgen Exner
- Re: writing get_script as an external routine callable by C
- From: Franken Sense
- Re: writing get_script as an external routine callable by C
- From: Franken Sense
- Re: writing get_script as an external routine callable by C
- From: Ben Morrow
- writing get_script as an external routine callable by C
- Prev by Date: Re: writing get_script as an external routine callable by C
- Next by Date: Just visit and have a Latest Hotel Stay for One Month Free
- Previous by thread: Re: writing get_script as an external routine callable by C
- Next by thread: Re: writing get_script as an external routine callable by C
- Index(es):
Relevant Pages
|