[7106] in Perl-Users-Digest
Perl-Users Digest, Issue: 731 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 14 05:17:20 1997
Date: Mon, 14 Jul 97 02:00:46 -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 Mon, 14 Jul 1997 Volume: 8 Number: 731
Today's topics:
Re: $1 trashed on nested s///: feature or bug (Tad McClellan)
Re: '' and "" + a question to the C Wizards (M.J.T. Guy)
Re: 500 Server Error - Perl & Win 95 PWS (Mark Nielsen)
Re: calculate No. of days <rootbeer@teleport.com>
Re: co-routines in Perl <rootbeer@teleport.com>
Re: CPAN help <rootbeer@teleport.com>
Example of reading data (Cloy D. Tobola)
Re: Example of reading data <rootbeer@teleport.com>
exit inside END block (Jack Applin)
Re: Help on recursive directory listing <rootbeer@teleport.com>
Re: Help with MacPerl <rootbeer@teleport.com>
Re: How do you do a 'cut -cx-y' with Perl? (Eric Bohlman)
Re: How efficient is shift command? <rootbeer@teleport.com>
How to make perl execute more than 1 command (in UNIX)? (James Thornton)
Re: How to make perl execute more than 1 command (in UN <rootbeer@teleport.com>
Re: How to make perl execute more than 1 command (in UN (Michael Fuhr)
Re: How to read and write an image with perl (M. muPe)
Re: Learning Perl ..Help?? <rootbeer@teleport.com>
Re: making refs in while() elegantly... (M.J.T. Guy)
Re: making refs in while() elegantly... <rootbeer@teleport.com>
Re: making refs in while() elegantly... <me@anon.com>
Re: making refs in while() elegantly... <rootbeer@teleport.com>
MORE -- script going zombie, missing read... <guitarweb@hotmail.com>
Re: Output to a file (Tung-chiang Yang)
Paradox files access <albertom@eolo.com>
Re: Perl 5.004 Socket from inetd <merlyn@stonehenge.com>
Perl Developer required at Netcraft, Bath, England (Mike Prettejohn)
Perl for Win32::Registry Set Value question (Marc Haber)
Re: perl script inside perl script <rootbeer@teleport.com>
Re: Perl5 for win/dos (Mark Nielsen)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Jul 1997 07:34:03 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: $1 trashed on nested s///: feature or bug
Message-Id: <rjt7q5.fi.ln@localhost>
John Callender (jbc@west.net) wrote:
: Eli the Bearded wrote:
: >
: > while(<>) {
: > s+\b(x-mac-(?:type|creator)=")([\da-f]{8})"+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: > ($e=$1,$e) .
: > ($f=$2, $f=~ s<([\da-f][\da-f])><chr(hex($1))>ige, $f)
: > . qq^"^ +ige;
: > print ;
: > }
: >
: > I know I am not using -w, that was just for the sample above. With it
: > It tells me I am using $1 uninitialized somewhere in the second
: > substitution pass of the outer s///. Meanwhile $2 clearly has not
: > been reset either for the second pass.
: I'm probably missing something (I usually am), but I thought you were
: supposed to use \1 and \2, rather than $1 and $2, to reference an
: earlier match within the same regexp.
That's right.
But Eli used $1 in the 'replacement' part of the s///, which is not
within a regex. The regex is only in the 'match' part...
(if you use \1 in the replacement part the -w switch will warn you about it)
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 12 Jul 1997 13:21:23 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: '' and "" + a question to the C Wizards
Message-Id: <5q80cj$jmk@lyra.csx.cam.ac.uk>
Sanjay Malunjkar <malunjkars@aol.com> wrote:
>
>Hope that makes sense. Surprisingly,the _- are in the shape of a circle.
But that is the whole point. The number of _, and therefore the final
value of F, is (approximately) proportional to the area of the circle.
And OO is the number of lines, i.e. the diameter. So pi is being
approximated as 4*area/diam**2.
And you'd get a much better approximation with a much larger circle.
Mike Guy
------------------------------
Date: 12 Jul 1997 16:47:45 -0400
From: men2@auto.med.ohio-state.edu (Mark Nielsen)
Subject: Re: 500 Server Error - Perl & Win 95 PWS
Message-Id: <5q8qhh$qv5$1@auto.med.ohio-state.edu>
I read a webpage somewhere about how to get perl to work on a microsoft
webserver. It was titled "What Microsft doesn't want you to know.".
Sorry, i forget where it is. It gave a very nice demonstration of how to
get perl scripts running on the Microsft webserver.
Mark
--
---------------------------------------------------------------------------
Mark Nielsen men2@auto.med.ohio-state.edu or gytres+@osu.edu
Systems Specialist
The Ohio State University
------------------------------
Date: Sat, 12 Jul 1997 07:00:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Raju Gadiraju <rajug@bnr.ca>
Subject: Re: calculate No. of days
Message-Id: <Pine.GSO.3.96.970712065355.2012G-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Raju Gadiraju wrote:
> I want to determine no. of days between two dates.
So, you want to use a Date module.
> I get the foll. error when I try to use it.
>
> ******************************************************
> Can't load module Date::DateCalc, dynamic loading not available in this
> perl.
> (You may need to build a new perl executable which either supports
> dynamic loading or has the Date::DateCalc module statically linked
> into it.)
> at Date/DateCalc.pm line 28
> ******************************************************
>
> I can't understand what it means.
It means that your perl binary doesn't let you link to new modules
dynamically. Maybe your OS doesn't support dynamic loading. If it does
support it, simply recompile perl with that option enabled. (Usually the
configuration script figures this out correctly for you.)
The alternative is static linking, which you can do by following the
instructions beginning on page 414 of the Camel book. 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, 12 Jul 1997 06:31:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Matthew X Economou <econommx@rose-hulman.edu>
Subject: Re: co-routines in Perl
Message-Id: <Pine.GSO.3.96.970712063115.2012E-100000@kelly.teleport.com>
On 10 Jul 1997, Matthew X Economou wrote:
> You can do co-routines in FORTRAN.
> You can do them in C.
> You can do them in Scheme.
> But can you do co-routines in Perl?
Probably. What are they? :-)
--
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, 12 Jul 1997 07:43:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Will Linden <wlinden@panix.com>
Subject: Re: CPAN help
Message-Id: <Pine.GSO.3.96.970712073623.2012M-100000@kelly.teleport.com>
On 11 Jul 1997, Will Linden wrote:
> Is there something else I am doing wrong? Or are non-superusers
> unable to use the modules?
Many modules are simply Perl code, and can be installed and used very
easily. Others need to be prepared to be linked (statically or
dynamically) with a perl binary. You don't have to be root to do this,
although it helps! :-) (Of course, you should have to be root to modify
the existing perl binary that's shared by all users. But as a non-root
user, you may be able to make a module to be dynamically linked with that
binary.)
Of course, the easiest way is often to get your sysadmin to install the
module. But if you have the disk space, you can compile perl yourself
(it's not as hard as it sounds) and add whatever modules you want. 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, 13 Jul 1997 00:22:21 -0500
From: ctobola@nospam.rrnet.com (Cloy D. Tobola)
Subject: Example of reading data
Message-Id: <ctobola-ya023180001307970022210001@snews.zippo.com>
I'm trying to write a simple database program to read an array from data
lines below the program code. I'm having a heck of a time getting this to
work.
Can someone point me to a working example of this procedure?
Thanks! -Cloy
=============================================
Some people never see the light,
Til it shines through bullet holes.
-Bruce Cockburn
For more 80s trivia, visit my New Wave 80s Page
at http://rrnet.com/~ctobola/newwave.html
=============================================
------------------------------
Date: Sun, 13 Jul 1997 07:55:26 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Cloy D. Tobola" <ctobola@nospam.rrnet.com>
Subject: Re: Example of reading data
Message-Id: <Pine.GSO.3.96.970713075231.8969F-100000@kelly.teleport.com>
On Sun, 13 Jul 1997, Cloy D. Tobola wrote:
> I'm trying to write a simple database program to read an array from data
> lines below the program code.
You could use this sort of code.
my @array = (
1, 2, 17, 3.14159, "foobar", sqrt(2),
"more items can go on other lines",
'the last one may end with a comma',
);
Does that do anything you need? Or maybe you're wanting to use the DATA
filehandle.
# Read in data after __END__ token
my @array = <DATA>;
Both of these techniques are covered in the docs. 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: 12 Jul 1997 23:21:55 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: exit inside END block
Message-Id: <5q93ij$s5o@fcnews.fc.hp.com>
I wrote a grep clone in Perl. It looked something like this:
#! /usr/bin/perl -w
$pattern = shift;
$matches = 0;
while (<>) {
if (/$pattern/o) {
$matches++;
print;
}
}
exit !$matches;
I showed it to a friend, and he suggested that I use the -n flag, like this:
#! /usr/bin/perl -wn
BEGIN {
$pattern = shift @ARGV; # needed to add @ARGV
$matches = 0;
}
if (/$pattern/o) {
$matches++;
print;
}
END {
exit !$matches; # Error at runtime
}
Ignoring the issue of whether this transformation is stylistically good,
two questions arise:
- Why did I have to convert "shift" to "shift @ARGV"?
The perlfunc man page says:
If ARRAY is omitted, shifts the @ARGV array in the
main program, and the @_ array in subroutines.
I'm not in a subroutine, right? Is BEGIN{} a sort of pseudo-subroutine?
- Perl didn't like having exit inside END{}:
Callback called exit.
END failed--cleanup aborted.
Fine, I can understand that. How can I accomplish what I want?
-Jack Applin
neutron@fc.hp.com
------------------------------
Date: Sat, 12 Jul 1997 07:35:00 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Bell <mike@linux.map.com>
Subject: Re: Help on recursive directory listing
Message-Id: <Pine.GSO.3.96.970712073338.2012L-100000@kelly.teleport.com>
On Thu, 10 Jul 1997, Michael Bell wrote:
> Newsgroups: comp.lang.perl
If your news administrator still carries comp.lang.perl, please encourage
him or her to check out the frequent posting about bogus newsgroup names
in news.announce.newgroups. You'll be doing yourself and many others a
favor to use comp.lang.perl.misc (and other valid Perl newsgroups)
instead.
news:news.announce.newgroups
> I am looking for a procedure to recursivly search through a directory
> structure
Using a module or find2perl would be a good place to start writing one.
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, 12 Jul 1997 06:30:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: JTurner201 <jturner201@aol.com>
Subject: Re: Help with MacPerl
Message-Id: <Pine.GSO.3.96.970712061748.2012D-100000@kelly.teleport.com>
On 11 Jul 1997, JTurner201 wrote:
> I've just downloaded a version of macperl, and can't get it to respond
> to any of the commands.
Any of them? If you can't get the about box (by choosing "About MacPerl"
in the Apple menu) it's really hosed. Which version do you have? If it's
earlier than about 5.1.3r2, see about getting something newer from CPAN.
> When I click any of the commands under the help menu it gives a message
> stating that it "could not find helper for 'pod', do you want to creat
> one".
If you have a recent version of MacPerl, it should come with Shuck, a cool
pod viewer. You may need to run Internet Config (also included with
MacPerl) and tell it that that's your pod helper.
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, 13 Jul 1997 09:27:24 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: How do you do a 'cut -cx-y' with Perl?
Message-Id: <ebohlmanED93Lo.CFu@netcom.com>
Clark Dorman (clark@s3i.com) wrote:
: That is, the 5 substr's takes less time than a single unpack
: statement. I'd go with substr. It makes more sense to me anyway.
While multiple substr's may be faster than a single unpack, they're not as
robust. If the specification for the data file changes (e.g. one of the
fields gets widened), with unpack you only have to change *one* value,
whereas with multiple substr's you have to change *all* the offsets for
the fields after the one that changed. It is trivially easy to miss one
or get one wrong (I've done it several times myself in other languages),
and this can lead to hard-to-track-down bugs.
------------------------------
Date: Sat, 12 Jul 1997 06:53:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Re: How efficient is shift command?
Message-Id: <Pine.GSO.3.96.970712063209.2012F-100000@kelly.teleport.com>
On Fri, 11 Jul 1997, Brett Denner wrote:
> If I have a large array, and perform a shift operation on it:
>
> my $line = shift @array;
>
> do all of the elements of @array from 1 to $#array get moved around in
> memory, or is the shift command more efficient than that?
It's much more efficient than that.
use Benchmark;
@big = (1..1e4);
timethese 1e5, {
push_pop => 'push @big, 12345; pop @big;',
unshift_shift => 'unshift @big, 12345; shift @big;',
push_shift => 'push @big, 12345; shift @big;',
unshift_pop => 'unshift @big, 12345; pop @big;',
} ;
I get these results:
push_pop: 3 secs ( 2.35 usr 0.00 sys = 2.35 cpu)
push_shift: 2 secs ( 2.29 usr 0.00 sys = 2.29 cpu)
unshift_pop: 123 secs (101.69 usr 0.03 sys = 101.72 cpu)
unshift_shift: 2 secs ( 2.45 usr 0.00 sys = 2.45 cpu)
Three of the cases are so close as to be virtually indistinguishable in
this sample. From the vast (!) difference that the other case shows, I'd
guess that the push-shift queue is well optimized, but nobody needs an
unshift-pop queue.
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: 13 Jul 1997 00:26:50 GMT
From: James@comp4ncr.com (James Thornton)
Subject: How to make perl execute more than 1 command (in UNIX)?
Message-Id: <5q97ca$f4r$1@gte1.gte.net>
I'm a perl newbie, and hope this question isn't totally stupid...
I am writing a simple perl script to do nslookup to entire class C
addresses. I put the "exec nslookup" in a loop, but it only does the
first specified IP before it sends me back to the command prompt. How can
I make perl execute the command on the entire class C address before it
sends me back to the command prompt?
Thanks,
--James (James@comp4ncr.com)
------------------------------
Date: Sat, 12 Jul 1997 18:08:57 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: James Thornton <James@comp4ncr.com>
Subject: Re: How to make perl execute more than 1 command (in UNIX)?
Message-Id: <Pine.GSO.3.96.970712180637.3712I-100000@kelly.teleport.com>
On 13 Jul 1997, James Thornton wrote:
> I am writing a simple perl script to do nslookup to entire class C
> addresses. I put the "exec nslookup" in a loop, but it only does the
> first specified IP before it sends me back to the command prompt.
Well, it sounds as if you're using exec which, according to the
documentation, never returns. Could that be the problem? 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: 12 Jul 1997 19:25:52 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: How to make perl execute more than 1 command (in UNIX)?
Message-Id: <5q9ar0$5r4@flatland.dimensional.com>
Tom Phoenix <rootbeer@teleport.com> writes:
> On 13 Jul 1997, James Thornton wrote:
> > I am writing a simple perl script to do nslookup to entire class C
> > addresses. I put the "exec nslookup" in a loop, but it only does the
> > first specified IP before it sends me back to the command prompt.
> Well, it sounds as if you're using exec which, according to the
> documentation, never returns. Could that be the problem? Hope this helps!
...and why on earth are you doing "exec nslookup" for DNS queries?
Check out the perlfunc manual page and search for "gethostby". Or
visit CPAN and search for "DNS":
http://www.perl.com/CPAN/CPAN.html
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
Date: Sun, 13 Jul 1997 13:56:40 GMT
From: mupe@desk.nl (M. muPe)
Subject: Re: How to read and write an image with perl
Message-Id: <5qajk9$5mu$1@news2.xs4all.nl>
In article <33C6C0CB.F89590DB@servicepool.net>, Marco Ender <info@servicepool.net> wrote:
>Hy,
>
>does anybody know how to read an image from an URL and write it into my
>dir
>with perl4
>
>Is this the right way ?
>
>open (IMAGE, "$URL");
>$IMAGE = <IMAGE>;
>close (IMAGE);
First of all upgrade to Perl5, it is more secure and has more
options then Perl4
Then it will also be possible to use the CGI.pm package.
That package comes with man pages also covering how to upload
files from a html form.
Mathilde muPe
------------------------------
Date: Sun, 13 Jul 1997 07:52:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Cowboy <cowboy@cybernw.com>
Subject: Re: Learning Perl ..Help??
Message-Id: <Pine.GSO.3.96.970713074914.8969E-100000@kelly.teleport.com>
On Sun, 13 Jul 1997, Cowboy wrote:
> Can someone tell me if they have read and used the book Learning
> Perl by Randal Schwartz ..O'reilly pub. and tell me if the excersize
> in the front is suppose to be used with html???
The current edition of that book includes nothing about HTML or the web.
So the answer is, no, the exercises are not supposed to be used with HTML.
If you're having trouble getting the examples from the first chapter to
work, see whether you can ask your local expert to help you get started.
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: 12 Jul 1997 14:28:39 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: making refs in while() elegantly...
Message-Id: <5q84an$me1@lyra.csx.cam.ac.uk>
In article <33C75E99.7F168462@anon.com>, Chris Hostetter <me@anon.com> wrote:
>
> my @list;
> while (my %res = $result->fetchhash()) {
> my $hashref = \%res;
> push @list, $hashref;
> }
>
>doesn't seem to work...
What version of Perl are you using? That works for versions 5.004
onwards. Before that, "my" in the condition of a while wasn't very
useful, and you had to use the sort of tricks you finally found.
Mike Guy
------------------------------
Date: Sat, 12 Jul 1997 08:03:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chris Hostetter <me@anon.com>
Subject: Re: making refs in while() elegantly...
Message-Id: <Pine.GSO.3.96.970712075821.2012P-100000@kelly.teleport.com>
On Sat, 12 Jul 1997, Chris Hostetter wrote:
> my %res_while
> my @list;
> while (%res_while = $result->fetchhash()) {
> my %res = %res_while;
> my $hashref = \%res;
> push @list, $hashref;
> }
>
> any other suggestions?
It's too bad that that method doesn't return a reference to a hash. How
about this? Hope this helps!
push @list, $_ while $_ = { $result->fetchhash() } and %$_;
--
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, 12 Jul 1997 17:20:15 -0700
From: Chris Hostetter <me@anon.com>
Subject: Re: making refs in while() elegantly...
Message-Id: <33C81F3F.7A954F3B@anon.com>
in response to news/mail reply's regarding the way i wanted to do it
acctually working... it turns out my systems are stil running 5.003, and
probably won't be upgraded to 5.004_1 anytime today.
also...
Tom Phoenix wrote:
> It's too bad that that method doesn't return a reference to a hash. How
yeah (it's an Msql sub), now that refs are starting to get used widely,
it might not be a bad idea if all new modules started providing 2 forms
of every function that return hashes/arrays... one for "true"
hashes/arrays and one for refrences.
> about this? Hope this helps!
>
> push @list, $_ while $_ = { $result->fetchhash() } and %$_;
now this i like! I'll try it and see if it works with 5.003... but i
don't quite follow the last part (the "and %$_"). Is that just checking
that the scalar in $_ can be derefrenced as a hash?
---
------------------------ The Hoss Man --- "c4"
-------------------- Chris M Hostetter -- --Deep Blue
---------- hossman@uclink3.berkeley.edu - "Resign!"
http://www.rescomp.berkeley.edu/~hossman/ --Gary Kasparov
------------------------------
Date: Sat, 12 Jul 1997 18:06:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: making refs in while() elegantly...
Message-Id: <Pine.GSO.3.96.970712180050.3712H-100000@kelly.teleport.com>
On Sat, 12 Jul 1997, Chris Hostetter wrote:
> Tom Phoenix wrote:
>
> > It's too bad that that method doesn't return a reference to a hash.
>
> yeah (it's an Msql sub), now that refs are starting to get used widely,
> it might not be a bad idea if all new modules started providing 2 forms
> of every function that return hashes/arrays... one for "true"
> hashes/arrays and one for refrences.
No, you need only one, if it returns a reference.
%i_really_want_to_do_this_the_hard_way = %{ &i_return_a_hashref() };
> > push @list, $_ while $_ = { $result->fetchhash() } and %$_;
>
> i don't quite follow the last part (the "and %$_"). Is that just
> checking that the scalar in $_ can be derefrenced as a hash?
It's emulating the conditional in your original post. That conditional
returned true if the returned hash was non-empty. In this case, the left
side of the 'and' will always be true (since a reference is always true,
it's being used for its side-effect) and the right side is the condition
we want: true if there are elements in the hash. The syntax is documented
in perlref(1) and elsewhere. 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, 12 Jul 1997 05:46:59 -0700
From: perl guy <guitarweb@hotmail.com>
Subject: MORE -- script going zombie, missing read...
Message-Id: <33C77CC3.267C@hotmail.com>
Sorry, I made a typo, I was meaning to say "but I can't figure out how
it (the chat script) is actually reading the messages, but they aren't
being read by the user that's supposed to read them?"
And I suppose I should post the other parts of the chat script here as
well.. This is all anyone would want to know...
sub GetSessionInfo {
local($session, $fsubmit,$frames) = @_;
local($session_file);
local($temp,@fields, @f);
local($high_number, $high_message);
$session_file = "$session.dat";
open (SESSIONFILE, "$chat_session_dir/$session_file");
while (<SESSIONFILE>) {
$temp = $_;
}
chop($temp);
@fields = split(/\|/, $temp);
close (SESSIONFILE);
$high_message = &GetHighMessageNumber;
@f = @fields;
@fields[@fields - 1] = $high_message;
if ($fsubmit ne "on" && $frames ne "on")
{
open (SESSIONFILE, ">$chat_session_dir/$session_file");
print SESSIONFILE join ("\|", @fields);
print SESSIONFILE "\n";
close (SESSIONFILE);
}
(@f, $high_message);
}
sub GetHighMessageNumber {
local($last_file, @files);
opendir(CHATDIR, "$chat_room_dir");
@files = sort(grep(/msg/, readdir(CHATDIR)));
closedir(CHATDIR);
if (@files > 0)
{
$last_file = $files[@files - 1];
}
else
{
$last_file = "0000000";
}
substr($last_file,0,6);
}
sub MakeSessionFile {
local(@fields) = @_;
local($session, $session_file);
&RemoveOldSessions;
srand($$|time);
$session = int(rand(60000));
$session = unpack("H*", pack("Nnn", time, $$, $session));
$session_file = "$session.dat";
open (SESSIONFILE, ">$chat_session_dir/$session_file");
print SESSIONFILE join ("\|", @fields);
print SESSIONFILE "\n";
close (SESSIONFILE);
$session;
}
sub GetChatRoomInfo {
local($chat_room) = @_;
local($chat_room_name, $chat_room_dir, $x);
local($chat_room_number, $error);
$chat_room_number = -1;
for ($x = 1; $x <= @chat_room_variable; $x++)
{
if ($chat_room_variable[$x - 1] eq $chat_room)
{
$chat_room_number = $x - 1;
last;
}
}
if ($chat_room_number > -1)
{
$chat_room_name = $chat_rooms[$chat_room_number];
$chat_room_dir = $chat_room_directories[$chat_room_number];
}
else
{
$chat_room_name="";
$chat_room_dir = "";
$chat_room = "No Chat Room Found..." if ($chat_room eq "");
$error = "'$chat_room' not found;
&PrintChatError($error);
exit(0);
}
($chat_room_name, $chat_room_dir);
}
>
--
* Chatmaster/Admin Chat Hub:
http://www.chathub.com - http://chat.nstate.net
E-Mail Contact:
chatmaster@chathub.com, webmaster@chathub.com, sales@chathub.com,
info@chathub.com, admin@chathub.com, chatmaster@nstate.net
* Webmaster Northstate Net:
http://www.nstate.net
E-Mail Contact:
webmaster@nstate.net
------------------------------
Date: Sun, 13 Jul 1997 10:43:22 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Output to a file
Message-Id: <tcyangED974A.I8w@netcom.com>
Make sure you are not using C shell..... "| more" is a major bug.
==============================
David Zeng wrote after zapping the scum of the universe:
: Hi, there,
: I found out what the problem is. ^_^ I generated lots of prints for
: debugging purposes in the main loop. Since the printout is too long,
: I did not scroll to the end before I terminated the | more. Perl,
: running as a scripting language, only processes as far as I let it
: scroll down. Therefore, if I only scroll down 40 loops' contents, Perl
: only processes 40 lines.
--
====== Try the low-crossposting robomoderated 'alt.culture.taiwan' ======
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 11 Jul 1997 07:21:57 GMT
From: <albertom@eolo.com>
Subject: Paradox files access
Message-Id: <01bc8dcb$74ddc620$0200a8c0@alberto>
Hello:
Does anybody know the fastest way to open Paradox files with Perl???
I4m building a report generator for an application in Delphi and I4d like
to use Perl to generate the reports of the Paradox DB files but the problem
is performance and I want to avoid using SQL and so on... I4ve looking for
a module to acces DB engines but I can4t find Paradox
Thanks in advance
Alberto Mijares
------------------------------
Date: 11 Jul 1997 10:20:04 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Jacktran@webtv.net (Jack Tran)
Subject: Re: Perl 5.004 Socket from inetd
Message-Id: <8ciuyhy08r.fsf@gadget.cscaper.com>
>>>>> "Jack" == Jack Tran <Jacktran@webtv.net> writes:
Jack> I have a socket server and client that work very well. They use port
Jack> 5050 to pass a file from the server to client. Insted of running the
Jack> server module constantly, I like to run it from inetd, so when the
Jack> connection arrives from the client it wakes up and passed the file. I
Jack> made an entry in /etc/services for port 5050 and used that name to run
Jack> my server in /etc/inetd.conf. All this runs on Sun Solaris 2.5.1.
Jack> Here is my problem: When the client starts a socket connection to the
Jack> server on port 5050, the server starts ( ps -ef shows the server is
Jack> running) however nothing happens. I believe once the server and
Jack> client connect, I need to get them off port 5050 to another port but I
Jack> don't know how to do this?
If you write a "standalone" server that opens 5050, you'll need to
change that server to have it run from inetd, because inetd will now
be the one listening to 5050. Your inetd-compatible server will
simply handle *one* connection already open on STDIN and STDOUT. So
your inetd-version of the server will have *no* socket code in it.
Jack> Please respont to my e-mail
Nope. If I spend the few minutes to compose this answer, it surely
doesn't need to be a private consultation for you. I'm posting it
publicly as well. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 416 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 13 Jul 97 13:06:28 GMT
From: mhp@ns0.netcraft.co.uk (Mike Prettejohn)
Subject: Perl Developer required at Netcraft, Bath, England
Message-Id: <mhp.868799188@ns0.netcraft.co.uk>
Netcraft needs to recruit a developer with a strong Unix/Perl background,
to its team based in Bath, England.
Projects would initially involve working on a range of commercial services
broadly related to the Netcraft Web Server Survey
http://www.netcraft.com/survey/
but would also include other customer funded projects typically involving
internet publishing and TCP/IP network management.
Applicants would need to demonstrate;
A keen interest in internet technology is very important, together
with an attention to detail, and a desire to find things out empirically
rather than rely on conjecture.
some evidience of conspicuous achievement, and a strong computing
background, probably but not necessarily including a First or 2:1 degree
in Computer Science.
ability and experience with Unix systems programming and systems
administration, and Perl (consistent with making effective use of the CPAN
and developing web applications with cgi or mod_perl) is essential.
Experience with FreeBSD, freewais-sf, SQL, postgres, Apache, Stronghold,
SSL, HTTP, and NT is also very welcome.
Expressive verbal and written communications skills.
A well developed sense of precaution; a person who likes to plan for the
future with suitable programming abstractions, automated test suites &
version control, etc, and generally feel that they are in control of their
own destiny.
General
Applications from outside the UK are welcome if they have
citizenship of an EU country or a current work permit for the UK
and an excellent command of the English language.
Applications from people considering a move from an academic environment
are also very welcome.
About Netcraft
Netcraft is an networking consultancy based in Bath, England and is
well known worldwide for its Web Server Survey, which is a widely
used empirical metric for the number of web sites and the relative
popularity of web server software on the internet.
Netcraft will turnover in excess of 1.5 million pounds in the year ending
September 1997, and is profitable, with growth funded from cashflow.
Clients include IBM, Hewlett Packard, Sun Microsystems, and Microsoft.
Mike
--
Mike Prettejohn http://www.netcraft.com
mhp@netcraft.com Phone +44 1225 447500 Fax +44 1225 448600
Netcraft Rockfield House Granville Road Bath BA1 9BQ England
------------------------------
Date: Sun, 13 Jul 1997 12:54:35 GMT
From: s_haber@ira.uka.de (Marc Haber)
Subject: Perl for Win32::Registry Set Value question
Message-Id: <5qaj32$mhk$3@nz12.rz.uni-karlsruhe.de>
Hi!
I have the following perl code designed to run under Windows 95:
use Win32::Registry;
my $gagakey;
$main::HKEY_CURRENT_USER->Open("gaga", $gagakey);
$gagakey->SetValue( "gagasub",REG_SZ,"gagavalue");
I would like to add a value named "gagasub" with the value "gagavalue"
to the existing key HKEY_CURRENT_USER\gaga and expect the code to do
just this. Instead, I get a subkey HKEY_CURRENT_USER\gaga\gagasub with
its standard value named "Standard" set to "gagavalue".
What am I doing wrong?
The documentation on Win32::Registry is sparse at least and contains
plain wrong information. It took me two hours of debugging before
finding out that Open's arguments are reversed in the documentation,
yielding "attempt to modify read-only value".
Any hints will be appreciated.
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | s_haber@ira.uka.de
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Sat, 12 Jul 1997 07:16:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: datta@hcla.com
Subject: Re: perl script inside perl script
Message-Id: <Pine.GSO.3.96.970712071432.2012H-100000@kelly.teleport.com>
On Fri, 11 Jul 1997 datta@hcla.com wrote:
> How to call a perl script inside a perl script?
The same way you call a shell script from inside a perl script. Check out
system(), documented in perlfunc(1). There are other ways to do it, also
documented. 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: 12 Jul 1997 16:55:02 -0400
From: men2@auto.med.ohio-state.edu (Mark Nielsen)
Subject: Re: Perl5 for win/dos
Message-Id: <5q8qv6$r0g$1@auto.med.ohio-state.edu>
I solved that problem in this way, have a batch file run the program like
perl Script.pl
pause
That will take care of the problem. If your perl script actually works
but not correctly, put something like
$Input = <STDIN>;
in the perl script to prompt the user for input.
Mark
In article <33be8839.9115713@news.bright.net>,
Rikky Alessi <ralessi@bright.net> wrote:
>I'm looking for a perl for perl5( i already have 4) that runs in
>windows and dos. I mean that if I go to run and type
>
>c:\perl\perl c:\cgi\gb.pl
>
>It will run the script and do whatever I tell it to do. I've found
>some like this but they don't work because it runs the script then
>closes the window so I can't see if it worked correctly. If you can
>find something like this drop me a line.
>
>
--
---------------------------------------------------------------------------
Mark Nielsen men2@auto.med.ohio-state.edu or gytres+@osu.edu
Systems Specialist
The Ohio State University
------------------------------
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 731
*************************************