[21874] in Perl-Users-Digest
Perl-Users Digest, Issue: 4078 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 7 06:06:52 2002
Date: Thu, 7 Nov 2002 03:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 7 Nov 2002 Volume: 10 Number: 4078
Today's topics:
(undef || LIST) vs (LIST || LIST) (Bernhard Kick)
Re: (undef || LIST) vs (LIST || LIST) (Villy Kruse)
Re: (undef || LIST) vs (LIST || LIST) <bobesch@letras.net>
Re: A Unix guy moving to Windows 2000 (Tad McClellan)
Re: A Unix guy moving to Windows 2000 (Helgi Briem)
Re: fork() and socket? edgue@web.de
Re: How to correctly use AUTOLOAD in derived class? <tassilo.parseval@post.rwth-aachen.de>
Re: How to guarantee process ID stays with web connecti (tî'pô)
How to locate Perl Interpreter <nospam@satyam.net.in>
LWP and ebay (Alexander Stuckenholz)
Makefile.PL @INC PREFIX LIB <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Perfecting my Perl <nobody@noplace.com>
Re: Perl module to read mails from Microsoft Outlook <ron@savage.net.au>
Re: Perl module to read mails from Microsoft Outlook (Alexander Stuckenholz)
Re: setuid script (Sam Holden)
Re: sh (bash) $1 equivalent <nobull@mail.com>
Re: Simple question - What is unicode? <bart.lateur@pandora.be>
Re: Simple question - What is unicode? (Helgi Briem)
Re: special characters in command-line <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Unix command (Helgi Briem)
Re: Using SNMP::Multi Modul: [description SNMP Modul] (Jens Abromeit)
Re: Using SNMP::Multi Modul: [Modul SNMP::Multi] (Jens Abromeit)
win32::ole Powerpoint examples <lance@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Nov 2002 23:31:03 -0800
From: bernhard.kick@gmx.de (Bernhard Kick)
Subject: (undef || LIST) vs (LIST || LIST)
Message-Id: <f2383213.0211062331.10787468@posting.google.com>
Could somebody please explain why
@l = (undef || qw/x y z/); print "@l\n"; # case (a)
prints "x y z"
but
@l = (qw/a b/ || qw/x y z/); print "@l\n"; # case (b)
prints "2" # why not "a b" ?
I guess it has to do with list vs. scalar context.
But why does case(a) return a list, but case(b) return a scalar?
What i originally wanted to do is this:
# use files from the cmdline, or default to *
@filenames = @ARGV || glob("*");
However, this does not work as expected.
(It does work for scalars. The Camel book, in the chapter
about short circuit operators, has this example:
$home = $ENV{HOME}||$ENV{LOGDIR}||...||die "You're homeless!";
)
Thanks for any insights into this,
Bernhard Kick
[i originally sent this to comp.lang.perl but after the fact learned
that this newsgroup is no longer alive. Sorry for the double
posting...]
------------------------------
Date: 07 Nov 2002 08:34:55 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: (undef || LIST) vs (LIST || LIST)
Message-Id: <slrnask9df.hkc.vek@station02.ohout.pharmapartners.nl>
On 6 Nov 2002 23:31:03 -0800,
Bernhard Kick <bernhard.kick@gmx.de> wrote:
>Could somebody please explain why
> @l = (undef || qw/x y z/); print "@l\n"; # case (a)
>prints "x y z"
>but
> @l = (qw/a b/ || qw/x y z/); print "@l\n"; # case (b)
>prints "2" # why not "a b" ?
>
>I guess it has to do with list vs. scalar context.
>But why does case(a) return a list, but case(b) return a scalar?
>
>What i originally wanted to do is this:
> # use files from the cmdline, or default to *
> @filenames = @ARGV || glob("*");
>However, this does not work as expected.
>
>(It does work for scalars. The Camel book, in the chapter
> about short circuit operators, has this example:
> $home = $ENV{HOME}||$ENV{LOGDIR}||...||die "You're homeless!";
>)
>
Logical operatores like || forces the left operand into scalar
context. Then when the left operand is true the right hand operand
isn't evaluated and the scalar value of the left operand becomes the
value of the entire right hand side of the assignment.
Villy
------------------------------
Date: 07 Nov 2002 09:57:14 +0100
From: Bodo Schulze <bobesch@letras.net>
Subject: Re: (undef || LIST) vs (LIST || LIST)
Message-Id: <87wunphi51.fsf@letras.net>
bernhard.kick@gmx.de (Bernhard Kick) writes:
> Could somebody please explain why
> @l = (undef || qw/x y z/); print "@l\n"; # case (a)
> prints "x y z"
> but
> @l = (qw/a b/ || qw/x y z/); print "@l\n"; # case (b)
> prints "2" # why not "a b" ?
>
On my Debian machine with Perl 5.6.1, this prints 'b', not '2'. And it
should, according to the lines immediately following the passage you
are citing from the Camel book (see below). As the left side of the ||
operator is evaluated in scalar context, all but the last element of
your left side list are discarded, which leaves 'b', which evaluates
to true, is returned by the || operator and than gets assigned to
$l[0].
>
> I guess it has to do with list vs. scalar context. But why does
> case(a) return a list, but case(b) return a scalar?
>
> What i originally wanted to do is this:
> # use files from the cmdline, or default to *
> @filenames = @ARGV || glob("*");
> However, this does not work as expected.
>
> (It does work for scalars. The Camel book, in the chapter
> about short circuit operators, has this example:
> $home = $ENV{HOME}||$ENV{LOGDIR}||...||die "You're homeless!";
> )
>
just read on the text you cited from the Camel book. The answer to
your question immediately follows the example you evoked.
p. 103 says:
"On the other hand, since the left argument is always evaluated in
scalar context, you can't use || for selecting between two aggregates
for assignment:
@a = @b || @c; # This doesn't do the right thing
@a = sclalar (@b) || @c; # because it really means this.
@a = @b ? @b : @c; # This works fine, though."
Best regards, Bodo
------------------------------
Date: Wed, 6 Nov 2002 21:40:27 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <slrnasjo5b.2te.tadmc@magna.augustmail.com>
pkent <pkent77tea@yahoo.com.tea> wrote:
> _Any_ time you invoke system() (or its chums) you're at the mercy of the
> local system.
> So, if you want to write portable code, don't invoke system.
Another resource for getting native Perl solutions for common
Unix commands is copying code from the Perl Power Tools project:
http://www.perl.com/language/ppt/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 07 Nov 2002 10:55:49 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: A Unix guy moving to Windows 2000
Message-Id: <3dca459c.1928467850@news.cis.dfn.de>
On Wed, 06 Nov 2002 20:19:07 GMT, "matt"
<matt@no.spam.please> wrote:
><stan@temple.edu> wrote in message news:aqbrc6$krm$1@cronkite.temple.edu...
>
><snip>
>> I installed the Cygwin utilities on this Windows system and the
>> Perl that comes with it
There are better Windows distributions (www.activestate.com
for example). In fact Activestate Perl is the best one for
Linux and Solaris too.
>> #!/usr/bin/perl -w
>>
>> print "Hello world!\n";
>> system("date > date.output");
>> system("ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
>> system("pwd");
>> system("df -k");
>> print "Hello world again!\n";
Why are you using perl as a fancy shell scripter?
>> exit;
There is no need for that exit. Where does this Cargo
Cult meme come from? C? I see this all over the place
in Perl programs, yet there is no need for it.
>Windows path's are very different than unix. Basically, windows
>doesn't know what /cygwin/c is. The equvilant in windows is
>c:\. To make this work you either have to change the path's
>in your scripts from /cygwin/c to c:\\ (don't forget to escape
>the \'s), or call bash in your system() call, ie.,
>system("bash ls /cygdrive/c/listserv/main/*.LIST > lists.stuff");
Except there is no need to use backslashes on Win2K. Just
use normal, proper forward slashes and you'll do just fine.
I write all my programs on Win2K and deploy them on
Unix machines with no problems.
>
>You will need to make sure your windows %PATH% env. variable
>points to the bin directory where you installed cygwin, something
>like c:\cygwin\usr\bin .
Yes. But Activeperl would take care of that for you.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 07 Nov 2002 08:38:39 +0100
From: edgue@web.de
Subject: Re: fork() and socket?
Message-Id: <3DCA187F.4050000@web.de>
Benjamin Goldberg wrote:
> No, I didn't say, keep the lock until you get a response. I said, keep
> the lock until you've written all of your data to the socket. Not the
> same thing.
True. But that wouldnt help. example:
server main process child process
locks
sends request data
unlocks
waits for result
....
receives data ....
process locks
process sends request data
process unlocks
.... .... waits for result
The problem is: the server should react "immediately" to the
request of the child process. That is not possible.
The server is still processing the first request. The child
process has to wait until the first request is handled.
So it is locked; it is not a big difference wether it
is locked from sending the request - or "locked" because
it has to wait for the server ...
> Fortunatly, writing data to a socket almost never blocks.
Unfortunately: leaving a message on a answering machine doesnt
help when you need to talk to a human operator immediately.
See the difference?
------------------------------
Date: 7 Nov 2002 07:23:01 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: How to correctly use AUTOLOAD in derived class?
Message-Id: <aqd4cl$7et$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Kevin Lin:
> I'm creating an application which uses a class I've derived from CGI.pm.
> For convenience, I'm using AUTOLOAD to access the class's data members,
> rather than create methods for all.
>
> My understanding is that perl will only call AUTOLOAD if the method is not
> found in either the object's class, or its parent class(es). But AUTOLOAD
> seems to be getting called for a "delete" method (I assume called by CGI's
> constructor or destructor, because I haven't defined one.)
>
> Here is the exception AUTOLOAD throws:
> Uncaught exception: Can't access `delete' field in class Test at
> F:/Gloc3/Development/Modules/Test.pm line 24.
Subclassing CGI is probably a little trickier. CGI.pm keeps a lot of its
methods as strings. Once a method is requested, the code for the method
is compiled and executed. Afterwards, it shows up as an ordinary symbol
in the symbol table. But not before.
> Here is the code for Test.pm:
> package Test;
> use CGI;
> use vars qw(@ISA);
> use vars '$AUTOLOAD';
> our @ISA = ("CGI");
Try the following modification:
use CGI;
BEGIN { CGI->compile(':all') }
use vars qw(@ISA);
...
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Thu, 07 Nov 2002 11:33:48 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: How to guarantee process ID stays with web connection
Message-Id: <mkcksu8d29tio3a7jss3of08bh0ua4clcv@4ax.com>
Joe Moschak bravely attempted to attach 69 electrodes of knowledge to
the nipples of comp.lang.perl.misc by saying:
>How can I
>make it so that each time I invoke my script from a given web session I get
>the same PID instead of a different one?
Easy. Put this line at the beginning of your script, and create a
wrapper that runs it in a loop until it gets the "correct" pid.
die "Please sir, may I have another PID?\n" if $$ != $Wanted_Pid;
;o)
------------------------------
Date: Thu, 7 Nov 2002 08:54:48 +0000 (UTC)
From: bansidhar <nospam@satyam.net.in>
Subject: How to locate Perl Interpreter
Message-Id: <Xns92BF96B5C481Dbansidhar@202.54.1.25>
Hi,
Can anybody tel me how to locate Perl Interpreter (if installed the path)
in a web server from a client.
regards
bansidhar
PS: if you want to mail me change nospam to my name
------------------------------
Date: 7 Nov 2002 02:02:16 -0800
From: Alexander.Stuckenholz@Ruhr-Uni-Bochum.de (Alexander Stuckenholz)
Subject: LWP and ebay
Message-Id: <cb7d7796.0211070202.55f4cdb7@posting.google.com>
Hello.
I´m trying to acces ebay´s isapi.dll to send emails to ebay users by
the
internal ebay communication system. (I´m writing a ebay email tool.)
Everytime i´m posting to http://cgi.ebay.com/aw-cgi/eBayISAPI.dll im
getting a
501 error (Not implemented). But the parameters are correct. I found
them out, when i listened into the communication of another windows
ebay tool with etherreal.
Please Help me...
Thanx.
Alex
------------------------------
Date: Thu, 07 Nov 2002 10:44:26 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Makefile.PL @INC PREFIX LIB
Message-Id: <newscache$2q975h$bx$1@news.emea.compuware.com>
I have installed HTML::Tagset in a local directory:
perl Makefile.pl PREFIX=/some/local/dir
make
make test
make install
This work beautifully. But if I then want to install HTML::Parser also in
the local directory, it can't find HTML::Tagset
perl Makefile.PL PREFIX=/usr/local/httpd/cgi-bin/upara_07/lib
Warning: prerequisite HTML::Tagset failed to load: Can't locate
HTML/Tagset.pm in @INC (@INC contains: /usr/lib/perl5/5.6.1/i586-linux
/usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i586-linux
/usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl .) at (eval 4)
line 3
As you see @INC keeps pointing to the default locations. How can I convince
Makefile.PL to scan the local directory too? Using LIB i.s.o. PREFIX
doesn't help.
Thanks,
--
KP
------------------------------
Date: Thu, 07 Nov 2002 10:47:00 GMT
From: "Gregory Toomey" <nobody@noplace.com>
Subject: Perfecting my Perl
Message-Id: <01c2864c$6cb47f00$88498a90@gmtoomey>
I'm helping a relative with some word puzzles but the solution I've come up
with is rather ugly.
Problem:
Make as many words as possible with the letters a,a,c,c,e,i,n,t,v; each
word must contain the letter c.
My solution:
Using the English language word list at www.wordlist.sourceforge.net/ ,
I've come up with the following:
while(<>) {
if (/^[aceintv]*$/ && /c/) {
my %hash;
foreach (split //) {$hash{$_}++};
print "$_" if $hash{v}<=1 && $hash{c}<=2 &&
$hash{c}>=1 && $hash{i}<=1 && $hash{n}<=1 && $hash{t}<=1 && $hash{e}<=1;
}
}
Does somebody have a more elegant solution?
gtoomey
------------------------------
Date: Thu, 7 Nov 2002 20:19:48 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: Perl module to read mails from Microsoft Outlook
Message-Id: <aqdbae$2pc0$1@arachne.labyrinth.net.au>
"Abid Mohammed" <mohammed@cse.unl.edu> wrote in message news:aqbcm9$ekq$1@unlnews.unl.edu...
> Hi,
>
> I am trying to do the following and need some help. I have reports mailed to my mailbox(Microsoft Outlook)
> which are put in a particular folder (say reports). I need to read the mails from the folder 'reports' parse
> the data and project it in a two dimensional graph. Could any one let me know how to achieve this.
Consider using DBXtract.exe. It reads Outlook Express (proprietry) files and outputs mail in text files. See:
http://savage.net.au/Ron.html
Parsing the emails and graphing them is a separate problem.
--
Cheers
Ron Savage
ron@savage.net.au
http://savage.net.au/index.html
------------------------------
Date: 7 Nov 2002 02:10:37 -0800
From: Alexander.Stuckenholz@Ruhr-Uni-Bochum.de (Alexander Stuckenholz)
Subject: Re: Perl module to read mails from Microsoft Outlook
Message-Id: <cb7d7796.0211070210.66966b2c@posting.google.com>
Try to use OLE.
Here is a example of reading the content of the standard inbox of
outlook by using OLE:
--SNIP--
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
my $outlook = Win32::OLE->new('Outlook.Application') or die
"Error!\n";
my $namespace = $outlook->GetNamespace("MAPI");
my $folder = $namespace->GetDefaultFolder(olFolderInbox);
my $items = $folder->Items;
for my $itemIndex (1..$items->Count)
{
my $message = $items->item($itemIndex);
next if not defined $message;
print $message->{SenderName}."\n";
print $message->{To}."\n";
print $message->{Subject}."\n";
print $message->{Body}."\n";
}
--SNAP--
You should have a look at the Outlook object model for further
information.
I think it is availible at MSDN. Just search it with google.
Alex
------------------------------
Date: 7 Nov 2002 05:08:56 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: setuid script
Message-Id: <slrnasjtb8.tlr.sholden@flexal.cs.usyd.edu.au>
On Thu, 7 Nov 2002 00:00:38 -0500, George <sheken@videotron.ca> wrote:
> I'm running freebsd 4.5
Which is one of those operating systems that doesn't allow setuid scripts,
and in fact silently fails on them. (well it was along time ago when
I looked at it, lots has changed since then :).
Use the code given in the perlsec man page, and all should be fine.
--
Sam Holden
------------------------------
Date: Thu, 7 Nov 2002 08:56:43 GMT
From: Brian McCauley <nobull@mail.com>
Subject: Re: sh (bash) $1 equivalent
Message-Id: <u94rat688v.fsf@wcl-l.bham.ac.uk>
Brian Seppanen <seppanen@chartermi.net> writes:
> At this point I'm just trying to figure out how to capture the data
> that bash captures with $1. I've tried using $ARGV[0], but this
> doesn't appear to work.
Please construct a minimal but _complete_ (strict, warning-free) script
in which you try to use $ARGV[0] and it doesn't appear to work. Post
it here unaltered.
> I'm sort of confused how something could be passing both an
> argument and standard input.
echo hello | wibble.pl there
The wibble.pl process gets "hello\n" from <STDIN> and "there" in $ARGV[0]
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 07 Nov 2002 08:03:07 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Simple question - What is unicode?
Message-Id: <5d6ksucp3hkdn73nih1e9tg9ee0ggnjl39@4ax.com>
Benjamin Goldberg wrote:
>> There is an option to save a file in this format in Excel.
>
>Err, no. It may say that, but it's really offering to save in one of
>the many *encodings* of unicode, such as utf8, utf16-be, utf16-le,
>utf32-be, utf32-le, or one of the encodings for a subset of unicode,
>such as ucs2 or ucs4. These encodings are mappings from numbers to
>sequences of bytes.
>
>You wouldn't happen to know which of those encodings Excel uses, when it
>saves in its so-called unicode format, do you?
That's why there's a so-called BOM ("byte order mark") pseudo-character.
It's a "zero width no-break space", meaning that even though it's a
character, it doesn't show up. It usually appears only at the start of
an Unicode text file. The character code is special, 0xFEFF, whatever
encoding mapping has been used, this byte sequence is typical for this
kind of encoding.
<http://www.zvon.org/tmRFC/RFC2781/Output/chapter3.html>
<http://www.unicode.org/unicode/faq/utf_bom.html#22>
<http://www.unicode.org/unicode/faq/utf_bom.html#25>
--
Bart.
------------------------------
Date: Thu, 07 Nov 2002 10:30:01 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Simple question - What is unicode?
Message-Id: <3dca3fde.1926998367@news.cis.dfn.de>
On Wed, 6 Nov 2002 20:39:15 +0100, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:
>On Nov 6, W K inscribed on the eternal scroll:
>
>> Helgi Briem <helgi@decode.is> wrote
>> > Unicode is a scheme for encoding alphabets
>Not exactly. Unicode assigns numerical values to characters, but
>there are numerous ways (several of which are in active use) of
>actually encoding those numerical values to represent a character.
<SNIP>
Thanks for the clarification, Alan. I have never done
any real Unicode work except quick hacks to translate
to and from ASCII, so I'm no expert and probably should
not have stuck my nose in.
We Icelanders have fight long and hard to keep our
special characters in the 256 character set, so have
not needed extended Unicode yet.
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: Thu, 7 Nov 2002 08:30:07 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: special characters in command-line
Message-Id: <slrnask5f3.53f.bernard.el-hagin@gdndev25.lido-tech>
In article <62dbf7f1.0211061011.45ead989@posting.google.com>, Stuart
Kendrick wrote:
> Hi John,
>
> Ahh, I haven't noticed 'pipe' until now. I'll go play with that. Thanks!
You're going to play with your pipe? I think that's a topic for
alt.sex.solo.
;-)
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Thu, 07 Nov 2002 10:38:34 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Unix command
Message-Id: <3dca40c9.1927233144@news.cis.dfn.de>
Don't top-post. It annoys the regulars and severely reduces
your chances of receiving useful answers. Many regulars
automatically killfile top-posters.
For additional posting guidelines, see:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see
the "NetiquetteGuidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
>In article <MPG.18330e03d4e586ff98968d@news-server.nyc.rr.com>,
>ry@yokoyama.ws says...
>> Hello All!
>>
>> Is it possible to invoke unix command from Perl? If so, please tell me
>> how.
perldoc -f system
On Wed, 06 Nov 2002 17:32:22 GMT, <ry@yokoyama.ws> wrote:
>Thanks for people answering my question. I did not konw perldoc. I
>will read it.
perldoc is a program that comes with every installation of
Perl. It is used to read and search the standard Perl
documentation which also comes with Perl. ( It can be
read with various other tools as well which some experts
prefer. )
The Perl documentation is also available online at
http://www.perldoc.com
>I have another question. Is there FAQ? If so, could you tell me
>where I can find it.
perldoc perlfaq
You can search the PerlFAQ with perldoc using the -q
switch for "query".
perldoc -q KEYWORD
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: 07 Nov 2002 05:34:00 GMT
From: j.abromeit@jpberlin.de (Jens Abromeit)
Subject: Re: Using SNMP::Multi Modul: [description SNMP Modul]
Message-Id: <8$RwhDh2qwB@enerclim.jpberlin.de>
Hello all again,
The methods I'm using are not described in my last posting
Here I added a part of the documentation and the source code
of the Modul SNMP (SNMP.pm). The methods *name* and *val* should
be used (see script snippet in my last posting)
A: part perldoc SNMP-Modul "SNMP"
##################################
[...]
Acceptable variable formats:
<vars> may be one of the following forms:
SNMP::VarList
represents an array of MIB objects to get or set,
implemented as a blessed reference to an array of
SNMP::Varbinds, (e.g., [<varbind1>, <varbind2>, ...])
SNMP::Varbind
represents a single MIB object to get or set, imple-
mented as a blessed reference to a 4 element array;
[<obj>, <iid>, <val>, <type>].
<obj>
one of the following forms:
1) leaf identifier (e.g., 'sysDescr') assumed to
be unique for practical purposes
2) fully qualified identifier (e.g.,
'.iso.org.dod.internet.mgmt.mib-2.system.sys-
Descr')
3) fully qualified, dotted-decimal, numeric OID
(e.g., '.1.3.6.1.2.1.1.1')
<iid>
the dotted-decimal, instance identifier. for
scalar MIB objects use '0'
<val>
the SNMP data value retrieved from or being set to
the agents MIB. for (f)get(next) operations <val>
may have a variety of formats as determined by
session and package settings. However for set
operations the <val> format must be canonical to
ensure unambiguous translation. The canonical
forms are as follows:
OBJECTID
dotted-decimal (e.g., .1.3.6.1.2.1.1.1)
OCTETSTR
perl scalar containing octets
INTEGER
decimal signed integer (or enum)
NETADDR
dotted-decimal
IPADDR
dotted-decimal
COUNTER
decimal unsigned integer
COUNTER64
decimal unsigned integer
GAUGE
decimal unsigned integer
UINTEGER
decimal unsigned integer
TICKS
decimal unsigned integer
OPAQUE
perl scalar containing octets
NULL
perl scalar containing nothing
<type>
SNMP data type (see list above), this field is
populated by 'get' and 'getnext' operations. In
some cases the programmer needs to populate this
field when passing to a 'set' operation. this
field need not be supplied when the attribute
indicated by <tag> is already described by loaded
Mib modules. for 'set's, if a numeric OID is used
and the object is not currently in the loaded Mib,
the <type> field must be supplied
simple string
light weight form of <var> used to 'set' or 'get' a
single attribute without constructing an
SNMP::Varbind. stored in a perl scalar, has the form
'<tag>.<iid>', (e.g., 'sysDescr.0'). for 'set' opera-
tions the value is passed as a second arg. Note: This
argument form is not updated in get[next] operations
as are the other forms.
[...]
------------------------------------------------------------------------
D: code snippet from SNMP.pm (SNMP Modul)
###############################################################
package SNMP::Varbind;
$tag_f = 0;
$iid_f = 1;
$val_f = 2;
$type_f = 3;
$time_f = 4;
sub new {
my $type = shift;
my $this = shift;
$this ||= [];
bless $this;
}
sub tag {
$_[0]->[$tag_f];
}
sub iid {
$_[0]->[$iid_f];
}
sub val {
$_[0]->[$val_f];
}
sub type {
$_[0]->[$type_f];
}
sub name {
if (defined($_[0]->[$iid_f]) && ($_[0]->[$iid_f] =~ m/^[0-9]+$/))
{
return $_[0]->[$tag_f] . "." . $_[0]->[$iid_f];
}
return $_[0]->[$tag_f];
}
sub stamp {
$_[0]->[$time_f];
}
sub fmt {
my $self = shift;
return $self->name . " = \"" . $self->val . "\" (" . $self->type
. ")";
}
#sub DESTROY {
# print "SNMP::Varbind::DESTROY($_[0])\n";
#}
package SNMP::VarList;
sub new {
my $type = shift;
my $this = [];
my $varb;
foreach $varb (@_) {
$varb = new SNMP::Varbind($varb) unless ref($varb) =~
/SNMP::Varbind/;
push(@{$this}, $varb);
}
bless $this;
}
------------------------------
Date: 07 Nov 2002 05:44:00 GMT
From: j.abromeit@jpberlin.de (Jens Abromeit)
Subject: Re: Using SNMP::Multi Modul: [Modul SNMP::Multi]
Message-Id: <8$RwhJhnqwB@enerclim.jpberlin.de>
Hello together,
this is a part of the SNMP::Multi modul.
The SNMP:Multi:Result class offers the method
'varlists' (see below).
->varlists() returns an reference to the object SNMP::Varlist,
which can then be accessed by the according methods (see last my last
posting).
Best regards
Jens
Part from Module Multi.pm (SNMP::Multi)
###########################################
#-------------------------------------------------------------------------
package SNMP::Multi::Result;
#-------------------------------------------------------------------------
use Carp;
use strict;
#
# The SNMP::Multi::Result class encapsulates the returned data (if any)
# from the SNMP agent, as well as any error information. It supplies a
# few methods to access this data, but is essentially just a container.
#
# The object is simply a hash arranged like this:
#
# +---------------------+----------+
# | SNMP::Multi::Result | varlist -+---> SNMP::VarList
# | | errnum |
# | | errstr |
# | | errind |
# | | reqind |
# +---------------------+----------+
#
# $smr->varlists() returns a reference to the array of SNMP::VarList
# object for this result.
#
# All of these methods return undef if no error occurred:
#
# $smr->errnum() returns numeric number of SNMP error.
# $smr->errstr() returns printable string describing the error.
# $smr->errind() returns the index of the variable causing the error.
# $smr->reqind() returns the index in the request of a bad variable.
# $smr->error() returns "$errstr ($errnum)"
#
# The _set_error() method can be used to change the error information:
#
# $smr->_set_error( <errnum>, <errstr> );
sub new {
my $type = shift;
my $class = ref($type) || $type;
my %args = @_;
my $self = {
varlist => $args{'varlist'},
errnum => $args{'errnum'},
errstr => $args{'errstr'},
errind => $args{'errind'},
reqind => $args{'reqind'},
};
bless $self, $class;
return $self;
}
sub error {
my $self = shift;
return undef unless defined $self->{errnum} && $self->{errnum} != 0;
return $self->{errstr} . " (err " . $self->{errnum}
. " at var $self->{errind})";
}
sub _set_error {
my ($self, $errnum, $errstr) = @_;
$self->{errnum} = $errnum;
$self->{errstr} = $errstr;
return $self;
}
# Simple accesssor functions.
#
sub varlists {
my $self = shift;
my $vl = $self->{varlist};
# Can't use an undefined value as an ARRAY reference [on next line]
if (wantarray) {
return UNIVERSAL::isa($vl, "ARRAY") ? @$vl : ();
} else {
return $vl;
}
}
sub errnum {
my $self = shift;
return undef unless defined $self->{errnum} && $self->{errnum} != 0;
return $self->{errnum};
}
sub errstr {
my $self = shift;
return undef unless defined $self->{errnum} && $self->{errnum} != 0;
return $self->{errstr};
}
sub errind {
my $self = shift;
return undef unless defined $self->{errnum} && $self->{errnum} != 0;
return $self->{errind};
}
sub reqind {
my $self = shift;
return undef unless defined $self->{errnum} && $self->{errnum} != 0;
return $self->{reqind};
}
sub values {
my $self = shift;
return if $self->error();
my @values = ();
for my $varlist ($self->varlists) {
for my $vb (@$varlist) {
push @values, $vb->val();
}
}
return wantarray ? @values : \@values;
------------------------------
Date: Thu, 07 Nov 2002 00:44:16 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: win32::ole Powerpoint examples
Message-Id: <pan.2002.11.07.06.44.16.389591.2002@augustmail.com>
Anyone have any examples of win32::OLE with Powerpoint
they would be willing to share? Any links to such
examples?
Specifically, I have some numbers I am gathering that
I will use to update existing Powerpoint Presentation
charts and graphs with. I know nothing about Win32::OLE
or OLE for that matter so fairly easy examples would
be appreciated.
I have found a few examples but nothing about inserting
numbers and updating charts.
My only other option would be to create Excel sheets using
win32::OLE and manually link Excel to Powerpoint but I
would prefer to eliminate the middleman (Excel).
Any help would be appreciated.
Lance
------------------------------
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 4078
***************************************