[7999] in Perl-Users-Digest
Perl-Users Digest, Issue: 1624 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 12 19:07:27 1998
Date: Mon, 12 Jan 98 16:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 12 Jan 1998 Volume: 8 Number: 1624
Today's topics:
Re: A newbie is trying to use perl <rootbeer@teleport.com>
Adv Perl Programming Tutorial - 2/3-5/98 <johnd@xor.com>
Re: Alphabetical Order (Martien Verbruggen)
Re: Avoiding regular expressions (was: Re: Newbie quest <ldanna@hotmail.com>
Re: Can Perl talk smtp protocol under NT4? (Martien Verbruggen)
Changing System Password <trey@waymark.net>
Code Refs <w.stanton@auckland.ac.nz>
Re: Code Refs <tchrist@mox.perl.com>
HELP!!! Error message: Get csdpmi*b.zip (KNervick)
Re: HELP!!! Error message: Get csdpmi*b.zip <jack_h_ostroff@groton.pfizer.com>
I'm nem at this (adding numbers) <potts@hc.ti.com>
Is modulus broken? (Martin D Schweitzer)
Re: Java/Perl integration - not free? <74331.3261@CompuServe.COM>
Re: LWP problem in a loop (Martien Verbruggen)
Newbie Sockets Question <mark.werner@bst.bls.com>
Re: Perl editor needed (Jeremy Brinkley)
Re: Perl oddity... (Martien Verbruggen)
Re: prog termination by server? <rootbeer@teleport.com>
qxurl/perl peculiarity (from perlfaq9) (John M. Klassa)
Re: Range Operator <rootbeer@teleport.com>
Re: serious post about gmtime and year-1900 (Martien Verbruggen)
Small Pattern Regrex Question? (John Irving)
Speed up a file write? (perl tricks in a cgi script?) (Michael R Weholt)
Re: Subroutine arguements (newbie) <rootbeer@teleport.com>
Re: Sys::Syslog problems. (Mike Stok)
Re: Truncating/trim from start an open text file <rootbeer@teleport.com>
use File::Find; ! on MacPerl ? (Don)
Re: WWW-pages generated by Perl-scripts (Ayse Sercan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Jan 1998 12:52:40 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: George Russell <george.russell@clara.net>
Subject: Re: A newbie is trying to use perl
Message-Id: <Pine.GSO.3.96.980112124933.24141P-100000@user2.teleport.com>
On Mon, 12 Jan 1998, George Russell wrote:
> The line to count the number of clara.net strings in $domain
> sometimes, and only sometimes returns an error Argument
> "xxxxx.yyyyy.zzz" isnt numeric in eq .
> next if $domain == /clara\.net$/;
When you look at the erroneous line and the error message together, does
the problem jump out at you? (Hint: Why would Perl care if that string in
$domain is numeric?)
Of course, that regular expression may not be exactly what you want,
unless you mean for it to match "notclara.net" as well. :-)
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/
Ask me about Perl trainings!
------------------------------
Date: Mon, 12 Jan 1998 17:08:46 -0700
From: John Donnelly <johnd@xor.com>
Subject: Adv Perl Programming Tutorial - 2/3-5/98
Message-Id: <34BAB08E.404B@xor.com>
**Upcoming Advanced Perl Programming Tutorial**
Sessions are held at our training facility in Boulder, CO.
Contact me for further information, registration forms.
--John Donnelly, Training Coordinator
XOR Network Engineering, Inc.
http://www.xor.com/tt johnd@xor.com 303-448-4816
*****
Advanced Perl Programming
(Three Day Hands-on Lecture/Lab)
Tom Christiansen, Consultant
Tuesday-Thursday, February 3-5, 1998
*****
------------------------------
Date: 11 Jan 1998 23:40:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Alphabetical Order
Message-Id: <69bl9m$cqq$1@comdyn.comdyn.com.au>
In article <34B7AEF2.4FB3@southernvirginia.edu>,
"Gary C. New" <gnew@southernvirginia.edu> writes:
> What is the simplest way to alphabatize data using Perl other than the
> "sort" command?
Why would you want to not use a function that was written specifically
to do what you want it to do?
"I want to switch on the light in my office, but I don't want to use
the switch they installed for that"
Bit odd..
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Mon, 12 Jan 1998 17:52:01 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: Avoiding regular expressions (was: Re: Newbie question)
Message-Id: <34BA9E90.16CF53FF@hotmail.com>
Chipmunk wrote:
> John C. Randolph wrote:
> >
> > No, there are definitely people who shouldn't be using Perl *or* Python, *or*
> > anything other than the first language they learned (Visual Basic: it causes
> > severe brain damage, just like all previous versions of Basic did.)
>
> Excuse me, but the first programming language I learned was BASIC.
>
Does BASIC really count as a programming language? I always thought
it was some tropical disease or something :)
---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
| -Winston Churchill
---------------------------------------------------
Larry D'Anna "eschew obfuscation"
------------------------------
Date: 12 Jan 1998 00:11:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can Perl talk smtp protocol under NT4?
Message-Id: <69bn32$cqq$5@comdyn.comdyn.com.au>
In article <34b94468.0@newsread1.dircon.co.uk>,
"Neil Sedley" <neil@nsedley.dircon.co.uk-antispam> writes:
> Get hold of the SMTP RFC ( 821 ISTR) and implement it yourself
Why would you want to do that, if someone else already has done the work?
Net::SMTP is available from CPAN.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Mon, 12 Jan 1998 14:49:04 -0600
From: Trey Thompson <trey@waymark.net>
Subject: Changing System Password
Message-Id: <34BA81C0.61F05A05@waymark.net>
I am currently changing the a users password (in the shadow file) by
opening the shadow file, replacing the old line with the new one, and
writing the shadow file. Obviously, I only do this if I need some
automated scripts to change a password, otherwise I user the built in
passwd function...
Is there a better way? I would like perl to be able to send a username
and password to a program and have it change it...
Trey Thompson
trey@waymark.net
------------------------------
Date: 13 Jan 1998 09:57:52 +1200
From: Worik Macky Stanton <w.stanton@auckland.ac.nz>
Subject: Code Refs
Message-Id: <wkhg791hjz.fsf@auckland.ac.nz>
Friends
If I have a package foo with a method bar that I access as...
$f = foo->new;
$f->bar;
How do I get a reference to bar?
ie. If I have a function in another package $z->blip and blib wants to
use foo::bar I would like to do something like...
$z->blip(\$self->bar)
from inside the foo package.
Do I have to pass a reference to foo and have blip know the name of bar?
Worik
------------------------------
Date: 12 Jan 1998 21:35:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Code Refs
Message-Id: <69e2at$8gt$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Worik Macky Stanton <w.stanton@auckland.ac.nz> writes:
:Friends
:
:If I have a package foo with a method bar that I access as...
:
:$f = foo->new;
:$f->bar;
:
:How do I get a reference to bar?
You shouldn't do that. :-(
:ie. If I have a function in another package $z->blip and blib wants to
:use foo::bar I would like to do something like...
:
:$z->blip(\$self->bar)
:
:from inside the foo package.
:
:Do I have to pass a reference to foo and have blip know the name of bar?
Extracted from the poduscript of The Perl Cookbook, still unpublished:
Problem: You want to store a reference to a method.
Solution: Create a closure that makes the proper method call on the
appropriate object.
Discussion
The best way to do this is to first realize that when you ask for a
reference to a method, you're asking for more than just a raw function
pointer. You also need to record the precise object the method is to
be called upon. That means the best way to do this is using a closure.
$mref = sub { $obj->meth(@_) };
# later...
$mref->("args", "go", "here);
Even when $obj goes out of scope, the closure stored in $mref has
captured it, so when later called indirectly, all works out.
Be aware that the notation:
$sref = \$obj->meth;
Doesn't do what you were probably expecting. It first calls the
method on that object and gives you a reference to the return value,
or a reference to the last of the return values if the method returns
a list.
The `can()' method from the UNIVERSAL base class, while appealing,
is also unlikely to produce what you want.
$cref = $obj->can("meth");
This produces is a code ref to the appropriate method (should one be
found), one which carries no object information. Think of it as a raw
function pointer. The information about the object is lost. That's
why you need a closure to capture both the object state as well as
the method to call.
All rights reserved, blah blah.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
I won't mention any names, because I don't want to get sun4's into
trouble... :-) --Larry Wall in <11333@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 12 Jan 1998 21:04:42 GMT
From: knervick@aol.com (KNervick)
Subject: HELP!!! Error message: Get csdpmi*b.zip
Message-Id: <19980112210401.QAA19404@ladder01.news.aol.com>
When I run perl under DOS I get an error saying that there is no DPMI, and that
i should get csdpmi*b.zip. What is this and where can it be found?
Thanx
Leif
------------------------------
Date: Mon, 12 Jan 1998 16:45:23 -0500
From: "Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com>
To: KNervick <knervick@aol.com>
Subject: Re: HELP!!! Error message: Get csdpmi*b.zip
Message-Id: <34BA8EF3.69F@groton.pfizer.com>
KNervick wrote:
>
> When I run perl under DOS I get an error saying that there is no DPMI, and that
> i should get csdpmi*b.zip. What is this and where can it be found?
> Thanx
> Leif
Sounds like you got the DJGPP compiled version of Perl. DPMI is a
memory manager thingy (very technical explanation...) Windows (3.1
and 95) include DPMI services, so you shouldn't get this message if
you run Perl in a DOS window. csdpmi is a small (?) utility which
provides DPMI services under DOS. You can probably get it from the
same place you got your version of Perl. csdpmi*b.zip implies that
you need more than one zip file (the * is probably 1, 2, ...) and
the b implies binary executables. There are probably files of the
same name with b changed to d (documentation) and s (source).
Good luck.
Jack
jack_h_ostroff@groton.pfizer.com
------------------------------
Date: Mon, 12 Jan 1998 15:03:11 -0600
From: Toby Potts <potts@hc.ti.com>
Subject: I'm nem at this (adding numbers)
Message-Id: <34BA850F.46647ECD@hc.ti.com>
Hello all:
I am just starting to learn programing languages. So I really don't
have a clue as to what I am doing.
Ok well mabey just a small clue. Any help offered will be greatly
appreciated.
This is the deal. After open a file from the input line and appending
to it. I want to find or match all
numbers and add them together and print sum to screen. This can be used
for any file, but I will be using
for a file of time records.
#!/apps/dad/bin/perl5 -w
##############################################
print "Input File name = ";
chomp($in=<STDIN>);
open(FILE, ">>$in") || die "Cant open $in";
print "What to append to file?: ";
$line = <>;
print FILE "$line";
close FILE;
system "more $in";
#####################################################
THANKS
TOBY
TI. Phone (972)995-7296
Fax (972) 995-6194
_/_/_/_/_/ _/_/_/_/ _/_/_/_/ \_ _/ _/_/_/_/
_/ _/ _/ _/ _/ \_ _/ _/ _/
_/ _/ _/ /_/_/ \_ _/ _/_/_/_/
_/ _/ _/ _/ _/ _/ _/
_/ _/_/_/_/ _/_/_/_/ _/_/_/_/ _/ =
email potts@ti.com
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
"I hope our wisdom will grow with our power, and teach us,
that the less we use our power the greater it will be."
Thomas Jefferson
------------------------------
Date: Mon, 12 Jan 1998 22:08:29 GMT
From: martin@matilda.vut.edu.au (Martin D Schweitzer)
Subject: Is modulus broken?
Message-Id: <EMoyu6.J92@matilda.vut.edu.au>
When I run the following expression:
>perl -e "print 1940641915534 % 11438;"
I get the result: 3862. As far as I can tell, the result
should be 0 (e.g. see bc). Is there a limit for the %
operator?
[I wrote a function to return the mod using floating point
which seemed to work, but is terribly slow]
Martin
--
---------------------------------------------------------------------
Martin Schweitzer
Snipe & Grouse
Footscray, Australia
------------------------------
Date: Mon, 12 Jan 1998 17:48:12 -0500
From: Terry Michaels <74331.3261@CompuServe.COM>
Subject: Re: Java/Perl integration - not free?
Message-Id: <#Xccqw6H9GA.158@ntawwabp.compuserve.com>
Buy the Resource Kit through amazon.com and save $30.
I got the whole thing shipped to me for $124.
TMichaels@compuserve.com
------------------------------
Date: 11 Jan 1998 23:27:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: LWP problem in a loop
Message-Id: <69bkgr$cmv$2@comdyn.comdyn.com.au>
In article <34B7BD43.422AD339@ungi.com>,
Gilles Maire <Gilles.Maire@ungi.com> writes:
> After 10 resolutions and good thinks, I have a list of instantaneous
> messages without any network access like this :
>
> Recherche URL : http://territorial.afuu.fr
> <HTML>
> <HEAD><TITLE>An Error Occurred</TITLE></HEAD>
> <BODY>
> <H1>An Error Occurred</h1>
> 500 Can't resolv address for territorial.afuu.fr
> </BODY>
> </HTML>
> ... strange like a pointer problem in LWP or a wrong thing in my
> program.
This looks suspiciously like proxy server output. Maybe there's a
problem there? If the perl script can resolve the first ten, but not
the later ones, I don't think there's anything wrong with perl, or the
script, but with your network setup, in whatever place that would be.
If you do 100 successive DNS lookups, do you get the same problem?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Mon, 12 Jan 1998 01:52:32 -0800
From: "Mark A. WErner" <mark.werner@bst.bls.com>
Subject: Newbie Sockets Question
Message-Id: <34B9E7E0.50C9@bst.bls.com>
I am running this code on HP UX 10.01 on a K-Series.
What I wanted to do was connect to the TELNET port and read the
banner info it spits back at you. When I use the TELNET port, nothing
comes back. BUT, when I got to the SMTP port, 25, I get back the 1st
line from SMTP just as I would expect. The TELNET daemon is up and
running on the box. I can manually TELNET to it and get the banner, no
problem.
Any advice or giudence would be greatly appreciatted.
THANKS in Advance
#!/usr/local/bin/perl
use Socket;
$iaddr = inet_aton('90.30.120.9');
$paddr = sockaddr_in(25,$iaddr); # 23 Is Telnet, 25 is Mail
$proto=getprotobyname('tcp');
print("proto is $proto\n");
socket(SH,PF_INET,SOCK_STREAM,$proto) || die("SOCKET DIED: $!\n");
connect(SH,$paddr) || die ("Connect failed $!\n");
print("CON PASSED\n");
sysread(SH,$buffer, 200);
print("-------------------------\n");
print($buffer);
print("--------------------------n");
close(SH);
------------------------------
Date: 12 Jan 1998 23:30:22 GMT
From: jeremy@wishbone.stanford.edu (Jeremy Brinkley)
Subject: Re: Perl editor needed
Message-Id: <69e92e$44v$1@nntp.Stanford.EDU>
On 9 Jan 1998 06:29:48 GMT, Shimpei Yamashita (shimpei+nospam+nospam+caltech.edu@socrates.caltech.edu) put forth:
> shareware editor Alpha <http://www.cs.umd.edu/~keleher/alpha.html> is
> probably the closest thing there is to emacs on the Mac; it uses Tcl
> rather than Lisp (or perl :-)) as the extension language, but it has
> color syntax coloring, modes, external hooks, completely modifiable
> key bindings and menus, the works. I've never tried to write perl
> with it, but I remember its C and C++ modes being very good.
Alpha's good for perl. The syntax highlighting can act a little funny--
if I remember it might have a minor problem handling # characters. I
use it for everything on the mac. But I must say that vim is my
favorite editor.
--
Jeremy Brinkley jeremy@wishbone.stanford.edu
System Administrator finger for PGP key (2.6.2) or
Stanford Blood Center http://wishbone.stanford.edu/~jeremy
------------------------------
Date: 11 Jan 1998 23:45:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl oddity...
Message-Id: <69bliu$cqq$2@comdyn.comdyn.com.au>
In article <696lra$a6e$1@cletus.bright.net>,
"Big Ape" <bigape@grungyape.com> writes:
> Here is the normal, expected output:
[snip]
> Part#: 100 Quantity: 1 Total: 6.92
[snip]
> Here is the same stuff on the BSD:
[snip]
> EDP#: 216 Quantity: 4 Total: 24.839999999999999858
Looks like a precision problem. FreeBSD obviously handles floats
differently from the other two systems. If you want control over how
numbers are displayed, use the sprintf function.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Mon, 12 Jan 1998 12:54:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tobias Poppe <udta@rz114s1.rz.uni-karlsruhe.de>
Subject: Re: prog termination by server?
Message-Id: <Pine.GSO.3.96.980112125346.24141R-100000@user2.teleport.com>
On 12 Jan 1998, Tobias Poppe wrote:
> Does the server automaticly terminates the skript ???
Sounds like a question about servers, not about Perl. If you can't find
the answer in your server's docs, the people in a newsgroup about servers
should be able to give you a better and more complete answer than we can
here. Good luck!
--
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/
Ask me about Perl trainings!
------------------------------
Date: 12 Jan 1998 22:04:09 GMT
From: klassa@aursgh.aur.alcatel.com (John M. Klassa)
Subject: qxurl/perl peculiarity (from perlfaq9)
Message-Id: <69e40p$70h$1@aurwww.aur.alcatel.com>
>From perlfaq9:
#!/usr/bin/perl -n00
# qxurl - tchrist@perl.com
print "$2\n" while m{
< \s*
A \s+ HREF \s* = \s* (["']) (.*?) \1
\s* >
}gsix;
I ran my netscape bookmarks file through it, and it did things like
this:
http://computerstore.utsa.edu/bsm/biblestudy/translations.html" \
ADD_DATE="850147572" LAST_VISIT="850402327" LAST_MODIFIED="850402327
http://www.vaxxine.com/compcare/divine.eht" ADD_DATE="859299560" \
LAST_VISIT="859299457" LAST_MODIFIED="859299457
http://users.kconline.com/paul/litv/INDEX.HTM" ADD_DATE="839609312" \
LAST_VISIT="851353831" LAST_MODIFIED="851353831
(Extra whitespace added by me, for readability.)
I'm perplexed about the behavior of the regex. It looks like the .*? is
being greedy, despite the "?". That is, the ["'] class is matching a double
quote in this case, so I'd expect the regex engine to stop snarfing
characters at the first ensuing double quote (which is right after the URL).
Instead, it keeps snarfing until it hits the *last* one (which seems pretty
greedy to me), after the LAST_MODIFIED field.
Is this to be expected? Have I hit upon a bug in the regex engine? Am I
just too stupid to see the obvious thing going on here?
Thanks!
John
--
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><
------------------------------
Date: Mon, 12 Jan 1998 13:18:09 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Joe Kline <Joe.Kline@sdrc.com>
Subject: Re: Range Operator
Message-Id: <Pine.GSO.3.96.980112131509.24141U-100000@user2.teleport.com>
On Mon, 12 Jan 1998, Joe Kline wrote:
> @temp = $inputs[ 1 .. $#inputs ];
That's not what it may look like; the range operator (..) is being used in
a scalar context, where it is a totally odd beast. The dollar sign makes
the expression into a single scalar, rather than a slice. If you use an at
sign, I think you'll get just what you expected. 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/
Ask me about Perl trainings!
------------------------------
Date: 12 Jan 1998 23:16:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: serious post about gmtime and year-1900
Message-Id: <69e89a$jlh$1@comdyn.comdyn.com.au>
In article <19980111.165249.5F9.rnr.w164w_-_@locutus.ofb.org>,
Russell Schulz <Russell_Schulz@locutus.ofB.ORG> writes:
>> Uhm, my copy of the documentation that comes with Perl says:
>>
>> Also, $year is the number of
>> years since 1900, that is, $year is 123 in year 2023.
>
> well, how come everyone else is claiming it DOESN'T give examples?
Because there are different sets of documentation out there, and
because people keep talking about two different documentation entries.
The above example is in the localtime() doco. The other extracts that
were mentioned are from the gmtime() doco.
perldoc -f gmtime
Also, $year is the number of
years since 1900, I<not> simply the last two digits of the year.
perldoc -f localtime
Also, $year is the number of
years since 1900, that is, $year is 123 in year 2023.
perl -v
This is perl, version 5.004_04 built for sun4-solaris
As far as *I* am concerned, I think both entries are more than clear
enough in describing what gets returned.
Now, can we please put this to rest? If you feel the documentation is
insufficient, submit a bug report with perlbug.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In the fight between you and the world,
Commercial Dynamics Pty. Ltd. | back the world - Franz Kafka
NSW, Australia |
------------------------------
Date: Mon, 12 Jan 1998 23:16:09 GMT
From: hyperc@magma.ca (John Irving)
Subject: Small Pattern Regrex Question?
Message-Id: <hyperc-1201981815230001@206.191.12.213>
Can anyone tell me why the following doesn't match?
$Query = '(?i)and maintained.|(?i)other patterns|(?i)etc.';
$Data = 'and maintained.';
print "\n\nQuery is: $Query";
if ($Data =~ /\b($Query)\b/) {
print "\nResult is: $& matches";
} else {
print "\nResult is: No Match";
}
# why doesn't 'and maintained.' match?
I've also tried "$Query = '(?i)and maintained\.|(?i)etc';" (note escaped
period) and "$Query = '(?i)\Qand maintained.\E|(?i)etc';" (quotemeta) with
similar results (latter format preferred).
I'm trying to build regex's based on user input and would like to quote
metacharacters in $Query yet match data.
Any help greatly appreciated.
Thanks,
John
john@hyperconnect.com
------------------------------
Date: Mon, 12 Jan 1998 22:52:46 GMT
From: awnbreel@panix.com (Michael R Weholt)
Subject: Speed up a file write? (perl tricks in a cgi script?)
Message-Id: <69e6ru$34o_002@mrw.panix.com>
The following bit of code (a write to disk in a cgi script), using the
"non-professional" version of the OmniHTTPd server on my local win95
machine, takes nearly *8* CPU seconds to execute. At the moment, the
file ends up being about 48K. Can anybody suggest any perl tricks to
speed things up? (Unless otherwise noted, the printed items are
only one line in length.)
use Text::Wrap;
$Text::Wrap::columns = 72;
$pre1 = $pre2 = "";
open(SF, ">$ftbw") || die "Cannot write to $ftbw\n";
foreach $quote (@quotes) {
print SF "{TOPIC}\n";
foreach $topic (@{$quote->{TOPICS}}) {
# this will print 1 to ~5 lines of a few words each
print SF $topic, "\n";
}
print SF "{SOURCE}\n";
print SF $quote->{SOURCE}, "\n";
print SF "{ALAST}\n";
print SF $quote->{ALAST}, "\n";
print SF "{AFIRST}\n";
print SF $quote->{AFIRST}, "\n";
print SF "{PAGES}\n";
print SF $quote->{PAGES}, "\n";
print SF "{TITLE}\n";
print SF $quote->{TITLE}, "\n";
print SF "{QUOTE}\n";
# this will print ~5 to 25 lines
print SF wrap($pre1, $pre2, $quote->{BODY}), "\n";
print SF "{END}\n";
print SF "\n";
}
close(SF);
It's January so just call the above "molasses". Thanks for any ideas.
--
mrw
------------------------------
Date: Mon, 12 Jan 1998 13:01:17 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Walker <john@5points.net>
Subject: Re: Subroutine arguements (newbie)
Message-Id: <Pine.GSO.3.96.980112125804.24141S-100000@user2.teleport.com>
On Mon, 12 Jan 1998, John Walker wrote:
> To put it another way... I want to call
>
> &snarfffile(somefile);
>
> which manipulates the file somefile and returns a value %somefile.
> Getting the varible to be named %somefile is what's giving me fits.
You could do this, but your code would be more reliable and easier to
maintain if you use a true reference instead. See the perlref manpage.
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/
Ask me about Perl trainings!
------------------------------
Date: 12 Jan 1998 16:39:36 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sys::Syslog problems.
Message-Id: <69e2io$1ph$1@stok.co.uk>
Are you sure syslog is cortrectly configured? My syslogd man page (linux)
says
-r This option will enable the facility to receive
message from the network using an internet domain
socket with the syslog service (see services(5)).
The default is to not receive any messages from the
network.
This option is introduced in version 1.3 of the
sysklogd package. Please note that the default
behavior is the opposite of how older versions
behave, so you might have to turn this on.
by default Sys::Syslog talks on inet domain sockets, as of 5.004_03 it's
possible to set the domain to unix using setlogsock.
Hope this helps,
Mike
In article <69duno$tm4$1@jake.esu.edu>,
Jeremy Madea <jdmadea@cs.millersv.edu> wrote:
>Sys::Syslog is not working for me...
>
>Running on 5.004_04 on linux (2.0.32). Code:
>
>#!/usr/bin/perl -d
>
>use Sys::Syslog;
>
>openlog("sl.pl [$$]", 'cons,ndelay,nowait', 'user');
>$!=55;
>syslog('info','Info test with error: %m and a 3:%d', 3);
>closelog;
>
>#################################
>
>syslog is configured correctly and tests in C work fine.
>Debugger walkthrough looks OK...
>netstat shows the connection, but no bytes ever seem to get transfered...
>$! is at some point set to "Bad File Number"...(I think in &closelog.)
>script does not die or croak...
>
>Anyone have any clues what is going wrong?!
>Please email replies to jdmadea@cs.millersv.edu
>
>Thanks,
>-j
>
>
>--
>
><----------------------------------------------------------------------------->
>/ /
>\ My two cents aren't worth a dime. Jeremy Madea == bones \
>/ jdmadea@cs.millersv.edu /
>\ http://cs.millersv.edu/~jdmadea/homepage.html \
> \__________________________________________________________________________/
> boneyard:~$ uname -nmsr
> Linux boneyard 2.0.32 i586
>
>-----BEGIN GEEK CODE BLOCK-----
>Version: 3.1
>GCS d-@ s-: a- C++++$ UBLS++++$ P++++$ L+++$>++++ E-@>+++ W-(++)$ N++@ !o
>!K w--- !O M--(-) !V(--) PS+++@ PE@ Y+@>++ PGP@>+ !t 5 X+ R !tv
>b+++>++++ DI(++) D-(+) G e>++ h(+) r>$ y+*(**)
>------END GEEK CODE BLOCK------
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Mon, 12 Jan 1998 13:10:38 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ameer Sulaiman <asulai@ctp.com>
Subject: Re: Truncating/trim from start an open text file
Message-Id: <Pine.GSO.3.96.980112130534.24141T-100000@user2.teleport.com>
On Mon, 12 Jan 1998, Ameer Sulaiman wrote:
> I am trying to use Perl to trim an application log file. I need Perl to
> trim from beginning and truncate() seems to work from the end of file.
It sounds as if you want to retain the last part of the file. Although
there's no system call to do this, it's not hard to do in Perl.
> The catch is that the file will be open by the application during the
> operation and may get written to.
That's a problem. I think you could use the methods in Randal's fourth Web
Techniques column, which explains how to use flock() to avoid problems
when multiple processes need to modify one file.
http://www.stonehenge.com/merlyn/WebTechniques/
But in most cases, I'd recommend that you consider simply renaming the log
file. When the application sees that the file is gone, it will typically
create a new one. You won't miss anything. 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/
Ask me about Perl trainings!
------------------------------
Date: Mon, 12 Jan 1998 23:16:53 GMT
From: defike@ilstu.edu..spam.not (Don)
Subject: use File::Find; ! on MacPerl ?
Message-Id: <34baa167.32302900@news.ice.net>
Help!
I was just introduced to File::Find and was happy. About as happy as
when I was introduced to associative arrays. Now I wrote a couple of
quick scripts on NT and Unix using File::Find and I am still happy.
But...When I tried to run from a Mac using MacPerl I get the following
errors;
"use" may clash with future reserved word
syntax error next 2 tokens "use File"
"find" may clash with future reserved word
Now here is the script OI would like to be running;
#!perl -w
use File::Find;
find (&Wanted, 'Macintosh HD:Desktop Folder:vicki")
sub Wanted
{
print "$File::Find::name\n";
}
What I am trying to do is rename Macintosh files with illegal
characters prior to moving them to Windows. My script worked well
when I ran it from Win95 or AIX but the files need to be renamed on
the Mac.
Could someone point out why I can't run this with MacPerl???
TIA
Don
defike@ilstu.edu..spam.not
------------------------------
Date: Mon, 12 Jan 1998 22:05:37 GMT
From: ayse@netcom.com (Ayse Sercan)
Subject: Re: WWW-pages generated by Perl-scripts
Message-Id: <ayseEMoypD.CqF@netcom.com>
mheins@prairienet.org (Mike Heins) wrote:
>
>I encourage everyone encountering these separate posts to ignore
>them all.
Seems that Paul was well ahead of you on that one. He's encouraging
people to ignore his posts himself:
Paul Weingarten (paulweingarten@hotmail.com) wrote:
>I would be very grateful for answers, please include the full
>Perl-code since I am a beginner on Perl.
--
ayse@netcom.com
"I like my men like I like my coffee: Strong, with lots of milk and sugar
and a touch of that Torani caramel syrup."
------------------------------
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 1624
**************************************