[7124] in Perl-Users-Digest
Perl-Users Digest, Issue: 749 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 21 01:07:13 1997
Date: Sun, 20 Jul 97 22:01:07 -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 Sun, 20 Jul 1997 Volume: 8 Number: 749
Today's topics:
Re: $1 vs \1 <rootbeer@teleport.com>
Re: //o and backreferences <rootbeer@teleport.com>
ANNOUNCE: Net::LDAPapi v1.21 Available (Clayton Donley)
Re: cgi perl <dev@sgi.net>
Re: cgi perl (Clay Irving)
Re: cgi perl <lucas@macronet.it>
Re: cgi perl <rootbeer@teleport.com>
Re: Character Limitation Sub-Routine (Clay Irving)
CORBA and Perl <peh@nbit.se>
Re: date conversion (from-to seconds) (Clay Irving)
Re: date conversion (from-to seconds) (Albert W. Dorrington)
Re: DESPARATLY NEED CGI INSTALLER (Even Holen)
DON"T Pay For $ex Site Entry 0987263268@compuserve.com
Re: Error in CGI.pm (odd number of elements in hash) (Christian Roy)
Re: File locking problem <rootbeer@teleport.com>
Re: flocking on HP-UX <rootbeer@teleport.com>
getting rid of decimal places in output <erbeck@web-design.net>
Re: getting rid of decimal places in output <rootbeer@teleport.com>
Re: getting rid of decimal places in output (Tad McClellan)
Re: hashes and <img> (Tim Smith)
Re: How to embed a gif source in perl script ?? <jbokma@caiw.nl>
Re: How to s/TARGET_TEXT/&Subroutine;/gi; <rootbeer@teleport.com>
Implicit passing to CORE:: functions does not work <axel@ramge.de>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 19 Jul 1997 08:04:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Stephen P. Schaefer" <schae006@nelle.mc.duke.edu>
Subject: Re: $1 vs \1
Message-Id: <Pine.GSO.3.96.970719075846.254C-100000@kelly.teleport.com>
On Fri, 18 Jul 1997, Stephen P. Schaefer wrote:
> Just to confuse things even more deeply, look what I found:
>
> perl -de 1
> DB<1> $foo='<a name="toc_chapter_1">Chapter 1</a>'."\n"
>
> DB<2> p ($foo=~/\<a name\=\"toc_chapter_([0-9]+)\"\>Chapter $1\</)
And that prints nothing because the match did not succeed. Near the end of
the pattern, you're looking for ">Chapter <", since $1 is empty. It's not
a backreference within that expression. It's a memory from the _previous_
pattern match, if any. (Actually, it's a bit more complicated than that,
but for our purposes, this will suffice.)
Within a pattern, use \1 for the backreference. Outside of a pattern, use
$1 for the memory of what was matched. 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: Sat, 19 Jul 1997 20:32:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Nottingham <mnot@pobox.com>
Subject: Re: //o and backreferences
Message-Id: <Pine.GSO.3.96.970719202423.5095K-100000@kelly.teleport.com>
On Sun, 20 Jul 1997, Mark Nottingham wrote:
> I'm doing a match inside of a loop, and would love to optimise it a bit
> with an 'o' on the end,
That's a worthy goal, but using /o doesn't necessarily optimize anything.
> but I'm using backreferences in the regex, like so
> ( the \16 near the end):
>
> $line =~ /(\S+) (\S+) ([^\[\n]+) \[(\d+)\/(\w+)\/(\d+):(\d+):(\d+):(
> \d+) (\S+)\] "(\S+) (\S+) (\S+)" (\S+) (\S+)(?: ("?)(\S+)\16 "(.+)"|(\-))?/
>
> Can I safely stick an 'o' here, or will it then lock that reference as the
> match of the first loop?
You may use /o here, but it will make no difference at all. :-) It is
useless in that expression.
What would make that expression run faster would be to use an anchor at
the beginning, if it's really to match at the beginning of the line. That
way, if it fails, it will be able to fail quickly, rather than bumping
along to the next character position and trying again. (An anchor at the
end might also be good, depending upon your needs.)
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 15:51:23 GMT
From: donley@courier.cig.mcel.mot.com (Clayton Donley)
Subject: ANNOUNCE: Net::LDAPapi v1.21 Available
Message-Id: <5qtc5r$1np$1@nadine.teleport.com>
Keywords: perl5, perl, LDAP
Hello Everyone,
I have just submitted the following module to PAUSE. It is also available
on my home page: http://www.geocities.com/SiliconValley/Bay/2131/
=======================================================================
Net::LDAPapi Module v1.21 for PERL5
Clayton Donley, <donley@cig.mcel.mot.com>
=======================================================================
COPYRIGHT
=========
Copyright (c) 1997 Clayton Donley. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
INTRODUCTION
============
This module acts as a Perl5 interface to the LDAP C Development Kits from
University of Michigan and Netscape. The module itself is written completely
in C. Full documentation is included, as are commented example scripts.
REQUIREMENTS
============
This module requires Perl5, a C compiler, and the LDAP libraries and include
files from either of the following:
Netscape LDAP C SDK (used by author):
http://developer.netscape.com/one/directory/downloads.html
University of Michigan LDAP-3.3:
ftp://terminator.rs.itd.umich.edu/ldap/ldap-3.3.tar.Z
It may also work with other LDAP development kits. Please let me know if
you successfully use it with other kits.
INSTALLATION
============
After un-compressing/archiving the file, simply type the following:
% perl Makefile.PL
[ Answer questions about include/library locations, select
University of Michigan if you are not using Netscape's SDK ]
% make
Now edit the file 'test.pl' to reflect your LDAP server and a valid CN.
% make test
You should see 8 successful tests related to binding and searching. You
will need to use the examples to test modifying the directory.
Now install the module with:
% make install
You should now be able to 'use Net::LDAPapi' in your scripts to take
advantage of this module.
EXAMPLES
========
Additional example scripts can also be found in the distribution under the
'examples' directory. These include:
o ldapwalk.pl - This script demonstrates the use of Asynchronous LDAP
calls to return all the attributes and values for entries matching
a filter specified on the command line. Simply change the variables
at the start of the file to match your environment.
o testwrite.pl - This script demonstrates using synchronous Add, Modify,
and Delete calls to manage an LDAP server. You need update access
to an LDAP server to run this example. Once again, simply change
the variables at the top of the file.
o www-ldap.pl - This script uses both this module and the CGI.pm
module available on the Internet. It allows users to authenticate
and modify their own information. You can easily customize this
program, or learn from it and write your own CGIs. The BIND
and WEB_AUTHENTICATE subroutines would be especially useful in
incorporating LDAP authentication into your own CGI scripts, even
if the script has nothing to do with LDAP otherwise.
PLATFORMS SUPPORTED
===================
Solaris 2.5 and HPUX 10.20 are tested and known to work. Anyone using this
on other platforms, please send me email with your results.
FEEDBACK
========
I'm looking for any feedback regarding this module or how you use this
module. If you've got other good examples or such, please send them my
way and I'll include them.
UPDATES
=======
Updates will be uploaded to PAUSE and posted to my personal home page at:
http://www.geocities.com/SiliconValley/Bay/2131/
BUGS
====
ldap_init doesn't seem to work with University of Michigan's API. Always
returns unable to connect to server errors. Use ldap_open instead for now.
Modifying Binary Values is not supported. Expect this in the next
non-maintenance release.
AUTHOR
======
Clayton Donley, Expatriate Sr. Network Systems Administrator
Motorola (China) Electronics, Ltd.
Beijing, China
email: donley@cig.mcel.mot.com
------------------------------
Date: Sat, 19 Jul 1997 15:51:31 -0400
From: Devin Anderson <dev@sgi.net>
Subject: Re: cgi perl
Message-Id: <33D11AC3.124B@sgi.net>
Luca wrote:
>
> 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...
>
> open ( PASWD,"|passwd user");
> print PASWD "password\n";
> print PASWD "password\n";
> close (PASWD);
>
> but it doesn't works !!! WHY??!!!
>
> Is Ther anybody that can help me!!
That kind of pipe only works if the command is programmed to accept it.
For example, you can't pipe to PGP unless you give it the -f flag. As
much as I like perl, in this case I might to for the expect script
(becasue expect will print to STDIN).
Hope this helps!
---
Devin P. Anderson
Webmaster, Systems Administrator
Stargate Industries, Inc.
http://www.sgi.net/
Phone: 412.930.STAR (7827) ext. 241
F a x: 412.930.7110
This should clear up any confusion:
anti-match - v. To reverse the match process. Show all patterns that
*DON'T* match.
-----PGP PUBLIC KEY AVAILABLE-----
------------------------------
Date: 19 Jul 1997 19:17:51 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: cgi perl
Message-Id: <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?
>Is Ther anybody that can help me!!
Probably.
--
Clay Irving <clay@panix.com> http://www.panix.com/~clay/
------------------------------
Date: 20 Jul 1997 14:55:51 GMT
From: "Ortolani Luca" <lucas@macronet.it>
Subject: Re: cgi perl
Message-Id: <01bc951d$965563e0$a4a9f7c2@luca.macronet.it>
> > print PASWD "password\n";
> > print PASWD "password\n";
> > close (PASWD);
> >
> > but it doesn't works !!! WHY??!!!
> >
> > Is Ther anybody that can help me!!
>
> That kind of pipe only works if the command is programmed to accept it.
> For example, you can't pipe to PGP unless you give it the -f flag. As
> much as I like perl, in this case I might to for the expect script
> (becasue expect will print to STDIN).
Ok! I undertand ! Thank you, but how I can to know wich command accept
this?
and in this case, how can I do to write a script ables to change a user
password?
I can't use any kind of pipe for a linux command?
Excuse me for english but I'm italian and I don't speak it very well
Thank you again!!
------------------------------
Date: Sun, 20 Jul 1997 08:46:59 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ortolani Luca <lucas@macronet.it>
Subject: Re: cgi perl
Message-Id: <Pine.GSO.3.96.970720082817.10215A-100000@kelly.teleport.com>
On 20 Jul 1997, Ortolani Luca wrote:
> how can I do to write a script ables to change a user
> password?
I was going to write out an answer telling how to do it, but I've changed
my mind: The potential security problems are so great that, if you need to
ask, you should really get somebody else to do the job. I apologize if
this sounds harsh, but you really can't afford to have bugs and security
holes in a script which is editing your user database. This is like trying
to build your own bank vault, and that's not a do-it-yourself project
either.
If you'd like to hire a contract programmer who could do this job right, I
could recommend somebody. :-) Or, you can wait until the User::pwent
module is finished. Since that should provide a good and safe interface to
the password database, you'll be able to write a simple program to do what
you want with fewer chances of something going wrong. (I don't know when
that module will be finished, if ever.)
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: 19 Jul 1997 10:16:44 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: Character Limitation Sub-Routine
Message-Id: <5qqi8c$t26@panix.com>
In <33CFA514.6838@npt.com> Don Engelmeyer <done@npt.com> writes:
>Hello,
>I need a sub-routine that counts the number of characters from a user's
>post. Specifically, limiting their post to 200 characters
>when they type in a text area.
>Please Email if you have this or can explain how to do it.
#!/usr/local/bin/perl5.003 -w
$input = "Hello,
I need a sub-routine that counts the number of characters from a user's
post. Specifically, limiting their post to 200 characters
when they type in a text area.
Please Email if you have this or can explain how to do it.";
$words = word_count($input);
print "$words\n";
#-- Word count subroutine -----------------------
sub word_count {
my $string = shift @_;
my $total_words = 0;
$string =~ s/\n/ /g; # remove the newlines
@words = split /\s+/, $string; # split each line into words and put
# the words into an array
$total_words += $#words + 1; # add the words on each line to the
# total - remember the first element of
# an array is 0, so we add 1 to the array
# count
return $total_words;
}
Prints:
42
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: Fri, 18 Jul 1997 11:06:59 +0200
From: Peter Holmstrand <peh@nbit.se>
Subject: CORBA and Perl
Message-Id: <33CF3233.2FA31A0C@nbit.se>
Anyone heard somthing about CORBA and Perl?
Is there a simpel way to use an ORB from a perl program, or du I have to
write an "interface" in another language (C/C++ for instance)?
// Peter
------------------------------
Date: 19 Jul 1997 09:25:52 -0400
From: clay@panix.com (Clay Irving)
Subject: Re: date conversion (from-to seconds)
Message-Id: <5qqf90$mro@panix.com>
In <33CBC2CE.2B5D@crmtraining.com> Marc Belcourt <marc@crmtraining.com> writes:
>Is there a perl library that will convert seconds sinc Jan. 1, 1970 to a
>date format. And visa-versa.
#!/usr/local/bin/perl -w
$seconds_since_epoch = time;
$now = localtime($seconds_since_epoch);
print "$seconds_since_epoch\n";
print "$now\n";
Prints:
869318685
Sat Jul 19 09:24:45 1997
--
Clay Irving See the happy moron,
clay@panix.com He doesn't give a damn,
http://www.panix.com/~clay I wish I were a moron,
My God! Perhaps I am!
------------------------------
Date: 17 Jul 1997 15:53:50 -0500
From: awdorrin@ictest.delcoelect.com (Albert W. Dorrington)
To: marc@crmtraining.com
Subject: Re: date conversion (from-to seconds)
Message-Id: <5qm0ou$dit@ws051eng.ictest.delcoelect.com>
The built in function 'localtime' converts from seconds since 1/1/70 to a
nine element array containing the time:
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
localtime($numsec);
To convert the other way, you can use the library module 'Time::Local'
which contains 'timelocal()'
Straight from Pages 185-6 of the Programming Perl 2nd edition. :-)
- Al
In article <33CBC2CE.2B5D@crmtraining.com>, Marc Belcourt <marc@crmtraining.com> writes:
:> hello all,
:>
:> Is there a perl library that will convert seconds sinc Jan. 1, 1970 to a
:> date format. And visa-versa.
:>
:> Please e-mail me
:>
:> Thank You
:>
:> Marc Belcourt
:> marc@crmtraining.com
--
Al Dorrington awdorrin@ictest.delcoelect.com
Delco Electronics - IC CIM Database & Unix Administrator
Kokomo, Indiana, USA Phone: 765.451.9655
------------------------------
Date: 19 Jul 1997 11:50:29 GMT
From: evenh@ra.pvv.ntnu.no (Even Holen)
Subject: Re: DESPARATLY NEED CGI INSTALLER
Message-Id: <slrn5t1acg.7og.evenh@ra.pvv.ntnu.no>
In article <19970718114701.HAA11048@ladder01.news.aol.com>, Igor3000 wrote:
>i desparately need a cgi installation
And you haven't presented a problem which is suitable for the
comp.lang.perl.misc. You present us with a scripts which seems to do
what you want to be done. And you next step is to get your server to
start this script.
And that is not a perl issue. Try mailing the people in change of your
server. Or ask questions on comp.infosystems.www.authoring.cgi or
something more appropriate...
>Please tell me a nice cgi person will install it for me!!!!!
Contact the people in charge of your webserver!
And as a general idea. If you don't get an answer on your first try when
posting you most likely either posted to the wrong group or you have to
rephrase your question or noone have got an answer to your question.
Either way please do not post the same message more than once...
Regards,
Even Holen
--
<>< Even Holen, evenh@pvv.ntnu.no, http://www.pvv.ntnu.no/~evenh/ :-)
------------------------------
Date: 19 Jul 1997 16:55:22 GMT
From: 0987263268@compuserve.com
Subject: DON"T Pay For $ex Site Entry
Message-Id: <5qqrhq$au3@news1-alterdial.uu.net>
This is a multi-part message in MIME format.
--_-=176
Content-type: text/html; name="Sex~1.htm"
Content-transfer-encoding: base64
PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9JRVRGLy9EVEQgSFRNTC8vRU4iPg0KDQo8aHRt
bD4NCg0KPGhlYWQ+DQo8dGl0bGU+U0VDUkVUIFBBU1NXT1JEIEZPUiBBRFVMVCBTSUdIVFM8
L3RpdGxlPg0KPG1ldGEgbmFtZT0iR0VORVJBVE9SIiBjb250ZW50PSJNaWNyb3NvZnQgRnJv
bnRQYWdlIDEuMSI+DQo8L2hlYWQ+DQoNCjxib2R5IGJnY29sb3I9IiNDMEMwQzAiIHRleHQ9
IiM4MEZGRkYiIGxpbms9IiMwMDAwRkYiIHZsaW5rPSIjMDAwMEZGIiBhbGluaz0iI0ZGMDAw
MCI+DQo8ZGl2IGFsaWduPWNlbnRlcj48Y2VudGVyPg0KPHRhYmxlIGJvcmRlcj01IGNlbGxw
YWRkaW5nPTI+DQo8dHI+PHRkIGFsaWduPWNlbnRlciB3aWR0aD0xMDAlPjxmb250IGNvbG9y
PSIjRkZGRjAwIj48Zm9udCBzaXplPTc+PGI+RlJFRSEgRlJFRSEgRlJFRSE8YnI+DQo8L2I+
PC9mb250PjwvZm9udD48Zm9udCBjb2xvcj0iI0ZGMDAwMCI+PGZvbnQgc2l6ZT01PjxiPlRI
QVQnUyBSSUdIVC4uLiBDT01QTEV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iI0ZGMDA4MCI+PGZvbnQgc2l6ZT03PjxzdHJvbmc+Qk9OVVMhISE8
YnI+DQo8L3N0cm9uZz48L2ZvbnQ+PGZvbnQgc2l6ZT01PjxzdHJvbmc+RlJFRSBYWFggQ2hh
dCBSb29tcyEhITwvc3Ryb25nPjwvZm9udD48L2ZvbnQ+PC9wPg0KPHAgYWxpZ249Y2VudGVy
PjxhIGhyZWY9Imh0dHA6Ly8yMDUuMjE2LjI0OS4xOC9jZ2ktc2hsL2RibWwuZXhlP3RlbXBs
YXRlPS9hcy9zaWdudXAuZGJtJmFtcDtzaXRlPXN0MzUzMjUiPjxmb250IGNvbG9yPSIjODAw
MDgwIj48Zm9udCBzaXplPTY+PHN0cm9uZz5JIFdBTlQgVEhFIFBBU1NXT1JEIE5PVzwvc3Ry
b25nPjwvZm9udD48L2ZvbnQ+PC9hPjwvcD4NCjwvYm9keT4NCg0KPC9odG1sPg0K
--_-=176
------------------------------
Date: Fri, 18 Jul 1997 20:08:10 GMT
From: roychri@total.net (Christian Roy)
Subject: Re: Error in CGI.pm (odd number of elements in hash)
Message-Id: <33cfcbe1.950615361@news.total.net>
On Fri, 18 Jul 1997 17:51:44 GMT, Jeff Etrick <jeffe@fl.ensco.com>
wrote:
>I'm trying to use CGI.pm for a simple form script.
>I keep getting an error in CGI.pm about odd number of elements.
>Anyone have any idea what this means. Where should I start looking?
>
>>> Odd number of elements in hash list at
>>>/usr/tools/gnu/lib/perl5/site_perl/CGI.pm
>>>line 617.
>
>I'm using CGI.pm 2.36
>
I would definitly try to see if your script use a CGI method that
require a hash table but that you call without a hash as the
parameter.
Example :
$myCGIobject->Method($param);
if Method is looking for an hash variable, then it would generate an
error of the kind.
I don't recall seing any method in CGI that accept only hash variables
as the parameter.
Maybe the problem is more complicated.
Are you the only one using the CGI package? If you are not the only
one, try to see if other people have the same problem. If not, then
the problem is definitly in the way you are using the CGI package....
Hope it help...
------------------------------
Date: Sat, 19 Jul 1997 09:57:03 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kenneth Kin Lum <kinlum@wco.com>
Subject: Re: File locking problem
Message-Id: <Pine.GSO.3.96.970719094526.5345A-100000@kelly.teleport.com>
On Sat, 19 Jul 1997, Kenneth Kin Lum wrote:
> if I open a file for *writing* and lock it (with flock(FILE, 2)), and
> another process goes ahead and open it for *reading* and lock it (also
> with flock(FILE, 2)), the reading process will fail immediately in
> getting the lock. How come? Can't a process lock for reading?
>
> I found that the only time the second process gets blocked is when both
> processes are openning the file for write.
If I understand correctly, you're saying that the exclusive lock is only
placed if you had the file open with permission to write to it. This is
the way most (all?) OSes do it, and it's something Perl has no control
over. I think the idea is that, if you don't have the ability to write to
the file, you should use shared locks instead of exclusive ones.
That is to say, the reading process should use flock(FILE, 1), which
should block until the writing process is finished.
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: Sun, 20 Jul 1997 07:37:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "J. Paul Reed" <preed@psd.k12.co.us>
Subject: Re: flocking on HP-UX
Message-Id: <Pine.GSO.3.96.970720072820.5855S-100000@kelly.teleport.com>
On 20 Jul 1997, J. Paul Reed wrote:
> 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 ;)
You can get the constants from the Fcntl module.
use Fcntl qw(:flock);
> flock OUT, 8;
> close(OUT);
And, as a general rule, you should never release the lock. Instead, finish
quickly and then simply close the file. That way, the system will be sure
to flush the buffers, close the file, and release the lock, all in the
proper order. When you understand the reasons behind this rule, you'll
know when you can break it. :-)
> 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?
You're on the wrong track here. Just use flock to block until the
exclusive lock is granted, then you can do whatever you need to do.
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: Sat, 19 Jul 1997 12:55:59 -0500
From: Eric Beck <erbeck@web-design.net>
Subject: getting rid of decimal places in output
Message-Id: <33D0F19F.4B3E@web-design.net>
Hi:
Please email me answers...thanks....
How do I get rid of decimal places in the output in Perl?
I want the output to be in dollar value format.
============
example
===========
$a=1.5;
$b=1.6;
$c=2.7;
$d= $a * $b * $c
print "The dollar value is $d.\n";
I get about 10 decimal places when I do that...I'm looking in my book by
Que, Using Perl 5, but can't find anything about format specifiers like
in C++.
Also, how do I print a $ sign in front of a $variable, besides assigning
the "$" sign to a variable such as $dsign='$'; and then going print "
The value of $dsign.$d is now added onto your account.
Thanks,
Eric
------------------------------
Date: Sun, 20 Jul 1997 06:30:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: erbeck@web-desgin.net
Subject: Re: getting rid of decimal places in output
Message-Id: <Pine.GSO.3.96.970720062422.5855G-100000@kelly.teleport.com>
On Sat, 19 Jul 1997, Eric Beck wrote:
> How do I get rid of decimal places in the output in Perl?
There are lots of ways. Some of them use the int() function, documented in
perlfunc(1). You could also use sprintf() or printf().
> Also, how do I print a $ sign in front of a $variable
Again, there are lots of ways. Here's one.
print '$', $variable;
But you may really want to put the dollar sign into a double-quoted
string. That is usually done with a backslash, like this. This is
documented in perlop(1).
print "The amount is \$$variable.\n";
If you have more questions after reading the manpages, post again. 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: Sun, 20 Jul 1997 09:03:18 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: getting rid of decimal places in output
Message-Id: <6r5tq5.r01.ln@localhost>
Eric Beck (erbeck@web-design.net) wrote:
: Hi:
Hi.
: Please email me answers...thanks....
Please seek the answer to the question in the same place where
you asked the question (the newsgroup). That way, thousands of
people can get the benefit of the answer.
: How do I get rid of decimal places in the output in Perl?
$num =~ s/\.\d+$//; # "get rid" of decimal places (truncate them)
: I want the output to be in dollar value format.
Oh, so you don't really want to "get rid of decimal places" then do you?
Or do you want to round to the next lowest dollar value?
What is "dollar value format"?
Are you sure you don't want "dollar and cents format"?
: ============
: example
: ===========
: $a=1.5;
: $b=1.6;
: $c=2.7;
: $d= $a * $b * $c
: print "The dollar value is $d.\n";
: I get about 10 decimal places when I do that...I'm looking in my book by
: Que, Using Perl 5, but can't find anything about format specifiers like
: in C++.
use sprintf() like in C.
see "Does perl have a round function? What about ceil() and floor()?
Trig functions?" in the Perl FAQ too.
Note particularly the paragraph about "financial applications"
and rounding error...
: Also, how do I print a $ sign in front of a $variable, besides assigning
: the "$" sign to a variable such as $dsign='$'; and then going print "
You escape it.
: The value of $dsign.$d is now added onto your account.
print "The value of \$.$d is now added onto your account.";
-------------------
#! /usr/bin/perl -w
$a=1.55; # changed to so as to generate more that two decimal places
# with the default settings
$b=1.6;
$c=2.7;
$d= sprintf("%.2f", $a * $b * $c); # round to two decimal places
print "The dollar value is \$$d.\n";
-------------------
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 20 Jul 1997 17:44:33 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: hashes and <img>
Message-Id: <5qubdh$o9s@web.azstarnet.com>
In article <5qu024$3i8$1@camelot.ccs.neu.edu>,
Greg Land <gland@ccs.neu.edu> wrote:
> 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.
Greg,
Perhaps your first script could print out a comment in the place where
you want the image tags to show up (e.g., just before the </BODY> tag).
Your second script reads the "standings" file and writes out a temporary
file (which it will later put in place of the current standings file) and
writes out to the temporary file.
Each time your second script finds a team, it puts the team name into
an associative array:
$teams_found{$1} = 1 if /<your pattern for finding team names here>/;
Then, when you get to the special comment, you do a foreach loop
on the keys of your teams_found:
foreach $team (keys %teams_found) {
print TMP qq(<img src="$image_names{$team}">);
}
So you print out the image names instead of the special comment. When
you're at the end of the standings file, close the temporary file handle
and then copy/move the temporary file over top of the standings file.
Tim
------------------------------
Date: 19 Jul 1997 09:12:58 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: How to embed a gif source in perl script ??
Message-Id: <01bc9424$0fca9740$d70ab2c2@Tschai>
SteveManes@REMOVEmagpie.com wrote in article
<EDEG0q.9Hy@magpie.com>...
> Harri Vainio (lmfhava@lmf.ericsson.se) wrote:
> : My idea would be to include the hex code of the image(Gif) in the
perl
> : source, but how to tell this to the browser ?? I would be filled
with
> : thanx to anyone with any information to my problem...
>
> Why embed it in the source? If you're talking to a browser just
> spit the GIF URL reference out as HTML code.
>
That's not the question....
@gif = qw(47 49 46 38 39 61 01 00 01 00 80 00 00 ff ff ff
00 00 00 21 f9 04 01 00 00 00 00 2c 00 00 00 00
01 00 01 00 00 02 02 44 01 00 3b);
print "Content-type: image/gif\n\n", pack("c43", map hex($_), @gif);
Is one way to do it... (This one returns a transparent gif).
The location method (i.e. print "Location:
http://example.com/my_image.gif\n\n")
is much slower (it needs another connection, ie. the server sends
location, the
browser opens a new connection to get the image.).
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: Sat, 19 Jul 1997 20:23:55 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Clay Shirky <clays@panix.com>
Subject: Re: How to s/TARGET_TEXT/&Subroutine;/gi;
Message-Id: <Pine.GSO.3.96.970719201352.5095I-100000@kelly.teleport.com>
On 19 Jul 1997, Clay Shirky wrote:
> I am running a search-and-replace function on an HTML file like so:
>
> for (@File) {
> if (/(TARGET_TEXT)/i) {
Do you have that literal text in that pattern match? Or is it a different
pattern than you're showing us here? You may be able to do this more
efficiently with index than with a pattern.
> &sub_to_generate_unique_variable;
> s/$1/$unique_variable/g;
I don't like that substitution. (You're compiling a new pattern for each
substitution, and you know just what text it should match already. Worse,
it might do something you really don't want if the text from $1 has
metacharacters in it!) You should probably re-write this loop with s///eg.
> }
> }
>
> This leaves me the non-HTML-ish assumption that subsequent occurences
> of TARGET_TEXT are separated by at least one \n.
And it may also be that you've made the assumption that each occurrence of
TARGET_TEXT was contained on one line. (That may be a valid assumption,
for that matter.)
> Alternatively, I could also
>
> s/TARGET_TEXT/&sub_to_generate_unique_variable;/gi;
>
> if the sub routine returns the value of the unique variable into the
> replacement position, but I cannot get either of these methods to work.
That one looks pretty close, but you'll want the /e modifier. 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: 19 Jul 1997 10:37:17 +0200
From: Axel Ramge <axel@ramge.de>
Subject: Implicit passing to CORE:: functions does not work
Message-Id: <m3d8ofh1z6.fsf@steiner.hh.ramge.de>
Hello,
Why doesn't Perl like to pass @_ implicit to the builtin functions, like
this way?
sub foo {
&CORE::foo;
}
Axel
---- Longer example ----
#!/usr/bin/perl -w
use strict;
my $hr = "-" x 70 . "\n";
sub foo {
my @args = @_;
return @_;
}
sub printargs {
my $name = shift;
print $hr;
for(my $i = 0; $i <= $#_; $i++) {
print "\t$name" . "[$i]\t$_[$i]\n";
}
print $hr;
}
sub bar {
print "I am bar() and got\n";
printargs('$_', @_);
print "\n" . 'My @_ will be passed implicit to &main::foo, which returns' . "\n";
printargs('&main::foo; ', &main::foo);
print "\n" . 'Passing @_ explicit to &main::foo(@_) returns' . "\n";
printargs('&main::foo(@_); ', &main::foo(@_));
print "\n" . 'Passing @_ explicit to CORE::sort(@_) returns' . "\n";
printargs('CORE::sort(@_); ', CORE::sort(@_));
print "\n" . 'But explicit &CORE::sort(@_) returns' . "\n";
eval { printargs('&CORE::sort(@_); ', &CORE::sort(@_)); };
print $hr, $@, $hr if $@;
print "\n" . 'and implicit &CORE::sort; says' . "\n";
eval { printargs('&CORE::sort; ', &CORE::sort); };
print $hr, $@, $hr if $@;
}
bar "World ", "Hello ";
------------------------------
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 749
*************************************