[19186] in Perl-Users-Digest
Perl-Users Digest, Issue: 1381 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 26 06:05:46 2001
Date: Thu, 26 Jul 2001 03:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <996141912-v10-i1381@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 26 Jul 2001 Volume: 10 Number: 1381
Today's topics:
Addressing WinNT Task Manager <madewildeNOSPAM@hotmail.com>
Compiling Perl with DBM support <somewhere@in.paradise.net>
Re: don't laugh (case usage for variables) <goldbb2@earthlink.net>
Re: don't laugh (case usage for variables) <wyzelli@yahoo.com>
Re: dynamically resizing pictures for a web page (Sebastian)
Re: Email Question (David Efflandt)
errata for book "PERL DEBUGGED"? (no url in book!) (David Combs)
FAQ: Does Perl have a Year 2000 problem? Is Perl Y2K c <faq@denver.pm.org>
Re: Finding a word in a sorted list. (Eric Bohlman)
Fork(): How to find out? ... <xhotarek@fi.muni.cz>
Has anyone see this book? <mnemotronic@mind\no-spam/spring.com>
Re: Has anyone see this book? <ron@savage.net.au>
Re: how to sort by the Nth ip addr in string? <goldbb2@earthlink.net>
Re: Incomplete output from crontab email: running shell (David Efflandt)
Inline and libraries <Florian.Albrecht@alcatel.de>
Re: kill idle user using unix w (Anno Siegel)
Re: ksh script porting problem <goldbb2@earthlink.net>
Re: match regexp pattern in a special context? <bwalton@rochester.rr.com>
Re: MSI Perl package installation from ActivePerl for w <ron@savage.net.au>
Re: Multi tuple hashes <bwalton@rochester.rr.com>
Re: Multi tuple hashes <pne-news-20010726@newton.digitalspace.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 26 Jul 2001 11:06:54 +0200
From: Me <madewildeNOSPAM@hotmail.com>
Subject: Addressing WinNT Task Manager
Message-Id: <3B5FDDAE.CBEF2A2B@hotmail.com>
Hey there,
Does anyone have experience with addressing the Windows (yuk) NT Task
Manager?
Or at any rate retrieving process id's from running windows programs (so
NOT the ones you create yourself - those I can find...)?
I have some experience addressing Office Applications (yuk) with Visual
Basic (yuk), but that 'flyer doesn't go up' as we say in holland.
So, all you gurus out there, please help..!
Cheers,
menno
(harrycolbert@hotmail.com)
------------------------------
Date: Thu, 26 Jul 2001 15:34:36 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Compiling Perl with DBM support
Message-Id: <H%N77.46$od6.507940@news.interact.net.au>
I'm running Mandrake 8 and was originally running the Perl 5.6.0 RPM that
came with the CD. As the RPM doesn't allow you to manually install modules,
I compiled up Perl 5.6.1
I was successfully using neomail (http://neomail.sourceforge.net/) with the
RPM'ed Perl version, but when I installed Perl 5.6.1 it didn't work. This
was due to it not finding the DBM libraries.
It uses the AnyDBM_File module, ie:
BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File) }
I definately have the GDBM RPM installed (libgdbm1-1.8.0-14mdk), but when I
tried to run neomail, the AnyDBM_File module barfed with the message:
"No DBM package was successfully found or installed"
I chose all the defaults when compiling Perl 5.6.1, so I can't remember if
there is a question in there about DBM support.
I noticed in the previous Perl version there was a GBM object file:
/usr/lib/perl5/5.6.0/i386-linux/auto/GDBM_File/GDBM_File.so
so I copied it to the 5.6.1 location (in /usr/local) and that fixed the
problem with AnyDBM_File.
Now, obviously that is a hack workaround to fix the problem. Should I just
be compiling Perl 5.6.1 again, or are there some other settings I need to
look at?
------------------------------
Date: Thu, 26 Jul 2001 03:46:35 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: don't laugh (case usage for variables)
Message-Id: <3B5FCADB.79D816A2@earthlink.net>
Abigail wrote:
>
> --Rick (no_trick@my-deja.com) wrote on MMDCCCLXXXIV September MCMXCIII in
> <URL:news:3Xj77.50788$C81.4281160@bgtnsc04-news.ops.worldnet.att.net>:
> }}
> }} Yes.. It looks that way at first and you are certainly the one to
> }} decide whether to use upper case for your own labels. The advantage to
> }} using lower-case for your own variables is that you don't have to worry
> }} about conflicting with future reserved words. In addition to that,
> }} conforming to common practice makes it easier to collaborate with
> }} others.
>
> Interesting that you say this.
>
> First of all, variables won't conflict easily with reserved words
> because scalars, arrays and hashes have funny symbols in front of them,
> and reserved words don't.
>
> However, your reasoning of not conflicting with future reserved words
> is usually used as an argument to use all caps file (and directory)
> handles - which don't have funny symbols. This is because it's supposed
> to be true that new reserved words in Perl will be all lower case.
>
> Right.
>
> Perl 5.005 gave us INIT and Perl 5.6.x gave us CHECK and made UNTIE
> special in certain cases.
>
> Of course, we also got 'our' and 'qr'.
I dunno about 'qr', but 'our' was a "future reserved word", even in
older perls.
> It seems that only TiTleCaSe prevents you from potential conflicts.
For variables, nearly all perl builtins whose names aren't funny symbols
are all caps (%ENV, @ISA, %ISA, %SIG, $AUTOLOAD) (the exceptions being
$a and $b, used by sort).
So for variables, it seems that it's highly likely that any new special
perl variables will also be in all caps, so it's probably safe for any
variables of our own to be lowercase or titlecase.
AFAIK, all perl keywords are lowercase (my, our, if, while, etc) (no,
there is no "etc" keyword... I wonder what it would do? :))
For subs, *most* perl builtins are lowercase, the exceptions being
BEGIN, CHECK, INIT, END, AUTOLOAD, and DESTROY -- the functions
mentioned in perltie don't count, since if you don't tie to the package,
it's not a concern. Umm, Abigail, I don't see UNTIE anywhere in my
docs... which version of perl is that? 5.6.<what?>
And of course, we can use just about anything we want for filehandles,
as long as it won't conflict with a builtin function or reserved word.
Since its a seperate namespace from variables and normal subroutines,
so we don't have to worry about new subroutines or variables becoming
special. We also don't have to worry about clashes with existing
filehandles, since the only predefined ones are STDIN, STDOUT, and DATA,
and none have ever been added since the beginning of Perl. This means
that TitleCase and UPPERCASE are both acceptable for filehandles.
--
I need more taglines. This one is getting old.
------------------------------
Date: Thu, 26 Jul 2001 18:28:19 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: don't laugh (case usage for variables)
Message-Id: <7TQ77.4$zJ6.480@vic.nntp.telstra.net>
"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3B5FCADB.79D816A2@earthlink.net...
>
> AFAIK, all perl keywords are lowercase (my, our, if, while, etc) (no,
> there is no "etc" keyword... I wonder what it would do? :))
#!/usr/local/bin/perl etc # saves all that typing of -w and 'use strict'
etc etc # this is the bulk of the program and takes DWIM to its logical
extremes
:)
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: 25 Jul 2001 18:30:43 -0700
From: dethtoll@yahoo.com (Sebastian)
Subject: Re: dynamically resizing pictures for a web page
Message-Id: <ea245403.0107251730.64045435@posting.google.com>
Daniel Davidson <danield@life.uiuc.edu> wrote in message news:<3B5F04F3.49405263@life.uiuc.edu>...
> All right here is the problem. I need to be able to take a 4MP photo
> and resize it so that people on slower connections dont have to leave
> their computer running at night to view one of them. Sounds simple,
> just run imagemagick and resize to something smaller (~800x600).
> However at the same time, I have people on the higher end who want to
> see the full size to do publications. And with the quantity of photos
> we will be handeling, storing both is not an option (well, that is what
> I was told anyway). The best solution would be to resize the image with
> imagemagick, then let the server get the resized picture. The only way
> I can think of how to do this is to have a temporary - resized image
> that the browser uses to load the picture. However when I think of the
> problems that I will run into by doing it this way, I start to go nuts.
> Anyone know of a way to display directly from the servers memory or some
> other better way?
>
> thanks,
>
> Dan
Hmmm. Having never used imagemagick, please consider my thoughts
suspect from the start. But why not script the resize to happen
on-the-fly, and simply output the resized image to the browser as
binary content? Done with a perl program that is seperate from your
html-content scripts, and requested by the browser in an image tag
like <img src='/cgi-bin/makelowres.pl?img=1234'>.
This way, you only store it in memory until the program exits.
Depending on usage though, we're talking about some heavy processing
power and ram on the server in order to run this kind of thing at any
speed.
------------------------------
Date: Thu, 26 Jul 2001 03:12:51 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Email Question
Message-Id: <slrn9lv2li.n8e.see-sig@typhoon.xnet.com>
On Wed, 25 Jul 2001 12:22:28 GMT, Blnukem <blnukem@hotmail.com> wrote:
> Hi Group
> I wrote a script that allows the user to upload a report and then send
> emails a retrieval link to some recipients for viewing it works great.
> Except in AOL the hyperlink in the mail body shows up as regular text not as
> a link any ideas? I've tried adding "print MAIL "Content-type:text/html\n";"
> But that kills the link in all the browsers here is the mail portion of the
> script:
>
> foreach (@mail_list){
>
> open(MAIL, "|$mail_path -t");
> print MAIL "To: $_\n";
> print MAIL "From: $returnemail ($from)\n";
> print MAIL "Subject: $subject\n";
> print MAIL "$body\n";
> print MAIL "Please click the link below to retrieve your report:\n";
> print MAIL "$url/$cgi_path/retrieve.pl?showme=$random_num\n\n";
> print MAIL "";
>
> close(MAIL);
> }
One problem is that your e-mail might be all headers and no body, which is
not a Perl problem. The headers end at the first blank line, which
appears to be _after_ the URL (depending upon what $body contains).
Perhaps you want to put a double newline at the end of your Subject line.
Is it a full http:// URL or does it start with a hostname? That can make
a difference.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 26 Jul 2001 04:55:48 -0400
From: dkcombs@panix.com (David Combs)
Subject: errata for book "PERL DEBUGGED"? (no url in book!)
Message-Id: <9joluk$ke1$1@panix6.panix.com>
I bought a copy of this new book, "Perl Debugged", and
have found what I (mistakenly?) think are errors in
his example programs.
But unlike O'Reilly books, which have easy-to-find
errata, and they tell you so in the intro, with
this book (addison wesley), there is NO mention at
all of any errata, or where to send any you might find,
or where to get a copy of what's been turned in --
OR even where to get already-typed-in code from the
book.
Nothing!
---
Did I look at addison wesley. No way! I tried that
once before; just about *impossible* to find *anything*
via their site.
(Does no higher management ever look at O'Reilly's site?
What a bunch of idiots for not doing that!)
----
Anyway, does anyone here know the url for the errata,
etc?
It'd be real nice to have it...
---
Thanks!
David Combs
------------------------------
Date: Thu, 26 Jul 2001 06:17:05 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
Message-Id: <BBO77.70$os9.209238016@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
Does Perl have a Year 2000 problem? Is Perl Y2K compliant?
Short answer: No, Perl does not have a Year 2000 problem. Yes, Perl is
Y2K compliant (whatever that means). The programmers you've hired to use
it, however, probably are not.
Long answer: The question belies a true understanding of the issue. Perl
is just as Y2K compliant as your pencil--no more, and no less. Can you
use your pencil to write a non-Y2K-compliant memo? Of course you can. Is
that the pencil's fault? Of course it isn't.
The date and time functions supplied with Perl (gmtime and localtime)
supply adequate information to determine the year well beyond 2000 (2038
is when trouble strikes for 32-bit machines). The year returned by these
functions when used in a list context is the year minus 1900. For years
between 1910 and 1999 this *happens* to be a 2-digit decimal number. To
avoid the year 2000 problem simply do not treat the year as a 2-digit
number. It isn't.
When gmtime() and localtime() are used in scalar context they return a
timestamp string that contains a fully-expanded year. For example,
"$timestamp = gmtime(1005613200)" sets $timestamp to "Tue Nov 13
01:00:00 2001". There's no year 2000 problem here.
That doesn't mean that Perl can't be used to create non-Y2K compliant
programs. It can. But so can your pencil. It's the fault of the user,
not the language. At the risk of inflaming the NRA: ``Perl doesn't break
Y2K, people do.'' See http://language.perl.com/news/y2k.html for a
longer exposition.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.16
--
This space intentionally left blank
------------------------------
Date: 26 Jul 2001 03:19:12 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Finding a word in a sorted list.
Message-Id: <9jo27g$8tt$1@bob.news.rcn.net>
Mario Rizzuti <mariorizzuti@yahoo.com> wrote:
> I have a fixed-length-records file where:
> * each record is 18 bytes made by an username (12 bytes) and a number
> (6 bytes).
> * the records are sorted alphabetically.
> I am wondering what is the fastest possible way to find the associated
> numbers of a given list of usernames?
[Snip binary search code]
Just for the hell of it, you might want to see what kind of performance
you get by setting $/ to \18, reading the file into an array, and
repeatedly grepping the array (using a test with substr and eq rather than
a regex). Sure, the time complexity of a binary search is better than a
linear search like grep does, but one of the dirty little secrets of
algorithm optimization is that for small enough input, an algorithm with a
higher time complexity will often outperform one with a lower time
complexity because the individual operations involved are faster (in the
case of grep, you're talking about a linear search implemented in highly
optimized C code vs. a binary search that requires dispatching lots of
Perl operations).
Of course, this presumes that the file is small enough to load into
memory. If it isn't, the way to get a significant speedup is to replace
the flat file with a tied database (e.g. DB_File) hash. If that's not
practical because of lots of other programs having to access the flat
file, then the next best solution is to use a tied database hash as an
index to the flat file (e.g. the values are indexes into the flat file
rather than the actual numbers). Of course, the index has to be kept in
sync with any changes to the flat file. If you can't easily do this, then
you could create an index "on the fly" each time you have to search for a
batch of users; whether this will give you an improvement will depend on
how many users you look up at a time; I suspect the break-even point would
be around three (I'm guessing that building the index would take about
twice as much time as searching through the whole file once; that may be
overly conservative).
------------------------------
Date: Tue, 24 Jul 2001 18:42:59 GMT
From: Vit Hotarek <xhotarek@fi.muni.cz>
Subject: Fork(): How to find out? ...
Message-Id: <Pine.SGI.4.21.0107242012290.26237579-100000@aisa.fi.muni.cz>
Hello,
Is there any way how to find out,
how many forked children are actually
running?
When I run the program below, everything
works OK, but when it gets to (*), I have
wrong number of entries in the @children array.
E.g., I am seeing (ps command) 3 running processess,
but scalar @children yields zero or any other
wrong value.
Could you please help with solving this problem?
Many thanks.
Vit Hotarek
.....
$SIG{CHLD} = \&wait_for_child;
$| = 1;
$i = 1;
@children = ();
while ($i < 6) # to do 5 children
{
$pid = fork();
if ($pid == 0) # I am a child
{
do_something();
exit(0);
}
elsif ($pid > 0) # I am a parent
{
push(@children, $pid); # Push $pid into @children
# scalar @children = nr. of running children
}
...
$i++;
}#end while
(*)
while (scalar(@children) > 0) # Empty @children = no running children
{
sleep(1);
}
# It should loop until all children are finished
.......
exit(0);
sub wait_for_child #REAPER
{
my ($child, $x);
$child = wait;
$x = shift(@children); # scalar @children -= 1;
# Pop an entry from @children.
# = decrease nr. of running children
$SIG{CHLD} = \&wait_for_child;
}
------------------------------
Date: Wed, 25 Jul 2001 21:38:04 -0600
From: pt <mnemotronic@mind\no-spam/spring.com>
Subject: Has anyone see this book?
Message-Id: <3B5F909B.3FF4C3F6@mindspring.com>
Graphics Programming with Perl -- by Martien Verbruggen
http://www.amazon.com/exec/obidos/ASIN/1930110022/qid=996118400/sr=2-2/102-1602180-3705744
Remove the obvious anti-spam to reply.
------------------------------
Date: Thu, 26 Jul 2001 14:08:11 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Has anyone see this book?
Message-Id: <KLM77.98021$Rr4.599725@ozemail.com.au>
Not published yet. Due December :-(.
http://www.manning.com/verbruggen/index.html
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
pt <mnemotronic@mind\no-spam/spring.com> wrote in message news:3B5F909B.3FF4C3F6@mindspring.com...
> Graphics Programming with Perl -- by Martien Verbruggen
>
> http://www.amazon.com/exec/obidos/ASIN/1930110022/qid=996118400/sr=2-2/102-1602180-3705744
>
>
>
>
> Remove the obvious anti-spam to reply.
------------------------------
Date: Thu, 26 Jul 2001 02:37:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how to sort by the Nth ip addr in string?
Message-Id: <3B5FBA9F.C0510A15@earthlink.net>
Mark W. Dufault wrote:
>
> Any ideas on how best to sort by the Nth IP match in the string. This
> algorithm works on the first IP address it comes across but I would
> like add the ability to sort by the Nth occurance of an IP address.
>
> file.cfg below...
> static (inside,dmz2) 172.16.4.2 10.1.3.5 netmask 255.255.255.255 0 0
> static (inside,dmz1) 172.16.3.4 10.2.5.7 netmask 255.255.255.255 0 0
> static (inside,dmz3) 172.16.4.1 10.5.6.8 netmask 255.255.255.255 0 0
> static (inside,dmz2) 172.16.32.1 10.2.3.4 netmask 255.255.255.255 0 0
>
> The above lines are the input...
use strict;
use warnings;
my $N = 1;
sub sortbyip {
map { substr, $_, 4 }
sort
map {
my $Nth = (m/(\d+\.\d+\.\d+\.\d+)/g)[$N];
pack("C4", $Nth =~ m/(\d+).(\d+).(\d+).(\d+)/) . $_;
} @_;
}
> sub sortbyip {
> @out = sort {
> pack('C4' => $a =~
> /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
> cmp
> pack('C4' => $b =~
> /(\d+)\.(\d+)\.(\d+)\.(\d+)/)
> } @_ ;
> return @out ;
> }
This is the classic example of when to use the GRT transformation, which
is what I did. Also, you don't need to assign to a temporary array and
return it, since a sub will generally return the last expression in the
block.
> while ( defined($filename = glob("*.cfg")) ) {
It's not necessarily bad (it may have been fixed), but some perls have a
memory leak if you use glob in a scalar context. Instead, use glob in a
list context:
foreach my $filename (glob("*.cfg")) {
This is one case where foreach should almost always be preferred to
while.
Also, you need to declare @static and @conduit someplace; this is as
good a place as any.
my (@static, @conduit);
> open (INPUTFILE, "< $filename") || die "can't open $filename: $!" ;
Good that you checked the output, bad that you used "||" not "or". It
works here, but if you get into the habit of doing "|| die..." instead
of "or die..." you'll get really unexpected errors when you want
something which needs list context, but is turned into scalar context
due to the "||" operator.
> @config = (<INPUTFILE>) ;
> foreach $line (@config) {
Eww. Don't slurp the file unless you absolutely need to.
Replace the above two lines with:
while( <INPUTFILE> ) {
> if ($line =~ /^static/) { push (@static,$line) ; } ;
> if ($line =~ /^conduit/) { push (@conduit,$line) ; } ;
You've got extraneous semicolons. It would look better without them.
if( /^static/ ) { push @static , $_ }
if( /^conduit/ ) { push @conduit, $_ }
> }
And you forgot to close INPUTFILE.
> print "-" x 79, "\n", "File = $filename\n", "-" x 79, "\n" ;
This would look nicer as three seperate print statements:
print "-" x 79, "\n";
print "File = $filename\n";
print "-" x 79, "\n";
> print (sortbyip(@static), sortbyip(@conduit)) ;
And this would look nicer as two seperate print statements:
print sortbyip @static;
print sortbyip @conduit;
> }
Besides learning about the Guttman-Rosler Transform and the Schwartzian
Transform, you should also read the perlstyle document.
--
I need more taglines. This one is getting old.
------------------------------
Date: Thu, 26 Jul 2001 03:20:33 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: Incomplete output from crontab email: running shell scripts from a perl script
Message-Id: <slrn9lv340.n8e.see-sig@typhoon.xnet.com>
On 25 Jul 2001, tenpercenter <tenpercenter54@hotmail.com> wrote:
> I am running a perl script from my crontab. The perl script that I
> run executes shell scripts at the command line. My crontab sends me
> the output from this perl script that runs shell scripts. However, if
> I run the shell scripts directly from the crontab itself I get a
> different output (the output that I want).
>
> Why would a perl script that runs a shell script give me a different
> "cron job" output then the shell script itself?
>
> I don't think it is a perl problem but I am running the shell scripts
> from perl with the following command: `$shell_script`.
That assigns the STDOUT of the script to $_ unless you assign it to a
variable and/or print that at some point. Does it work like you expect if
you do: print `shell_script`; [or maybe you want to use system()]?
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Thu, 26 Jul 2001 10:10:35 +0200
From: Florian Albrecht <Florian.Albrecht@alcatel.de>
Subject: Inline and libraries
Message-Id: <3B5FD07B.D25CE6E3@alcatel.de>
Hi there!
My problem is not very complex, I think! Anyway, I can't manage it. I am
working on a Win32 system with Perl 5.6 and MSVC++ 6. I wrote a module
in C with Inline. During developement everthing was OK. Now that I tried
to install it on a "clean" enviroment, I have the problem with chrapi.h
and chrapi.lib (just a library, both in the same directory as
myModule.pm)!
First the include file chrapi.h was not found. So copied it to the
include directory from VC. This is my first problem! I do not want the
user to copy this to a certain directory. How can I tell nmake that this
file is in the same directory as myModul.pm?
I have the following line in my source use Inline (C => Config => LIBS
=> '-lchrapi');
Second problem is, that now as this file was found, I get linker errors
(unresolved symbols). Seems that chrapi.lib is not found. What is the
correct way to say where this library is located? ( I also tried
MYEXTLIBS, but then nmake doesn't know how to make chrapi.lib.)
Thanks in advance!
--
ciao,
;-) Flo
KMR=29.05
Powered by KMCount ;)
------------------------------
Date: 26 Jul 2001 08:09:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: kill idle user using unix w
Message-Id: <9joj80$bi6$1@mamenchi.zrz.TU-Berlin.DE>
According to eric leung <eric.leung@philips.com>:
> Hi
> I want using unix command "w" and those users idle more than 30 minutes
> without change on JCPU time.
> How to write perl ?
What have you tried so far?
Anno
------------------------------
Date: Thu, 26 Jul 2001 01:13:22 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ksh script porting problem
Message-Id: <3B5FA6F2.3FA649B4@earthlink.net>
John Blevin wrote:
>
> I have a UNIX ksh script that I would like to port to perl.
> The ksh script has a few lines like:
>
> . env_file_1
> . env_file_2
>
> It is "dotting in" these environment configuration files which define
> environment variables used in this script.
>
> I would like to port over this script without yet having to change
> these environment files. Is there a way I can port over these lines?
> The system(), exec() and backtick don't work.
The problem with system, exec, and qx, is that they are started in their
own process, and thus don't affect their caller's environment.
Fortunatly, you can use the "env" program to print out the current
environment of the program which called it.
foreach( qx[. env_file_1;. env_file_2;env] ) {
chomp;
my ($key,$val) = split /=/, $_, 2;
$ENV{$key} = $val;
}
You probably shouldn't do it quite like this -- it's not exactly safe.
It would be better to describe a pattern of what shell variables you
want, and then set *only* those. For example, if you have some
configuration scripts which need to set variables for DBI, then
something like this should be ok:
foreach( qx[. env_file_1;. env_file_2;env] ) {
chomp;
my ($key,$val) = split /=/, $_, 2;
next unless $key =~ m/^DB[ID]_/;
$ENV{$key} = $val;
}
Here's an even more restrictive way of getting a limited set of
variables.
my @DBI_ENV_VARS = qw( DSN DRIVER AUTOPROXY USER PASS DBNAME TRACE );
my @DBD_ENV_VARS = ... # depends on the database, I think.
$_ = "DBI_$_" for ( @DBI_ENV_VARS );
$_ = "DBD_$_" for ( @DBD_ENV_VARS );
my $get_db_vars = join "", map "echo \$$_;",
@DBI_ENV_VARS, @DBD_ENV_VARS;
chomp( $ENV{@DBI_ENV_VARS, @DBD_ENV_VARS} =
qx[. env_file_1;. env_file_2;$get_db_vars] );
This only brings in a fixed, named set of variables. It's much more
cumbersome than the prior example, and if the driver changes, then not
only your environment-variable-setting-scripts need to change, then the
perl code with your list of what names to bring in from those scripts
also needs to change... in other words, it may be too restrictive, and
unable to deal gracefully with upgrades.
However, for other purposes than DBI, this type of mechanism may be
preferred -- especially if you are storing the results into a set of
named variables, and are not computing the echo lines, eg:
chomp( my ($foo, $bar) = qx'
. somefile
echo $FOO
echo $BAR' );
Note that I used ' for the quoting character, otherwise I would have had
to escape the $ characters.
--
I need more taglines. This one is getting old.
------------------------------
Date: Thu, 26 Jul 2001 01:38:05 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: match regexp pattern in a special context?
Message-Id: <3B5F7478.6053DC29@rochester.rr.com>
"MMX166+2.1G HD" wrote:
>
> hmm... there is, e.g., a html doc,I want to parse tags in it and match
> the attribute="value" pairs which are inside the <tag ... >.
> for example:
> ><img src="images/logo.gif" width="120" height="120" > don't choose me.I am a wrong name="alex"
> how to match the src="images/logo.gif", width="120" and height="120"
> but avoid the name="alex". thus neither /(\w+)=\"(.*?)\"/ nor
> /(?:<\w+\s+)(\w+)=\"(.*?)\"(?:\s*[^>]*\/?>)/ is correct.
> videlicet, match all the html attributes (name="value" pair which is
> between "<" and ">").
> any hint?
> my badly solution is to separate whole document into tags, then
> extract the attributes, at last, match name="value".
HTML parsing is more complicated that you think. Stick to the tried and
true solutions already done for you, like use HTML::Parser;, perhaps.
It's probably already installed on your hard drive. You can get this
advice yourself with:
perldoc -q HTML
--
Bob Walton
------------------------------
Date: Thu, 26 Jul 2001 12:26:00 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: MSI Perl package installation from ActivePerl for win98
Message-Id: <XfL77.97982$Rr4.596820@ozemail.com.au>
Razvan
See below.
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
Razvan Mihailescu <razvan.mihailescu@gartner.com> wrote in message news:451d8b00.0107251428.51d08d78@posting.google.com...
> Hello,
>
> 1. I got MSI for win98 from this link to install Perl on my machine:
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/
OK so far.
> 2. I ran the .msi file I got from ActivePerl
OK.
> 3. I typed "perl -v" to test, and it told me I didn't have
> "win32gnu.dll"
Hmm. I believe this means you've downloaded part of the GNU utils for Windows [1], and they are in your path in front of the Perl
you just installed.
[1] Go here:
http://savage.net.au/Ron/PerlMagick.html
and look under:
1 Prepare
for:
http://savage.net.au/Ron/GNU-Utils.html
Delete the perl.exe which comes with the GNU utils for Windows.
Oh, BTW: 'Card flourishes' asked you 'Have you got a webserver?' Ignore him.
------------------------------
Date: Thu, 26 Jul 2001 03:26:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Multi tuple hashes
Message-Id: <3B5F8DED.134B9507@rochester.rr.com>
Paul wrote:
>
> The following code produces FooBar
>
> $areas{1}{A} = 1;
> $areas{2}{A} = 1;
>
> $areas{1}{A}{2} = "Foo";
> print $areas{1}{A}{2};
> $areas{2}{A}{2} = "Bar";
> print $areas{1}{A}{2};
>
> I expected FooFoo (why should $areas{2} have any bearing on {1}?). If
> anyone can explain, I would be very grateful.
...
> Paul
I can explain. First you create hash key 1 in hash %areas, the value of
which is a hash reference to an anonymous hash with one key "A" and its
value 1. Then your create hash key 2 in hash %areas, the value of which
is a hash reference to another anonymous hash with one key "A" and its
value 1.
Then in the statement $areas{1}{A}{2}="Foo" you take the
already-assigned value of $areas{1}{A} (which is 1, remember) and you
use it as a symbolic reference, thereby creating hash %1, which has key
2 with value "Foo". Then you print that out. Then you take the
already-assigned value of $areas{2}{A} (which is again 1) and you use it
as a symbolic reference, thereby setting key 2 of hash %1 to "Bar".
With the print statements, you are actually printing key 2 of hash %1
each time, which value changed between the two print statements. It
wouldn't matter if you referenced that value via $areas{1}{A}{2} or
$areas{2}{A}{2}, since they are both the value of the same key of the
same hash, namely $1{2}.
If you don't believe me, add:
for(keys %1){print "\nhash 1{$_}=$1{$_}"}
to the end of your example and see. Or use:
perl -d program.pl
and use the debugger command
x %1
as you step through the program with the s debugger command. You can
also use V to see what variables exist at each step, noting the popping
into existence of %1 at the ...="Foo" line.
Note that if a string already exists when a reference is looked up, a
symbolic reference will occur. See:
perldoc perlref
in particular the section on symbolic references. The moral of the
story? Don't assign anything to the upper levels of a list-of-lists type
structure, either before or after building the structure. In that case
Perl won't do what you meant (unless you meant to screw up or do
masters-level obfuscation :-)=. That is true for arrays as well as
hashes, or combos thereof.
--
Bob Walton
------------------------------
Date: Thu, 26 Jul 2001 08:03:41 +0200
From: Philip Newton <pne-news-20010726@newton.digitalspace.net>
Subject: Re: Multi tuple hashes
Message-Id: <lqavlt88qdhc3mlfvhmdbvh8nrr7n81sor@4ax.com>
On Thu, 26 Jul 2001 03:26:46 GMT, Bob Walton <bwalton@rochester.rr.com>
wrote:
> and use the debugger command
>
> x %1
I prefer x \%1 usually, since that gives me a key => value
representation, rather than a flat list key, value, key, value, with
each key or value on a separate line. (It also sorts the keys, which is
sometimes useful.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 1381
***************************************