[11997] in Perl-Users-Digest
Perl-Users Digest, Issue: 5597 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 7 15:07:27 1999
Date: Fri, 7 May 99 12:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 7 May 1999 Volume: 8 Number: 5597
Today's topics:
Re: ==> help with using strict <== (Matthew Bafford)
Can't Find Benchmark on CPAN <design@raincloud-studios.com>
Download script <dleach@bigfootNOSPAM.com>
Re: Download script <design@raincloud-studios.com>
Function vs Object oriented <grichard@uci.edu>
Re: HASH references... (I R A Aggie)
Re: How to keep travelled path in hash ? (Benjamin Franz)
Learning to use modules <grichard@uci.edu>
Re: Learning to use modules <design@raincloud-studios.com>
Re: ODBC and Access memo fields (Gus)
Re: procedure to convert sec to HH:MM:SS format (Larry Rosler)
Re: simple way for several if ( eq ||) ? (Bob Trieger)
Re: Stupid FAQ question of the (day? month? year?) (Bob Trieger)
thread::semaphore bug under winnt <ukirazci@fore.com>
Re: UNIX comands and switches in perl <ludlow@us.ibm.com>
Re: URGENT perldoc Sybase::* does nothing (I R A Aggie)
Re: using $, (was Re: having problems) (Fuzzy Warm Moogles)
Re: using $, (was Re: having problems) (Bart Lateur)
Re: Why my? <grichard@uci.edu>
Re: Why my? <design@raincloud-studios.com>
Re: Why my? <emschwar@rmi.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 07 May 1999 18:06:21 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: ==> help with using strict <==
Message-Id: <slrn7j69k2.7mf.dragons@dragons.duesouth.net>
On Fri, 7 May 1999 13:56:59 -0300, Kevin Howe <khowe@performance-net.com>
lucked upon a computer, and thus typed in the following:
: Why doesn't "strict" allow you to use 1,2,3,etc. as scalar references to
: the variables $1, $2, $3. etc?
: In the following script, is strict is commented out, it will work fine, but
: without it commented out, it gives me the error I mentioned above.
I'm sorry, your code seems to have mutated into a gaudy subject line.
Please try again.
Be sure to read 'perldoc strict', first.
: Much appreciated,
HTH, HAND,
: Kevin Howe
--Matthew
------------------------------
Date: Fri, 07 May 1999 18:01:01 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Can't Find Benchmark on CPAN
Message-Id: <xTFY2.89$vP2.100@news.rdc1.tn.home.com>
I've never had this much trouble 'drilling-down' to a module. I'm trying to
find the benchmark module so I can test a few things. I went to CPAN and
modules by name... when I click on Benchmark I end up in ILYAZ. Benchmark is
nowhere to be found in this directory... not even in the modules/
subdirectory. Is the actual .gz named something else?
CT
------------------------------
Date: Fri, 7 May 1999 19:25:24 -0500
From: "K-Nine" <dleach@bigfootNOSPAM.com>
Subject: Download script
Message-Id: <7gvb38$csg$1@news4.svr.pol.co.uk>
Hi,
I have no knowledge of Perl but am looking for a script that will monitor
what people download form my site and report it. Can any1 help please?
Thankyou
Dan
------------------------------
Date: Fri, 07 May 1999 18:53:19 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Download script
Message-Id: <zEGY2.175$vP2.158@news.rdc1.tn.home.com>
>I have no knowledge of Perl but am looking for a script that will monitor
>what people download form my site and report it. Can any1 help please?
If you are set on Perl, you could write a script to log your downloads. This
group deals with the Perl language itself, which you aren't using (yet).
Since it is fairly obvious you are new to this...
I would recommend going to comp.infosystems.www.authoring.cgi and ask about
website statistics generating scripts. Let them know what you are trying to
accomplish and they may have a solution for you. A stat script will let you
know what files are being accessed on your system by parsing the access_log
for the server.
P.S. Many hosting providers are starting to supply these scripts preconfigured
for your account. You might check with them as well.
CT
------------------------------
Date: Fri, 7 May 1999 11:47:35 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Function vs Object oriented
Message-Id: <7gvc6f$efm@news.service.uci.edu>
It seems (at least with CGI.pm) that function oriented programming reduces
keystrokes. Other than that it isn't obvious to me what the significant
differences are and/or benefits of either. The docs for this module seem to
prefer the object oriented style, but why?
On a different note, using CGI.pm to generate dynamic documents seems kinda
cumbersome. I mean, isn't it easier and faster just to use a here document?
What am I not thinking about?
Gabe
------------------------------
Date: 7 May 1999 18:22:36 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: HASH references...
Message-Id: <slrn7j6c09.a63.fl_aggie@stat.fsu.edu>
On Fri, 7 May 1999 11:23:40 -0600, Paul L Tomlinson <keighvin@urjet.net>, in
<926097562.578.90@news.remarQ.com> wrote:
+ How can I refer to elements in a hash using a pointer, reference, or
+ variable?
If I'm groking your question, you want to know how to access an element
within a hash using a variable. This may provide enlightenment:
%hash=qw/a 1 b 2 c 3 d 4 e 5/;
foreach $key (sort keys %hash) {
print "$key $hash{$key}\n";
}
Results:
a 1
b 2
c 3
d 4
e 5
James
------------------------------
Date: Fri, 07 May 1999 18:47:12 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: How to keep travelled path in hash ?
Message-Id: <QyGY2.9081$ny.796334@typhoon-sf.snfc21.pbi.net>
In article <AmFY2.9066$ny.790708@typhoon-sf.snfc21.pbi.net>,
Benjamin Franz <snowhare@long-lake.nihongo.org> wrote:
>In article <7gskak$qpq$1@news.mch.sbs.de>,
>Michel Dalle <michel.dalle@usa.net> wrote:
>>Hi,
>>
>>here is a little brain teaser. :-)
>>
>>I want to keep track of the number of times a certain PATH is travelled
>>through a website/city/forrest/..., and I have a file containing the
>>the different pages/pubs/trees/... by each visitor.
>>
>>E.g. : (who when where)
>>mike 01:52 post1
>>mike 01:53 post2
>>john 01:53 post3
>>mike 01:54 post1
>>john 01:55 post1
>>john 01:56 post2
>>mike 01:57 post3
>>john 01:58 post2
>>..
For some reason I just couldn't leave this one alone (probably
because I've been considering adding path analysis to my
log analysers).
Mk 2:
#!/usr/bin/perl -w
use strict;
@User::ISA = qw(Generic);
@IndivPath::ISA = qw(Generic);
@Path::ISA = qw(Generic);
my $paths = {};
my $users = {};
while (my $line = <STDIN>) {
chop $line;
my ($who,$when,$where) = split(/ /,$line,3);
# This user
my $user = $users->{$who};
if (not defined $user) {
$user = User->new({ -who => $who,
-paths => {},
-last_where => '',
-last_when => '',
-count => -1,
});
$users->{$who} = $user;
}
my ($last_where,$last_when,$user_paths,$user_count) = $user->get('-last_where','-last_when','-paths','-count');
$user_count++;
$user->set({ -count => $user_count, -last_when => $when, -last_where => $where });
next if ($user_count == 0);
# The paths *this* user has followed
my $ipath = $user_paths->{$last_where}->{$where};
if (not defined $ipath) {
$ipath = IndivPath->new({ -count => 0, -last_when => '' });
$user_paths->{$last_where}->{$where} = $ipath;
}
my ($ipath_count) = $ipath->get('-count');
$ipath_count++;
$ipath->set({ -count => $ipath_count, -last_when => $when });
# *This* path
my $path = $paths->{$last_where}->{$where};
if (not defined $path) {
$path = Path->new({ -count => 0,
-users => {},
-last_when => '',
});
$paths->{$last_where}->{$where} = $path;
}
my ($path_count,$path_users) = $path->get('-count','-users');
$path_count++;
# The users who have followed *this* path
if (not defined $path_users->{$who}) {
$path_users->{$who} = $user;
}
$path->set({ -count => $path_count, -last_when => $when });
}
print "Paths:\n";
my @path_list = sort keys %$paths;
foreach my $from (@path_list) {
my @targets = keys %{$paths->{$from}};
foreach my $to (@targets) {
my $path = $paths->{$from}->{$to};
my ($count,$path_users,$last) = $path->get('-count','-users','-last_when');
my @visitors = sort keys %$path_users;
print "$from -> $to ($count) last on $last\n";
foreach my $who (@visitors) {
my $user = $path_users->{$who};
my ($user_paths) = $user->get('-paths');
my $ipath = $user_paths->{$from}->{$to};
my ($visits,$u_last) = $ipath->get('-count','-last_when');
print " $who ($visits) last on $u_last\n";
}
}
}
print "-------------------------------------\nUsers:\n";
my @users_list = sort keys %$users;
foreach my $who (@users_list) {
my $user = $users->{$who};
my ($total,$user_paths,$last) = $user->get('-count','-paths','-last_when');
print "$who ($total) last on $last\n";
my (@from_list) = sort keys %$user_paths;
foreach my $from (@from_list) {
my (@to_list) = sort keys %{$user_paths->{$from}};
foreach my $to (@to_list) {
my $ipath = $user_paths->{$from}->{$to};
my ($count,$p_last) = $ipath->get('-count','-last_when');
print " $from -> $to ($count) last on $p_last\n";
}
}
}
package Generic;
sub new {
my ($class) = shift;
my $self = bless {},$class;
if ($#_ > -1) {
$self->set(@_);
}
$self;
}
sub set {
my ($self) = shift;
my ($parm_ref) = @_;
my $parm_list = [];
@$parm_list = keys (%$parm_ref);
foreach my $parm (@$parm_list) {
my $key = lc ($parm);
my $value = $parm_ref->{$parm};
$self->{$key} = $value;
}
}
sub get {
my ($self) = shift;
my (@parm_list) = @_;
my (@result) = ();
foreach my $parm (@parm_list) {
my $value = $self->{lc($parm)};
if (defined $value) {
push (@result,$value);
} else {
push (@result,'');
}
}
return @result;
}
--
Benjamin Franz
------------------------------
Date: Fri, 7 May 1999 11:06:50 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Learning to use modules
Message-Id: <7gv9q3$d8j@news.service.uci.edu>
I'm new to perl and am just beginning to learn how to use modules. I have a
question about a sample in the docs for CGI.pm.
use CGI;
So this initiates the module or something like that. Where must the module
reside?
In the script's directory? In @INC?
$query = new CGI;
So this causes the scalar variable $query to point to the CGI module?
I can now use CGI.pm's methods (like subroutines basically?) by referring to
them $query->method()?
I must read the module's docs to learn about the methods and the syntax to
use them?
my($query) = @_;
This is what I really don't understand. Isn't $query's value already set?
What is this for?
Is @_ simply the array version of $_? I don't understand the camel book's
explanation very clearly.
Thanks,
Gabe
------------------------------
Date: Fri, 07 May 1999 18:36:33 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Learning to use modules
Message-Id: <RoGY2.141$vP2.96@news.rdc1.tn.home.com>
>So this initiates the module or something like that. Where must the module
>reside?
>In the script's directory? In @INC?
>$query = new CGI;
This depends. If it's a system you have more access to, the modules can be
installed (usually by an included installation untility) where all Perl users
can use them. Sometimes the system administrators will have popular modules
already installed on the system. On more limited machines (such as a webserver
with 'virtual servers') access to such installtions will be forbidden and you
will probably use a subdirectory under your cgi-bin. An example from one of
our setups...
use lib '/drv1/web/sites/web6517e/cgi-bin/mdl';
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
$query = new CGI;
Here we copied the CGI.pm and it's related files/directories to our mdl
directory. We added the path to the @INC and then used it in our script. The
only main concerns I've come across are making sure you have a compatible Perl
version and your permissions are set correctly. Usually looking in the top of
the .pm file will reveal what Perl version is required.
It's also important to note that if you are FTP'ing to a server you need to
make sure 'convert to lower case' isn't enabled if your software supports that
feature. Many of these modules are case sensitive and you'll never get them to
work if the file name changes.
I'll leave the other questions to the rest because I'm not so hot at
presenting more detailed technical stuff. :)
CT
------------------------------
Date: Fri, 07 May 1999 18:02:42 GMT
From: spg@quokka.com (Gus)
Subject: Re: ODBC and Access memo fields
Message-Id: <37332997.65926096@news.earthlink.net>
On 7 May 1999 17:19:44 GMT, scott@aravis.softbase.com (Scott McMahan)
wrote:
>gregarine (michaelw@palawnet.com) wrote:
>> I am using Active Perl on NT using ODBC to access a memo field out of
>> Access97. The problem is that I am only getting part of the memo field loaded
>> into my perl variable. Their is a long article in the memo field. It seems
>> due to some sort of character limitation because when i cut stuff out of the
>> memo field I am able to load a bit more. Thus I don't think it is due to
>> some sort of unrecognizable caharacter or an EOF.
>
>You may very well be hitting a limit on the amount of data that can go
>through an Automation string. I think the limit is 255 bytes, but it has
>been so long since I encountered that limit I can't remember. I don't
>think this is an Access bug as much as it is the Automation system's bug.
>I think the limit is built into the BSTR data type. It's been a long
>time, though, since I dealt with that.
>
>Scott
Actually if you are using DBI you need to look at the documentation
for LongReadLen
$dbh->{LongReadLen}=1500;
Change this value to something larger than the largest entry in your
memo field, and you should be okay.
gus
------------------------------
Date: Fri, 7 May 1999 11:44:04 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <MPG.119cd44efcff4a439899f7@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <373306f9.588576@news.skynet.be> on Fri, 07 May 1999 15:31:12
GMT, Bart Lateur <bart.lateur@skynet.be> says...
> M.J.T. Guy wrote:
> >Bart Lateur <bart.lateur@skynet.be> wrote:
> >>Also, note that (s)printf('%d', NONINTEGER) also rounds towards zero
> >>(aka "truncate"), so you don't really need all that.
> >
> >It's just an accident of the current implementation that it truncates
> >rather than rounds. So don't rely on that.
>
> Tell that to Larry Rosler!
Thanks for telling me. NOT!
> Larry Rosler wrote:
> >> $timestring = sprintf("%02d:%02d:%02d",
> >> int ($sec /3600 ),
> >> int(($sec % 3600 ) / 60 ),
> >> $sec % 60 );
> >
> >Redundant use of int()! :-)
>
> Apparently, if you want to be on the safe side, it's NOT redundant.
I know of one other situation where a number is implicity truncated: in
array indexing. I've looked through perldata, perlop, and perlsyn, but
can't find an explicit statement of this truncation. All perldata says
is "Normal arrays are indexed by number, starting with 0." D'oh!.
I know of no situation where a number is implicitly rounded.
Changing the current implementation of s?printf from truncation to
rounding would be malicious tampering with existing, functioning code.
Note that the C specification is of no help here, because integers and
floating-point numbers are different data types in C, so explicit
conversion is required. However, assigning or casting a float or double
to an integer *truncates*, explicitly: "When a value of floating type
is converted to integral type, the fractional part is discarded." To do
otherwise in Perl would be egregious.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 07 May 1999 18:15:18 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: simple way for several if ( eq ||) ?
Message-Id: <7gv9rg$d6q$1@holly.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
Eric The Read <emschwar@rmi.net> wrote:
>Well, I just whipped up a quickie benchmark:
>timethese( 65536, {
> Grep => sub { grep /$name/io, @names },
> Regex => sub { $name =~ /$regex/io },
> NoGrep => sub { grep /$notName/io, @names },
> NoRegex => sub { $notName =~ /$regex/io },
> } );
>
>And found:
>
>Benchmark: timing 65536 iterations of Grep, NoGrep, NoRegex, Regex...
> Grep: 11 secs ( 9.71 usr 0.04 sys = 9.75 cpu)
> NoGrep: 10 secs (10.00 usr 0.04 sys = 10.04 cpu)
> NoRegex: 6 secs ( 6.44 usr 0.02 sys = 6.46 cpu)
> Regex: 3 secs ( 3.21 usr 0.01 sys = 3.22 cpu)
>
I threw a hash as Bart suggested, into your benchmark and it is twice as
fast as the regex.
Benchmark: timing 5000000 iterations of Grep, NoGrep, NoRegex, Regex,
hash, nohash...
Grep: 88 secs (87.44 usr 0.00 sys = 87.44 cpu)
NoGrep: 85 secs (85.00 usr 0.00 sys = 85.00 cpu)
NoRegex: 61 secs (60.66 usr 0.00 sys = 60.66 cpu)
Regex: 46 secs (46.51 usr 0.00 sys = 46.51 cpu)
hash: 20 secs (19.50 usr 0.00 sys = 19.50 cpu)
nohash: 21 secs (20.99 usr 0.00 sys = 20.99 cpu)
Here is the code I used for the timings:
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my $name = 'JOHN';
my $notName = 'BILBO';
my @names = qw(BOB DAVE BERT JOHN);
my $regex = join '|',@names;
my %names = map { $_ => 1 } @names;
timethese( 5000000, {
Grep => sub { grep /$name/io, @names },
Regex => sub { $name =~ /$regex/io },
NoGrep => sub { grep /$notName/io, @names },
NoRegex => sub { $notName =~ /$regex/io },
hash => sub { exists $names{$name} },
nohash => sub { exists $names{$notName} }
} );
------------------------------
Date: Fri, 07 May 1999 18:41:55 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: Stupid FAQ question of the (day? month? year?)
Message-Id: <7gvbdd$eqn$1@holly.prod.itd.earthlink.net>
[ courtesy cc sent by mail if address not munged ]
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
>sowmaster@juicepigs.com (Bob Trieger) writes:
>
>> Just translate the FAQS into text files and then you can use any text
>> reader, editor or web browser to view them. To find a specific entry
>> open the file in your reader/editor/browser and do a search on the
>> entry.
>
>/me scratches his head harshly.
>
>Aren't the FAQs already text files??
No, they aren't. They are in POD format and this format isn't pretty if
simply displayed on a windows machine.
------------------------------
Date: Fri, 07 May 1999 18:45:21 GMT
From: "Ulas Kirazci" <ukirazci@fore.com>
Subject: thread::semaphore bug under winnt
Message-Id: <01be98b9$085b5e90$7201000a@kirazci>
i am using build 5.00503 on an winnt server service pack 4.
for some odd reason, the number of filehandles in the system increases each
time i do an up or a down on a semaphore. is this perhaps a leak in the
thread::semaphore module?
is there any hope of the 4-argument select being supported for all
filehandles under winnt?
ulas
------------------------------
Date: Fri, 07 May 1999 13:15:49 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: UNIX comands and switches in perl
Message-Id: <37332DD5.34E82E3C@us.ibm.com>
Jerry Raynor
>
> I'm trying to do a search using the grep command (which does case-sensitive
> searches) with the (-i) it would return all matches regardles of case. I'm
> just not sure how to format it.
>
> @results = grep(/$searchstr/,@data);
> (works but is case-sensitive)
>
> I've tried:
> @results = grep -i (/$searchstr/,@data);
Close, but not quite. You want your regex to be case insensitive.
'perldoc -f grep' will show you why you're getting the error messages.
'perldoc perlre' will show you how to use the 'i' modifier.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 7 May 1999 18:30:33 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: URGENT perldoc Sybase::* does nothing
Message-Id: <slrn7j6cf6.a63.fl_aggie@stat.fsu.edu>
On Fri, 07 May 1999 12:27:09 -0400, Steve Linberg
<linberg@literacy.upenn.edu>, in
<linberg-0705991227090001@ltl1.literacy.upenn.edu> wrote:
+ Run, don't walk, to http://www.perl.com and dig into the CPAN archives.
Better yet, get CPAN.pm, and install that. Then, from your friendly
neighborhood command line, you can do magic like:
% perl -MCPAN -e shell
At that point, after configuration, one can do:
cpan> d /sybase/
Distribution BPOWERS/Sybase-Login-1.4.tar.gz
Distribution M/MD/MDOWNING/Apache-Sybase-CTlib-1.02.tar.gz
Distribution MEWP/DBD-Sybase-0.13.tar.gz
<and the crowd goes wild>
You can even install the module you want! *gasp* or just get the README.
James
------------------------------
Date: Fri, 07 May 1999 18:15:54 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: using $, (was Re: having problems)
Message-Id: <37331ef0.9411212@news.oz.net>
On Fri, 07 May 1999 09:46:53 GMT, bart.lateur@skynet.be (Bart Lateur) wrote:
>BENCHMARKS
>
>I've modified Larry's original code, so that it's more realistic. I have
>a row of 50 cells, and the length of each cell line is random (between 5
>and 29).
I am unclear what you mean. I have run your benchmark code with line lengths
set at 5, 25, 50 and 100. The results are below. They contradict the
results you get on your computer with your version of Perl.
>Different runs provide different data. Apparently, how these
>routines compare, depends on the data! Sometimes your code is faster,
>sometimes mine.
Uri's code consistently beats out your code over here.
>But before you get too carried away, be aware of the
>fact that the "localize" of the special variables is one of the things
>that take a lot of the time. If I move setting the variables to outside
>the test sub, mine becomes the clear winner.
I also thought localizing variables was unfair. You normally localize once
for several prints, but the benchmarks localizes for every print. Even when
this is corrected though, your non-localized code still lost out to Uri's.
>What is not obvious to me is the large difference between
>"BartNoLocalize"+"Localize" and plain "Bart". There's a 0.75 seconds
>difference, and it's not just the sub call; I added a
The difference is much smaller in the results I got.
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $size = 50; # 5, 25, 50, 100
my @data = ('x' x $size) x 50;
open OUT, '>NUL' or die "Couldn't open 'NUL'. $!";
# Pardon my misspelling of '/dev/null'. :-)
my $loops = 10000;
timethese($loops, {
Bart => sub { local($\,$,) = ("\n", "\t"); print OUT @data },
uri => sub { print OUT join("\t",@data),"\n" },
Interpol => sub { local $" = "\t"; print OUT "@data\n" },
Localize => sub { local($\,$,) = ("\n", "\t") },
});
{
local($\,$,) = ("\n", "\t");
timethese($loops, {
BartNoLocal => sub { print OUT @data },
});
}
__END__
**RUN 1: $size = 5;
Benchmark: timing 10000 iterations of Bart, Interpol, Localize, uri...
Bart: 2 wallclock secs ( 1.82 usr + 0.00 sys = 1.82 CPU)
Interpol: 1 wallclock secs ( 0.54 usr + 0.00 sys = 0.54 CPU)
Localize: 0 wallclock secs ( 0.27 usr + 0.00 sys = 0.27 CPU)
(warning: too few iterations for a reliable count)
uri: 0 wallclock secs ( 0.61 usr + 0.00 sys = 0.61 CPU)
Benchmark: timing 10000 iterations of BartNoLocal...
BartNoLocal: 2 wallclock secs ( 1.70 usr + 0.00 sys = 1.70 CPU)
(I have reformatted the benchmark for BartNoLocal. $\ splits it across
several lines.)
**RUN 2: $size = 25;
Benchmark: timing 10000 iterations of Bart, Interpol, Localize, uri...
Bart: 3 wallclock secs ( 2.68 usr + 0.00 sys = 2.68 CPU)
Interpol: 2 wallclock secs ( 1.59 usr + 0.00 sys = 1.59 CPU)
Localize: 0 wallclock secs ( 0.21 usr + 0.00 sys = 0.21 CPU)
(warning: too few iterations for a reliable count)
uri: 2 wallclock secs ( 1.54 usr + 0.00 sys = 1.54 CPU)
Benchmark: timing 10000 iterations of BartNoLocal...
BartNoLocal: 2 wallclock secs ( 2.47 usr + 0.00 sys = 2.47 CPU)
**RUN 3: $size = 50;
Benchmark: timing 10000 iterations of Bart, Interpol, Localize, uri...
Bart: 4 wallclock secs ( 3.84 usr + 0.00 sys = 3.84 CPU)
Interpol: 3 wallclock secs ( 2.74 usr + 0.00 sys = 2.74 CPU)
Localize: 0 wallclock secs ( 0.22 usr + 0.00 sys = 0.22 CPU)
(warning: too few iterations for a reliable count)
uri: 3 wallclock secs ( 2.64 usr + 0.00 sys = 2.64 CPU)
Benchmark: timing 10000 iterations of BartNoLocal...
BartNoLocal: 3 wallclock secs ( 3.57 usr + 0.00 sys = 3.57 CPU)
**RUN 4: $size = 100;
Benchmark: timing 10000 iterations of Bart, Interpol, Localize, uri...
Bart: 6 wallclock secs ( 6.10 usr + 0.00 sys = 6.10 CPU)
Interpol: 5 wallclock secs ( 5.01 usr + 0.00 sys = 5.01 CPU)
Localize: 0 wallclock secs ( 0.27 usr + 0.00 sys = 0.27 CPU)
(warning: too few iterations for a reliable count)
uri: 5 wallclock secs ( 4.67 usr + 0.00 sys = 4.67 CPU)
Benchmark: timing 10000 iterations of BartNoLocal...
BartNoLocal: 5 wallclock secs ( 5.60 usr + 0.00 sys = 5.60 CPU)
I can only guess that you are running an older version of Perl and that there
have been optimizations to 'join' since then. Or perhaps I have a broken $\
and $, :)
Below is my Perl version info:
C:\WINDOWS>perl -v
This is perl, version 5.005_02 built for MSWin32-x86-object
Copyright 1987-1998, Larry Wall
Binary build 508 provided by ActiveState Tool Corp. http://www.ActiveState.
Built 16:22:15 Dec 22 1998
Perl may be copied only under the terms of either the Artistic License or t
GNU General Public License, which may be found in the Perl 5.0 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Fri, 07 May 1999 18:47:40 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: using $, (was Re: having problems)
Message-Id: <37333425.362395@news.skynet.be>
Fuzzy Warm Moogles wrote:
>>I've modified Larry's original code, so that it's more realistic. I have
>>a row of 50 cells, and the length of each cell line is random (between 5
>>and 29).
>
>I am unclear what you mean. I have run your benchmark code with line lengths
>set at 5, 25, 50 and 100. The results are below. They contradict the
>results you get on your computer with your version of Perl.
I mean that different array ELEMENTS have different sizes. Your and
Larry's arrays have elements with ALL the same constant size.
Apparently that makes a difference.
>I can only guess that you are running an older version of Perl and that there
>have been optimizations to 'join' since then. Or perhaps I have a broken $\
>and $, :)
"Older"? I'm running the very latest 5.005_02 GNU DOS port.
Anyway, it shows once more that the benchmarks are not that reliable,
because they vary across Perl versions and data size, so relatively
small differences may safely be discarded. Let's go only for readabilty,
however you define it.
Bart.
------------------------------
Date: Fri, 7 May 1999 11:19:16 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Re: Why my?
Message-Id: <7gvahe$dj3@news.service.uci.edu>
Kevin Howe <khowe@performance-net.com> wrote in message
news:OLFY2.27764$134.325397@tor-nn1.netcom.ca...
> Yes, that's exactly why. When you have a large program, it is easy to use
> the same name twice (this is called a CONFLICT), and this can cause you
> massive headaches, trust me.
>
OK, so suppose I've got a variable in one part of my program that I want to
be available somewhere else, in this case should I not use "my" (and the
variable becomes global?) or is there someway to explicitly pass (or take) a
variable from one subroutine to another?
Gabe
------------------------------
Date: Fri, 07 May 1999 18:45:57 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Why my?
Message-Id: <FxGY2.158$vP2.12@news.rdc1.tn.home.com>
>OK, so suppose I've got a variable in one part of my program that I want to
>be available somewhere else, in this case should I not use "my" (and the
>variable becomes global?) or is there someway to explicitly pass (or take) a
>variable from one subroutine to another?
You should read ...
http://language.perl.com/newdocs/pod/perlfaq7.html#What_s_the_difference_betwe
en_dy
To get a basic look at my.
Passing scalars and arrays between subroutines is possible. I think I saw you
mention the Camel Book in a previous message here?!? Try page 110 which begins
a discussion on subroutines. (112 answers your question)
P.S. Flipping back a few pages to 108 will give more insight to my.
CT
------------------------------
Date: 07 May 1999 12:56:53 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Why my?
Message-Id: <xkf3e18lnd6.fsf@valdemar.col.hp.com>
"Gabe" <grichard@uci.edu> writes:
> OK, so suppose I've got a variable in one part of my program that I want to
> be available somewhere else, in this case should I not use "my" (and the
> variable becomes global?)
You should "use vars qw($var1, @var2, %var3);". If you don't use "my",
then "use strict" will complain. You *are* using the strict module,
aren't you?
> or is there someway to explicitly pass (or take) a variable from one
> subroutine to another?
I'm pretty sure there's no way to do a COME FROM in Perl (watch, somebody
will come along and prove me wrong), but it's trivial to pass variables
into subroutines. perldoc perlsub for more details-- just be careful and
pay attention on how to pass hashes and lists and the like.
-=Eric
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5597
**************************************