Thanks folks, this is ANOTHER module I'm going to start using.
I have to say that this is a lot more fun than counting clock cycles, which
was the last bench-marking I did a long, long time ago...
regards,
Richard
At 19:53 7/06/2001 -0700, Peter Cornelius wrote:
>Looking at the other postin
Since someone raised the general question of differences, which is faster?
Randal's suggestion:
my @result = <*.jpg>;
or variations on:
@files = grep /jpg/i, readdir DIR;
regards,
Richard
On 7 Jun 2001, Randal L. Schwartz wrote:
> Was this on 5.6 or 5.6.1, where the glob is internalized, or on 5.5 or
> earlier, where glob called an external process?
This is on a RedHat Linux 7.1 os with 5.6.0.
--
Ian
> I got
>
> Benchmark: timing 5 iterations of Randals, variations...
>Randals: 79 wallclock secs (28.94 usr + 49.99 sys = 78.93
> CPU) @ 633.46/s
> (n=5)
> variations: 0 wallclock secs ( 0.03 usr + 0.00 sys = 0.03 CPU) @
> 166.67/s (n=5)
> (warning: too few it
> "iansmith" == iansmith <[EMAIL PROTECTED]> writes:
iansmith> On Fri, 8 Jun 2001, Richard Hulse wrote:
>> Since someone raised the general question of differences, which is faster?
>> my @result = <*.jpg>;
>> or variations on:
>> @files = grep /jpg/i, readdir DIR;
iansmith> use Benchmark;
> which is faster?
>
> Randal's suggestion:
>
> my @result = <*.jpg>;
>
> or variations on:
>
> @files = grep /jpg/i, readdir DIR;
>
Try this...
use Benchmark;
opendir (DH, ".") or die;
timethese(5, {
'Randals' => q{my @result = <*.jpg>},
'variations' => q{my @result =
On Fri, 8 Jun 2001, Richard Hulse wrote:
> Since someone raised the general question of differences, which is faster?
> my @result = <*.jpg>;
> or variations on:
> @files = grep /jpg/i, readdir DIR;
use Benchmark;
timethese(1, {
'Glob' => sub { my @result = <*.jpg>; },
'Read' => sub { opendir
Looking at the other posting to this I realize I should have included the
open and close in the test block. That makes the results...
Benchmark: timing 1 iterations of Randals, variations...
Randals: 16 wallclock secs ( 6.00 usr + 10.05 sys = 16.05 CPU) @ 622.98/s
(n=1)
variations: 3 w
On Thu, 7 Jun 2001, Peter Cornelius wrote:
> use Benchmark;
> opendir (DH, ".") or die;
> timethese(5, {
> 'Randals' => q{my @result = <*.jpg>},
> 'variations' => q{my @result = grep /\.jpg$/i, readdir DH}
> });
> closedir(DH)
This only reads the directory in once for the 'variati
At 01:45 PM 6/7/01 -0500, Shawn wrote:
>Can someone let me know what effectively is the difference between
>@files = grep {/jpe?g$/i} readdir DIR;
>and
>@files = grep /jpe?g$/i, readdir DIR;
>?
>
>Or is there any?
There isn't. Some people like to use only the block form even in those
cases wher
On Jun 7, Shawn said:
>Japhy pointed out this particular syntax to me. Before this, I was using
>@files = grep {/jpe?g$/i} readdir DIR;
>
>Can someone let me know what effectively is the difference between
>@files = grep {/jpe?g$/i} readdir DIR;
>and
>@files = grep /jpe?g$/i, readdir DIR;
If you
Japhy pointed out this particular syntax to me. Before this, I was using
@files = grep {/jpe?g$/i} readdir DIR;
Can someone let me know what effectively is the difference between
@files = grep {/jpe?g$/i} readdir DIR;
and
@files = grep /jpe?g$/i, readdir DIR;
?
Or is there any?
On 06/07, Pete E
...and just to include both .jpg and .jpeg like John's program:
opendir DIR, "./" or die "can't open $directory: $!\n";
@files = grep /jpe?g$/i, readdir DIR;
Nice code, Shawn. I must admit that my original way of doing this was even worse
than John's (by not using opendir and closedir). Zoiks. G
Holy JESUS! Why not:
opendir DIR, $directory or die "can't open $directory: $!\n";
@files = grep /jpg$/i, readdir DIR;
On 06/07, John Storms rearranged the electrons to read:
> my($path) = "/home/jstorms/public_html/images/";
> my(@files) = get_jpg_from_dir($path);
>
> sub get_jpg_from_dir {
>
Thanks for the info, I got everything up and running. I've never had so
many responses in such a short amount of time, and with so many ways of
getting the job done... :-)
-Evan
Evan McNabb [EMAIL PROTECTED]
http://www.mcnabbs.org/evan
On Thu, Jun 07, 2001 at 11:16:36AM -0500, Evan McNabb wrote:
>
> I've been working on a little script for a while but I can't seem to get
> this part working. What I want to do is list all of the *.jpg files in a
> directory (ls *.jpg) and then have an array with each filename as elements
> of th
my($path) = "/home/jstorms/public_html/images/";
my(@files) = get_jpg_from_dir($path);
sub get_jpg_from_dir {
my($path) = $_[0];
opendir(DIR,"$path");
my($filename,@jpeg);
$filename = readdir(DIR);
while($filename ne "") {
if( substr($filen
# begin cheap non portable hack
$list = `/bin/ls -1 *.jpg`;
@array = split(/\n/, $list);
# end cheap non portable hack
# try this a little cleaner
opendir(DIR, ".");
@dir_entries = readdir(DIR);
closedir(DIR);
foreach (@dir_entries)
{
next if(!/\.jpg/);
push(@arr, $_);
}
#end attempt
@list = `ls *.jpg`;
print @list;
Evan McNabb wrote:
>
> I've been working on a little script for a while but I can't seem to get
> this part working. What I want to do is list all of the *.jpg files in a
> directory (ls *.jpg) and then have an array with each filename as elements
> of that arr
--- Evan McNabb <[EMAIL PROTECTED]> wrote:
> I've been working on a little script for a while but I can't seem to
> get this part working. What I want to do is list all of the *.jpg
> files in a directory (ls *.jpg) and then have an array with each
> filename as elements of that array. Its probab
> "Evan" == Evan McNabb <[EMAIL PROTECTED]> writes:
Evan> I've been working on a little script for a while but I can't seem to get
Evan> this part working. What I want to do is list all of the *.jpg files in a
Evan> directory (ls *.jpg) and then have an array with each filename as elements
Ev
21 matches
Mail list logo