P
poopdeville
Hi everybody,
I'm looking to write a Catalyst model to basically use a newline
delimited database, so that each line of the text file corresponds to a
datum. My question isn't about the module per se, but on smart
algorithms to pull a single line of text from an arbitrary text file.
I know the following would work:
#!/usr/bin/perl
use warnings;
use strict;
print "Enter a file\n";
my $file = <STDIN>;
print "Enter a number\n";
my $number = <STDIN>;
my @array;
open FILE, "$file";
while (<FILE>) { push @array; }
close FILE;
print $array[$number];
__END__
or something close to it should work. (I hope there aren't any errors
there, but if there are, I hope you get the idea of the naive
implementation I'm talking about). An anyone point the way to a faster
algorithm?
Thanks,
'cid 'ooh
I'm looking to write a Catalyst model to basically use a newline
delimited database, so that each line of the text file corresponds to a
datum. My question isn't about the module per se, but on smart
algorithms to pull a single line of text from an arbitrary text file.
I know the following would work:
#!/usr/bin/perl
use warnings;
use strict;
print "Enter a file\n";
my $file = <STDIN>;
print "Enter a number\n";
my $number = <STDIN>;
my @array;
open FILE, "$file";
while (<FILE>) { push @array; }
close FILE;
print $array[$number];
__END__
or something close to it should work. (I hope there aren't any errors
there, but if there are, I hope you get the idea of the naive
implementation I'm talking about). An anyone point the way to a faster
algorithm?
Thanks,
'cid 'ooh