[7138] in Perl-Users-Digest
Perl-Users Digest, Issue: 761 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 24 03:38:53 1997
Date: Thu, 24 Jul 97 00:00:59 -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 Thu, 24 Jul 1997 Volume: 8 Number: 761
Today's topics:
2-way sockets with IO::Socket.pm (Ken Williams)
Re: ?? - how to format for sendmail <lnzadams@slip.net>
A problem with references and bless w.stanton@auckland.ac.nz
ANNOUNCE: Bit::Vector 4.2 (Set::IntegerFast) (Steffen Beyer)
Any PL/SQL packages/functions with perl-type functions (Dude)
Benchmarking Perl Compile Times <bkyan@mindcast.com>
Re: Can't match = (Roberto L. Dorich)
cgi for form based uploads <donb@dllb.com>
Re: cgi perl <lucas@macronet.it>
Re: cgi, server side include help <brandon@mrgolm.com>
Re: Creating a file, only if the file handle is 'used' <dres@dimensional.com>
Displaying 1 html file in cgi, then second (Neeraj Murarka)
flocking on HP-UX (J. Paul Reed)
Formatting Text 101! HELP!!! <webmaster@restaurantdigest.com>
hashes and <img> <gland@ccs.neu.edu>
Re: hashes and <img> <rootbeer@teleport.com>
Re: hashes and <img> <gland@ccs.neu.edu>
Re: how to reverse substitution order ? (Tim Smith)
How to set precision <agnet@3rivers.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Jul 1997 17:00:52 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: 2-way sockets with IO::Socket.pm
Message-Id: <ken-2207971700520001@news.swarthmore.edu>
Hi-
I'm trying to set up a Unix-domain (not Internet-domain) server & client
using IO::Sockets.pm. The connection must be two-way, i.e. the client and
server must each be able to send and receive data to and from the other.
I've figured out how to get the server to write to the client, but I can't
get the client to write to the server.
I've structured my server & client somewhat like the Camel Book examples,
although those use Socket.pm instead of IO::Socket.pm. Here is my client:
---------------------------------------------
#!/usr/bin/perl -w
require 5.002;
use IO::Socket;
use strict;
my ($NAME, $socket, $line);
$NAME = '/tmp/taco_socket';
$socket = new IO::Socket::UNIX (Type => SOCK_STREAM,
Peer => $NAME) or die $!;
print $socket ("Hi, here's a line.\n");
while (defined ($line = <$socket>) ) {
print $line;
# last if $line =~ /bye/;
}
---------------------------------------------
And here are some relevant parts of my server:
---------------------------------------------
my $NAME = '/tmp/taco_socket';
$SIG{CHLD} = \&REAPER; # &REAPER is just like Camel example's &REAPER
my $server = new IO::Socket::UNIX(Type => SOCK_STREAM,
Local => $NAME,
Listen => 10 ) or die $!;
my $client;
while ($client = $server->accept()) {
$client->autoflush(1);
print $client ("Hiya. Found child.\n");
&spawn (\&handle_child); # Much like Camel Book's &spawn,
# but I skip the STDIO duping
print $client ("Goodbye.\n");
}
sub handle_child {
my $line;
$line = <$client>; # This doesn't work (the &handle_child seems
# to get skipped entirely! I.E., no "Hello there..."
print $client "Hello there, it's now ", scalar localtime, "\n";
print $client ("You say '$line'.\n");
exec '/usr/bin/date';
}
----------------------------------------------
Another problem, and I suspect it's a related one, is that the child never
finishes the request. The while() loop never finishes - it waits for a
<$socket>, I guess.
I'd appreciate any help anyone can offer with this - more than anything,
I'd appreciate it if there were examples - even a Usage Example (!) - in
the IO::Sockets.pm manual page.
Thanks very much in advance.
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: Tue, 22 Jul 1997 13:32:11 -0700
From: Lindsay Adams <lnzadams@slip.net>
Subject: Re: ?? - how to format for sendmail
Message-Id: <33D518BA.3ACE44D0@slip.net>
Lindsay Adams wrote:
> I have just started programming in Perl, and my project is coming
> along
> nicely, in fact it works perfectly except for one thing. It generates
> an
> output file that is basically a really complicated mail merge. It does
>
> it just fine and I can open the generated file and pass it to sendmail
>
> as the body of an email, but...
>
> What I want to do is have teh output file sent as an attachment.
>
> This may be slightly Off subject but if anyone knows how to format teh
>
> output to sendmail so that I can send it as an attached file instead
> of
> as the body of the email, I would be most appreciative.
>
> Please reply to my email address as I rarely have time to scour the
> newsgroups these days.
>
> thank you much!
> Anyone else curious about this answer may also email me and I will
> forward all responses to you.
>
> lnzadams@slip.net
Thank you to all those that answered. This newbie id very grateful and
the answer was MIME::Lite from CPAN
------------------------------
Date: 23 Jul 1997 11:02:28 +1300
From: w.stanton@auckland.ac.nz
Subject: A problem with references and bless
Message-Id: <wkg1t6u4nf.fsf@RIDO.i-have-a-misconfigured-system-so-shoot-me>
I am using a Hash of references to blessed objects like so...
$self->{list}->{$design} = $evaluation;
my $d;
foreach $d (keys %{$self->{list}}){
print $d;
print "\t";
print ref $d;
print "\n";
print $design;
print "\t";
print ref $design;
print "\n";
print "\n" . $design->toString;
print "\n" . $d->toString;
}
The output from the above is...
Design=HASH(0xb77bf0)
Design=HASH(0xb77bf0) Design
x 0.1 y 2.9
Can't locate object method "toString" via package
"Design=HASH(0xb77bf0)" at Des ignCache.pm line 39.
$d and $design appear to be the same.
But ref $d != ref $design
When I try to bless $d (a C programmer trying to cast...) to Design as
bless $d, Design;
I get the error message
Can't bless non-reference value at DesignCache.pm line 30.
But I can (re) bless $design.
Is there some magic I am missing with keys of Hash?
Worik Stanton
------------------------------
Date: 20 Jul 1997 15:48:41 GMT
From: sb@sdm.de (Steffen Beyer)
Subject: ANNOUNCE: Bit::Vector 4.2 (Set::IntegerFast)
Message-Id: <5qtc0p$1m5$1@nadine.teleport.com>
I am glad and proud to submit
=====================================
Package "Bit::Vector" Version 4.2
=====================================
for Perl version 5.000 and higher
Copyright (c) 1995, 1996, 1997 by Steffen Beyer. All rights reserved.
This package is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
to the Perl community.
Abstract:
---------
This module is extremely useful for a lot of different tasks:
For example for implementing sets and performing set operations (like
union, difference, intersection, complement, check for subset relation-
ship etc.), as a basis for many efficient algorithms (the complexities
of the methods in this module are either O(1) or O(n) (the latter is
actually O(n/b), where b is the number of bits in a machine word on
your system!)), like the "Sieve of Erathostenes" (for calculating prime
numbers), for having shift registers (for instance for Cyclic Redundancy
Checksums) of arbitrary length, to calculate "look-ahead", "first" and
"follow" character sets for parsers and compiler-compilers, for graph
algorithms, for efficient storage and retrieval of state information,
for performing text generation depending on logical expressions,
and much more!
=======================
A T T E N T I O N :
=======================
#########################################################################
## ##
## This distribution REPLACES the "Set::IntegerFast"-distribution!!! ##
## ================================================================= ##
## ##
#########################################################################
Contents of this message:
-------------------------
+ Where to find
+ Prerequisites
+ New features in version 4.2
+ What does it do
+ New features in version 4.1
+ New features in version 4.0
+ This distribution contains
+ Reasons for the change of the name of this distribution and module
+ Migration strategy
Where to find:
--------------
You can download this module directly from the author's web site, where you
will also find my other modules and a couple of logos illustrating what the
modules do:
http://www.engelschall.com/u/sb/download/
You should also be able to find this module on any CPAN ftp site (CPAN =
"Comprehensive Perl Archive Network"), where the file "Bit-Vector-4.2.tar.gz"
should be found in any of the following directories:
.../CPAN/authors/id/STBEY/
.../CPAN/modules/by-category/06_Data_Type_Utilities/Bit/
.../CPAN/modules/by-module/Bit/
To find a CPAN ftp site, you can either direct your web browser to
http://www.perl.com/CPAN/modules/by-module/Bit/Bit-Vector-4.2.tar.gz
(which will automatically redirect you to a CPAN ftp server near you) or
look into "The Perl 5 Module List" by Tim Bunce and Andreas Koenig either
on USENET in the "comp.lang.perl.modules" newsgroup or at
http://www.perl.com/CPAN/modules/00modlist.long.html
Prerequisites:
--------------
Perl version 5.000 or higher, a C compiler capable of the ANSI C standard (!)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
New features in version 4.2:
----------------------------
Two new methods are available in the "Bit::Vector" and the
"Set::IntegerRange" module: "is_empty()" and "is_full".
These methods test wether ALL bits in the given bit vector
are cleared or set.
What does it do:
----------------
The base class of this distribution, "Bit::Vector", allows you to create bit
vectors and sets of arbitrary size (only limited by the size of a machine
word and available memory on your system) with indices (= elements) in the
range from zero to some positive integer, to dynamically change the size of
such bit vectors or sets and to perform a broad range of basic operations on
them, like
- adding or removing elements (setting and clearing single bits),
- testing the presence of a certain element (testing a single bit),
- setting or clearing contiguous ranges of bits,
- detecting contiguous ranges of set bits,
- copying bit vectors,
- converting a bit vector into either a compact (hexadecimal) or a
human-readable string representation (allowing you to store bit
vectors in a file, for instance),
- reading in the contents of a bit vector from a string,
- comparing two bit vectors for equality and lexical order,
- performing bitwise shift and rotation operations,
- computing the union, intersection, difference, symmetric difference
or complement of sets,
- testing two sets for equality or inclusion (subset relationship),
- computing the minimum, the maximum and the norm (number of elements)
of a set,
and more.
Note also that it is very easy to implement sets of arbitrary intervals of
integers using this module (negative indices are no obstacle), despite the
fact that only intervals of positive integers (from zero to some positive
integer) are supported directly.
Please refer to the "Set::IntegerRange" module (also contained in this
distribution) and its man page to see how this can be done!
The "Bit::Vector" module is mainly intended for mathematical or algorithmical
computations. There are also a number of efficient algorithms that rely on
sets (and bit vectors).
An example of such an efficient algorithm (which uses a different
representation for sets, however, not bit vectors) is Kruskal's
algorithm for minimal spanning trees in graphs.
(See the module "Graph::Kruskal" and its man page in this distribution.)
Another famous algorithm using bit vectors is the "Sieve of Erathostenes"
for calculating prime numbers, which is included here as a demo program
(see the file "primes.pl" in this distribution).
An important field of application is the computation of "first", "follow"
and "look-ahead" character sets for the construction of LL, SLR, LR and LALR
parsers for compilers (or a compiler-compiler, like "yacc", for instance).
(That's what the C library in this package was initially written for.)
(See Aho, Hopcroft, Ullman, "The Design and Analysis of Computer Algorithms"
for an excellent book on efficient algorithms and the famous "Dragon Book"
on how to build compilers by Aho, Sethi, Ullman.)
Therefore, this module is primarily designed for efficiency, which is the
reason why most of its methods are implemented in C.
To increase execution speed, the module doesn't use bytes as its basic storage
unit, it rather uses machine words, assuming that a machine word is the most
efficiently handled size of all scalar types on any machine (that's what the
ANSI C standard proposes and assumes anyway).
In order to achieve this, it automatically determines the number of bits
in a machine word on your system and then adjusts its internal configuration
constants accordingly.
The greater the size of this basic storage unit, the better the complexity
(= execution speed) of the methods in this module (but also the greater the
average waste of unused bits in the last word).
Note that the C library of this package ("BitVector.c") is designed in such
a way that it can be used independently from Perl and this Perl extension
module. (!)
For this, you can use the file "BitVector.o" exactly as it is produced when
building this module! It contains no references to Perl, and it doesn't need
any Perl header files in order to compile. (It only needs "Definitions.h" and
some system header files.)
Note however that this C library does not perform any bounds checking
whatsoever! (This is your application's duty!)
(See the respective explanation in the file "BitVector.c" for more details
and the file "Vector.xs" for an example of how this can be done!)
In this module, all bounds and type checking (which should be absolutely
fool-proof, BTW!) is done in the XSUB routines (in C).
For more details about the modules in this distribution, please refer to
their respective man pages!
New features in version 4.1:
----------------------------
1) In the "Bit::Vector" module:
a) There are two new methods called "Move_Left()" and "Move_Right()"
for shifting a bit vector by more than one bit at a time.
These methods are far more efficient than calling "shift_left()" or
"shift_right()" the desired number of times.
b) BEWARE that the semantics of the overloaded operators "<<" and ">>"
has been changed accordingly:
These operators now use "Move_Left()" and "Move_Right()" internally
to produce the usual behaviour for these two operators, i.e.,
$vector << 5
$vector >> 5
moves all bits up/down by 5 places (inserting 5 zero bits at the
right/left end), respectively.
c) Two new methods named "increment()" and "decrement()" have been added
which increment/decrement a given bit vector as though it was one large
(unsigned) integer in binary representation.
d) BEWARE that the semantics of the overloaded operators "++" and "--"
has been changed accordingly: Whereas in previous versions, "++"
was the same as setting bit #1 to the "on" state and "--" was the
same as setting bit #1 to the "off" state, these two operators now
perform a true increment and decrement operation on the given bit
vector, which - by the way - can be used in its pre-increment and
post-increment or pre-decrement and post-decrement form as usual!
2) In the "Set::IntegerRange" module:
a) A "Resize()" method was added which allows you to change the size of
an existing set while preserving as many bits (i.e., elements) of the
old set as will fit into the new set.
b) The methods "Interval_Scan_inc" and "Interval_Scan_dec" are now also
available in the "Set::IntegerRange" module.
c) A method "BitVector" is now available which allows you to call any of
the methods of the "Bit::Vector" class for the underlying bit vector
which contains your set. Use wisely and with precaution!
3) In general:
A complexity analysis has been added to this distribution that shows
the time complexity of the functions implemented in the C library which
is the core of the "Bit::Vector" module. See the file "COMPLEXITY" in
this distribution for more details.
New features in version 4.0:
----------------------------
Flip
$vector->Flip();
Interval_Scan_inc
while (($min,$max) = $vector->Interval_Scan_inc($start))
Interval_Scan_dec
while (($min,$max) = $vector->Interval_Scan_dec($start))
rotate_left
$carry_out = $vector->rotate_left();
rotate_right
$carry_out = $vector->rotate_right();
shift_left
$carry_out = $vector->shift_left($carry_in);
shift_right
$carry_out = $vector->shift_right($carry_in);
to_String
$string = $vector->to_String(); # e.g., "A08A28AC"
from_string
$ok = $vector->from_string($string);
Multiplication
$matrix1->Multiplication($rows1,$cols1,
$matrix2,$rows2,$cols2,
$matrix3,$rows3,$cols3);
Closure
$matrix->Closure($rows,$cols);
Shadow
$other_vector = $some_vector->Shadow();
Clone
$twin_vector = $some_vector->Clone();
new_from_String
eval { $vector = Bit::Vector->new_from_String($string); };
to_ASCII
$string = $vector->to_ASCII(); # e.g., "2,3,5-7,11,13-19"
from_ASCII
eval { $vector->from_ASCII($string); };
Emptyness
if ($vector) # if not empty
if (! $vector) # if empty
unless ($vector) # if empty
# "$index" is a number or a Perl scalar variable containing a
# number which represents the set containing only that element:
Equality
if ($vector1 == $vector2)
if ($vector1 != $vector2)
if ($vector == $index)
if ($vector != $index)
Lexical Comparison
$cmp = $vector1 cmp $vector2;
if ($vector1 lt $vector2)
if ($vector1 le $vector2)
if ($vector1 gt $vector2)
if ($vector1 ge $vector2)
if ($vector1 eq $vector2)
if ($vector1 ne $vector2)
$cmp = $vector cmp $index;
if ($vector lt $index)
if ($vector le $index)
if ($vector gt $index)
if ($vector ge $index)
if ($vector eq $index)
if ($vector ne $index)
Shift Register
$carry_out = $vector << $carry_in;
$carry_out = $vector >> $carry_in;
$carry_out = $carry_in >> $vector;
$vector <<= $carry_in;
$vector >>= $carry_in;
Rotate Register
$carry_out = $vector << $vector->bit_test($vector->Size()-1);
$carry_out = $vector >> $vector->bit_test(0);
$carry_out = $vector->bit_test(0) >> $vector;
$vector <<= $vector->bit_test($vector->Size()-1);
$vector >>= $vector->bit_test(0);
String Conversion
$string = "$vector";
print "\$vector = '$vector'\n";
Union
$set1 = $set2 + $set3;
$set1 += $set2;
$set1 = $set2 | $set3;
$set1 |= $set2;
$vector1 = $vector2 + $index;
$vector += $index;
$vector1 = $vector2 | $index;
$vector |= $index;
Intersection
$set1 = $set2 * $set3;
$set1 *= $set2;
$set1 = $set2 & $set3;
$set1 &= $set2;
$vector1 = $vector2 * $index;
$vector *= $index;
$vector1 = $vector2 & $index;
$vector &= $index;
Difference
$set1 = $set2 - $set3;
$set1 -= $set2;
$set1 = $set2 - $set1;
$vector1 = $vector2 - $index;
$vector1 = $index - $vector2;
$vector -= $index;
ExclusiveOr
$set1 = $set2 ^ $set3;
$set1 ^= $set2;
$vector1 = $vector2 ^ $index;
$vector ^= $index;
Complement
$set1 = -$set2;
$set1 = ~$set2;
$set = -$set;
$set = ~$set;
Subset Relationship
if ($set1 <= $set2)
True Subset Relationship
if ($set1 < $set2)
Superset Relationship
if ($set1 >= $set2)
True Superset Relationship
if ($set1 > $set2)
Norm
$norm = abs($set);
This distribution contains:
---------------------------
* a "BitVector" C library (can be used stand-alone!)
(files "Definitions.h", "BitVector.h" and "BitVector.c")
+ efficient (fast) handling of bit vectors and sets of
integers (and more)
+ determines the size of a machine word on your system
and automatically configures itself accordingly for
maximum speed of execution
* a "Bit::Vector" base class
(files "Vector.pm", "Vector.xs", "typemap", "Definitions.h",
"BitVector.h" and "BitVector.c")
+ efficient (fast) object-oriented methods for handling
bit vectors and sets of integers (intervals from zero
to some positive integer)
+ methods for converting bit vectors in strings and
vice-versa (supports "newsrc" style sets)
+ overloaded arithmetic and relational operators for
maximum comfort
* a "Set::IntegerFast" wrapper module
(file "lib/Set/IntegerFast.pm")
+ assures backward compatibility with previous versions
* a "Set::IntegerRange" application module
(file "lib/Set/IntegerRange.pm")
+ object-oriented methods for handling sets of integers
(arbitrary intervals)
+ overloaded arithmetic and relational operators for
maximum comfort
+ methods for converting sets in strings and
vice-versa
* a "Math::MatrixBool" application module
(file "lib/Math/MatrixBool.pm")
+ object-oriented methods for handling matrices of booleans
(Boolean Algebra)
+ overloaded arithmetic and relational operators for
maximum comfort
+ computes reflexive transitive closure using Kleene's
algorithm (essential for solving path-problem in graphs)
+ methods for converting matrices in strings and
vice-versa
+ matrix multiplication and closure are actually carried out
in the "Bit::Vector" module for maximum speed of execution
Related modules (NOT derived from the "Bit::Vector" base class):
* "Math::MatrixReal"
(file "lib/Math/MatrixReal.pm")
+ object-oriented methods for handling matrices of reals
+ overloaded arithmetic and relational operators for
maximum comfort
+ allows to solve linear equation systems using an
efficient algorithm known as "LR decomposition"
and several approximative (iterative) methods
+ features an implementation of Kleene's algorithm to
compute the minimal costs for all paths in a graph
with weighted edges
+ methods for converting matrices in strings and
vice-versa
* "DFA::Kleene"
(file "lib/DFA/Kleene.pm")
+ another implementation of Kleene's algorithm to compute
the language accepted by a Deterministic Finite Automaton
* "Math::Kleene"
(file "lib/Math/Kleene.pod")
+ a man page giving a brief introduction into the theory
behind Kleene's algorithm
* "Graph::Kruskal"
(file "lib/Graph/Kruskal.pm")
+ implementation of Kruskal's efficient algorithm
for Minimal Spanning Trees in graphs O( n * ld(n) )
+ example of an efficient algorithm relying heavily on sets
(with a different representation, though, not bit vectors)
Reasons for the change of the name of this distribution and module:
-------------------------------------------------------------------
Version 4.0 was a complete rewrite of the whole "Set::Integerfast" package,
during which a huge number of new methods have been added to this module
(see also above!), with also large additions to its associated application
modules.
The module has been renamed to "Bit::Vector" since it now not only offers
methods for the handling of sets, but also for other applications based
on bit vectors, like boolean matrices and shift registers.
Having multiple modules using C code via the XSUB interface in one
distribution (the "Set::IntegerFast" and the "Math::MatrixBool" modules)
made things prohibitively costly to maintain.
A third such module was on the verge to arrive, one to implement bit
shift registers of arbitrary length.
Instead of duplicating the basic code to create, handle and destroy
bit vectors (which would have been the same for all three modules!),
everything was assembled into one unique C library.
The name of "Set::IntegerFast" simply didn't fit this grown library
anymore, a more general name was needed.
"Bit::Vector" seems to be the most appropriate for it.
Migration strategy:
-------------------
You will need to apply the following changes to your existing
applications that use the "Set::IntegerFast" module (use
interactive global text search & replace for this):
"Set::IntegerFast" --> "Bit::Vector" (required)
"Empty_Interval(" --> "Interval_Empty(" (recommended)
"Fill_Interval(" --> "Interval_Fill(" (recommended)
"Flip_Interval(" --> "Interval_Flip(" (recommended)
"Delete(" --> "Bit_Off(" (recommended)
"Insert(" --> "Bit_On(" (recommended)
"flip(" --> "bit_flip(" (recommended)
"in(" --> "bit_test(" (recommended)
"in(" --> "contains(" (alternative)
"inclusion(" --> "subset(" (recommended)
You should also apply these very changes to all of your applications
using the "Set::IntegerRange" and the "Math::MatrixBool" module.
This is because the same changes and additions as in the new "Bit::Vector"
module have also been applied to these two modules, including (some of)
the new methods and (all of) the new method names and aliases!
The old method names on the left of the table above are still supported,
but deprecated from now on (this means that they could disappear at some
day in the future).
The module "Set::IntegerFast" still exists, but it is maintained only to
assure backward compatibility. It might also go sometime in the future.
Therefore, it is strongly recommended that you migrate your application(s).
-----------------------------------------------------------------------------
If you have any questions or need any assistance, or should you have some
comments to make, suggestions, compliments or donations ;-) to give, then
please don't hesitate to send me some e-mail!
I hope you will find this module benefitful!
Share and enjoy!
Yours,
--
Steffen Beyer <sb@sdm.de> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
>> Unsolicited commercial email goes directly to /dev/null <<
------------------------------
Date: Tue, 22 Jul 1997 23:54:17 GMT
From: dudexx@us.oracles.coms (Dude)
Subject: Any PL/SQL packages/functions with perl-type functions available?
Message-Id: <5r3hep$cd0$1@inet16.us.oracle.com>
Anyone know of freely available PL/SQL packages with perl-type functions for
pattern recognition and substitution? The built-in '%' and '.' just isn't
capable for what I need to do and I'd rather not code from scratch.
Please reply to ---igum@us.oracle.com without the leading ---'s. Thanks.
------------------------------
Date: Sun, 20 Jul 1997 23:00:53 -0700
From: Benjamin Kyan <bkyan@mindcast.com>
Subject: Benchmarking Perl Compile Times
Message-Id: <33D2FB15.84CED1DE@mindcast.com>
Hi,
Anyone know of a *quick* way to benchmark a script, including
compile times? I think the Benchmark module ignores compile
times...
I've a CGI script that's getting pretty long, and am looking for
a mean to benchmark it to see how much different using the
SelfLoader module makes...
Thanks!
--
Best Regards,
Benjamin Kyan
bkyan@mindcast.com
========================== ======================== ==============
Clickstream Communications 9101 W. Sahara, #105-183 T 404.685.0852
(website) www.mindcast.com Las Vegas, Nevada 89117 F 404.685.0853
========================== ======================== ==============
------------------------------
Date: 23 Jul 1997 16:12:15 GMT
From: rdorich@allegro.cs.tufts.edu (Roberto L. Dorich)
Subject: Re: Can't match =
Message-Id: <5r5agv$de7$1@d2.tufts.edu>
Thanks to all that responded... the problem was the fact that I
was using \b instead of \s. It works dandy now. I wonder why
the = sign was mocking everuyting up though.
Thanks,
Roberto
Roberto L. Dorich (rdorich@allegro.cs.tufts.edu) wrote:
: Hi netters,
:
: I'm trying to process all the lines in a file with the following format:
:
: SOME_ID = some_num,
: ^--- the , is optional.
:
: So I do:
:
: while ($line = <file>)
: {
: next if ($line =~ /\w+\b*=/);
:
: process($line);
: }
:
: Now the problem is that none of the lines get processed! If I get rid of
: the '=' in the regexp then I do process the lines, but get a lot of
: unwanted lines as well. Why is the '=' being so annoying?
:
--
Roberto Dorich o SKI rdorich@jade.tufts.edu
Electrical Engineering /= EXTREME rdorich@athena.mit.edu
Tufts University __/__, uucp: roberto@kastle.ext.tufts.edu
----------------------------------------------------------------------------
------------------------------
Date: 21 Jul 1997 02:52:15 GMT
From: "Don Botten" <donb@dllb.com>
Subject: cgi for form based uploads
Message-Id: <01bc9581$d03b5380$0100007f@localhost>
I have the patch for Explorer 3.02 for browser form based file uploads and
it looks good. I need help on the perl cgi program to receive the upload.
Does anyone have an example of the perl (cgi) script to accept and locate
the file on the server?
--
*********************************************
Don Botten donb@dllb.com
http://www.dllb.com
*********************************************
------------------------------
Date: 20 Jul 1997 14:55:50 GMT
From: "Ortolani Luca" <lucas@macronet.it>
Subject: Re: cgi perl
Message-Id: <01bc951c$c3447e00$a4a9f7c2@luca.macronet.it>
Clay Irving <clay@panix.com> scritto nell'articolo
<5qrhuv$mi4@panix.com>...
> In <5qqs40$e7i$1@news.flashnet.it> "Luca" <p.luca@macronet.it> writes:
>
> >Hi,
> >I'm looking for a script ables to change my user's password.
> >I thought to the "open" command for a pipe to the passwd, with the next
> >simple script...
>
> This will probably tell you why:
>
> >open ( PASWD,"|passwd user");
> open PASWD, "|passwd user" or die "Ack! Can't open passwd: $!\n";
>
> >print PASWD "password\n";
> >print PASWD "password\n";
> >close (PASWD);
>
> >but it doesn't works !!! WHY??!!!
>
> Because user 'nobody' can't change user 'user' password?
>
but I run mmy script as root user is not that the problem
the problem is that the two command print don't work with the pipe!!
------------------------------
Date: Mon, 21 Jul 1997 08:35:53 -0400
From: Brandon Golm <brandon@mrgolm.com>
Subject: Re: cgi, server side include help
Message-Id: <33D357A9.675F7304@mrgolm.com>
Raj Kumar wrote:
>
> Hello
>
> I am trying to get the time stamp displayed on my web page,
> but it isn't working.
>
> I have renamed my html file to index.shtml
> and then I put the following in my file:
>
> <!-- #config timefmt = "%I:%M:%S" -->
>
> but it doesn't work.
> Any suggestions or comments.
This is a dumb question but do you have your web server set for SSI?
It has be my experience that I had to turn it on or config it for SSI.
------------------------------
Date: 20 Jul 1997 09:03:00 -0600
From: James LewisMoss <dres@dimensional.com>
Subject: Re: Creating a file, only if the file handle is 'used'
Message-Id: <hhn2nh7om3.fsf@dres.elam.org>
>>>>> On Thu, 17 Jul 1997 18:47:14 -0700, Andrew Dear <dear_andrew@jpmorgan.com> said:
Andrew> I want to redefine STDERR to a file eg.
Andrew> open STDERR, ">my_file";
Andrew> However I would like to avoid any overhead, and avoid
Andrew> actually creating the empty file "my_file" if STDERR is not
Andrew> used.
Andrew> Does anybody know if this is possible?
Sure. Make sure that anything writing to STDERR uses a specific print
function (stderr_print maybe). First time that function is run have
it do the open.
Jim
---------
my $is_stderr_open = 0;
sub stderr_print {
if(! $is_stderr_open) {
open STDERR, "> my_file";
$is_stderr_open = 1;
}
print STDERR @_;
}
--
@James LewisMoss <dres@dimensional.com> | Blessed Be!
@ http://www.dimensional.com/~dres | Linux is cool!
@"Argue for your limitations and sure enough, they're yours." Bach
------------------------------
Date: 23 Jul 1997 17:51:58 GMT
From: murarka@sfu.ca (Neeraj Murarka)
Subject: Displaying 1 html file in cgi, then second
Message-Id: <5r5gbu$4bb$1@morgoth.sfu.ca>
Hi. I am trying to wrote a Perl script that basically displays an html
file that is actually generated by print statements in the perl script,
and then, after having displayed the html and having done some searches,
displays another html file that is also dynamically generated. Is there a
way to do this? I tried to simply display the first, and then the second
html file, but the second one never shows up! Any help will be most
appreciated. Thanks.
------------------------------
Date: 20 Jul 1997 09:37:17 GMT
From: preed@psd.k12.co.us (J. Paul Reed)
Subject: flocking on HP-UX
Message-Id: <5qsm8d$ag8$1@mercury.psd.k12.co.us>
I looked all around DejaNews and in Programming Perl, and it didn't help,
so I come to you, the perl wizards of c.l.p.m...
I'm using perl 5.003 on HP-UX 10.10 and I need to flock a file. But I
don't even know if flock is supported on HP-UX (I would be surprised if it
weren't) and I don't know the "flock" numbers (as everything else in HP-UX
is weird, I wouldn't expect those to be the same ;)
Anywho, this is my block of code; I was wondering if someone could help me
with it:
open(OUT, ">>/tmp/file.txt") || die "Couldn't open file";
flock OUT, 2;
until(print OUT "Hello!\n";) {
sleep 2;
}
flock OUT, 8;
close(OUT);
Now, I know that until statement doesn't work, since perl -d barfed all
over it; but essentially, since the file handle is open for such a short
amount of time, I want the script to keep retrying until the print
succeeds; is there anyway to trap the success value of the print statement
and have it keep trying until another process (using the exact same code
block) unflocks it?
Also, beyond that until statement, will this keep my file safe? :)
Thanks for the help!
Later,
Paul
-------------------------------------------------------------------
J. Paul Reed preed@psd.k12.co.us || paul@619pro.com
Such a noble creature; a quality we sometimes lack...
--Borg Queen; Star Trek: First Contact
Geek Code and various other frivolities at www.psd.k12.co.us/~preed
------------------------------
Date: Tue, 22 Jul 1997 20:39:20 +0000
From: Mark McDonald <webmaster@restaurantdigest.com>
Subject: Formatting Text 101! HELP!!!
Message-Id: <33D51A75.6A57@restaurantdigest.com>
Does anyone know how to search out a hard return from a textarea?
I am tring to pull out a new line (that was meant to be a <P>) in a
posting...
------------------------------
Date: 20 Jul 1997 20:23:24 GMT
From: Grey Land <gland@ccs.neu.edu>
Subject: hashes and <img>
Message-Id: <5qts3t$1bl$1@camelot.ccs.neu.edu>
Ok let me kee this as simple and as short as possible. I wrote a scipt that strips a web page of the sports standings... I want to search the file (not the problem) and find each team. When it locates the teams I would like it to add the "<img src="..."> with the team name in the order that it finds them at the bottom of the document. I built a hash team => picture, with all of the possibilities, but have no idea how to finish the implementation. Any help would be appreciated.
Thanks in advance
Greg
------------------------------
Date: Sun, 20 Jul 1997 13:57:09 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Grey Land <gland@ccs.neu.edu>
Subject: Re: hashes and <img>
Message-Id: <Pine.GSO.3.96.970720135511.29697H-100000@kelly.teleport.com>
On 20 Jul 1997, Grey Land wrote:
> When it locates the teams I would like it to add the "<img src="...">
> with the team name in the order that it finds them at the bottom of the
> document.
Try a for loop, and print (or push) each one as you find it. If that's not
what you're looking for, and if you still can't find it in the docs,
please post again with some source code showing what's going wrong. Hope
this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 20 Jul 1997 21:30:44 GMT
From: Greg Land <gland@ccs.neu.edu>
Subject: Re: hashes and <img>
Message-Id: <5qu024$3i8$1@camelot.ccs.neu.edu>
Tom Phoenix <rootbeer@teleport.com> wrote:
: On 20 Jul 1997, Grey Land wrote:
: > When it locates the teams I would like it to add the "<img src="...">
: > with the team name in the order that it finds them at the bottom of the
: > document.
: Try a for loop, and print (or push) each one as you find it. If that's not
: what you're looking for, and if you still can't find it in the docs,
: please post again with some source code showing what's going wrong. Hope
: this helps!
: --
: Tom Phoenix http://www.teleport.com/~rootbeer/
: rootbeer@teleport.com PGP Skribu al mi per Esperanto!
: Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
OK... thanks for the suggestions, but I am still a little to new for this adding at the end of the document stuff. So, here is a piece of the code... see if any of you gurus can make some sense of it.
The script generates this page...
<HTML>
<HEAD>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H2><FONT size=+3>Final
1996-97 standings </FONT></H2>
<H3><FONT size=+2>Eastern Conference</FONT></H3>
<PRE>
<B> W L PCT GB HOME ROAD DIV CONF </B>
Z-CHICAGO 69 13 .841 - 39-2 30-11 24-4 44-10
Y-MIAMI 61 21 .744 8 29-12 32-9 16-8 40-14
X-NEW YORK 57 25 .695 12 31-10 26-15 19-6 38-16
X-ATLANTA 56 26 .683 13 36-5 20-21 17-11 34-20
....
</body>
</html>
So now I need a script that opens this file(call it standings) and find "CHICAGO" then "MIAMI" etc... and add the tag <img src="/home/gland/.www/nba/chicago.gif"> <img src="/home/gland/.www/nba/miami.gif"> at the bottom of the file. if at all possible before the </body> and </html> tags.
Thanks in advance
Greg
------------------------------
Date: 23 Jul 1997 16:41:00 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: how to reverse substitution order ?
Message-Id: <5r64qc$9ie@web.azstarnet.com>
In article <33D5C9F1.41C6@geocities.com>,
Proux Jean-Philippe <proux@geocities.com> wrote:
>if I use:
>$chemin =~ s/\/\w*\/\.\.//g;
>$chemin =~ s/\.\///g;
It might work better for you to split the path name up, then deal with
each component of the path in turn. This isn't fully tested, but it
might get you started.
#!/usr/bin/perl -w
# in my test, d is a symbolic link to '/usr/local/bin'
my $chemin = 'a/b/./c/d/../e';
my @path = ();
# split the input path on each '/'
foreach (split /\//, $chemin) {
$_ eq '..' and do {
# if we're going up a directory, worry about symbolic links
my $sym;
if (defined($sym = readlink join '/', @path)) {
# the current path is a symbolic link, so set the current
# path to the real path
@path = split /\//, $sym;
}
# only go back a component if there exists a non-'..' component
if (@path and $path[$#path] ne '..') { pop @path; next; }
};
# skip '.' components altogether
$_ eq '.' and next;
# just put normal components onto the end of the stack
push @path, $_;
}
$chemin = join '/', @path;
# this prints out (/usr/local/e) in my test
print "($chemin)\n";
Enjoy,
Tim
------------------------------
Date: 23 Jul 1997 22:16:07 GMT
From: "Jennifer & Nathan Hammontree" <agnet@3rivers.net>
Subject: How to set precision
Message-Id: <01bc97b4$805b3620$bdb788d0@Pagnet.3rivers.net>
I can't seem to find a function to set decimal precessions. Is there a
Perl function for this, or does someone have one I can use?
Please reply via e-mail: agnet@3rivers.net
Thanks in advance,
NH
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
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 761
*************************************