[10210] in Perl-Users-Digest
Perl-Users Digest, Issue: 3802 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 23 16:07:22 1998
Date: Wed, 23 Sep 98 13:00:23 -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 Wed, 23 Sep 1998 Volume: 8 Number: 3802
Today's topics:
Re: any way to encrypt my script? <sauvin@osmic.com>
Re: Array of hashes: a better way? <uri@camel.fastserv.com>
Re: Beginner in Perl and Tape problem (Tye McQueen)
Re: can MSWord and Adobe PDF docs be read for indexing? (Jan Dubois)
Re: Comparing arrays ? <jdporter@min.net>
Re: emacs Perl mode and viper-paren-match <tim@unt.edu>
Re: Enumerating Properties and Methods (Jan Dubois)
Re: hash slices with hashes of hashes <Arved_37@chebucto.ns.ca>
Re: Hashes springing into existence [Was: more regex/pa (Ilya Zakharevich)
Need help with packages <jvaught@ichips.intel.com>
Re: Perl & Java - differences and uses bjohnsto_usa_net@my-dejanews.com
Re: Perl & Java - differences and uses colmk@innocent.com
Re: Perl and Lotus Notes? (Jan Dubois)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Sep 1998 15:53:29 -0400
From: Ben Sauvin <sauvin@osmic.com>
Subject: Re: any way to encrypt my script?
Message-Id: <360951B9.B2E45636@osmic.com>
::smirk::
They're big balls of hot gasses only because of thermal dissociation. :)
Rich Grise wrote:
> Ronald J Kimball wrote:
> >[bunch stuff]
> > Perhaps it's more akin to saying that only astrophysicists should make
> > authoritative comments about the composition of stars.
> >
>
> Do you mean comments like, "They're big conglomerations of hot gas"?
>
> --
> Rich Grise
> richgrise@entheosengineering.com
> (No need to futz with my e-mail: I have a "Delete" button!)
------------------------------
Date: 23 Sep 1998 15:52:57 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: alecler@cam.org (Andre L.)
Subject: Re: Array of hashes: a better way?
Message-Id: <sar90jafvxi.fsf@camel.fastserv.com>
>>>>> "AL" == Andre L <alecler@cam.org> writes:
AL> while ( defined(my $line = <DATA>) ) {
AL> chomp $line;
AL> $i++, next if $line eq '';
AL> my ($key,$value) = split /\s*=>\s*/, $line, 2;
^^^^^^^^
i don't think this is was you meant. it won't return the 2 fields,
probably just null strings. the split should be on '=>' or it should be
a match like $line =~ /(\s+)=>(\s+)/
AL> $records[$i]{$key} = $value; # See Note.
AL> }
and you didn't have to quote his entire original post.
hth,
uri
--
Uri Guttman Speed up your web server with Fast CGI!
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: 23 Sep 1998 14:21:28 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Beginner in Perl and Tape problem
Message-Id: <6ubhno$t9c@fumnix.metronet.com>
[Posted and e-mailed.]
Gilles Bellaches <gilles.bellaches@somepost.fr> writes:
) We would like to know if there is a tape in the Tape Device before we
) run the backup.
Sorry to take so long; I didn't have my machine with the tape drive
in it available. The following works:
use strict;
use Win32API::File 0.05 qw(
createFile
DeviceIoControl IOCTL_STORAGE_CHECK_VERIFY
CloseHandle
);
my $tape= createFile( "//./Tape0", "r" )
or die "Can't access first tape device: $^E\n";
my $ok= DeviceIoControl( $tape, IOCTRL_STORAGE_CHECK_VERIFY(),
[], 0, [], 0, [], [] );
if( ! $ok && $^E =~ /bus was reset/ ) { # Transient error; retry:
$ok= DeviceIoControl( $tape, IOCTRL_STORAGE_CHECK_VERIFY(),
[], 0, [], 0, [], [] );
}
if( $ok ) {
warn "A tape is in drive 0.\n";
} else {
warn "Media not available for tape drive 0: $^E\n";
}
CloseHandle( $tape );
The output for the failed case should be:
Media not available for tape drive 0: No media in drive
Win32API::File v0.05 is available from
http://www.metronet.com/~tye/alpha/Win32API/ (a future version
will be on CPAN when the documentation and test script are done).
You'll need a version of Perl for Win32 that supports building
standard extensions (the best choice for this depends on several
things).
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Wed, 23 Sep 1998 21:29:26 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: can MSWord and Adobe PDF docs be read for indexing?
Message-Id: <360c48c6.5973729@news2.ibm.net>
[mailed & posted]
scott@softbase.com wrote:
>Pat Trainor (ptrainor@bbn.com) wrote:
>> What is required (even for $$$) that enables perl to write data in msword,
>> excel, pdf formats?
>
>You can get the file format descriptions for free, *BUT*, the file
>format is defined in terms of an OLE storage. You'd have to reimplement
>the storage subsystem of OLE in C on UNIX and use it to open the file.
>It isn't just plain data.
There is an OLE::Storage module on CPAN. It should read Excel and Word files
on UNIX. I think there is even a companion program that translates Excel
spreadsheets to HTML on UNIX using OLE::Storage. Disclaimer: I never used
the module at all!
-Jan
------------------------------
Date: Wed, 23 Sep 1998 15:56:21 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Comparing arrays ?
Message-Id: <36095265.17C76B11@min.net>
Rich Grise wrote:
>
> Phil Taylor wrote:
> >
> > I've got an array which contains a series of codes ie
> >
> > @array1 = ("01", "02");
> >
> > and I have another array which contains the above codes with a decode
> > separated by a colon ie
> >
> > @array2 = ("01:Element01", "02:Element02", "03:Element03", ........)
> >
> > I want to end up with @array2 to only contain elements relating to
> > codes "01" and "02" ie
> >
> > @array2 = ("01:Element01", "02:Element02")
> >
> > Can anyone suggest a neat way to achieve this?
I'm not sure if anyone has suggested this yet; but I would
use a hash to map from '01' => 'Element01', etc.
# first, build the hash:
%hash2 = map { /:/ ? ( $` => $_ ) : () } @array2;
# now, given
@array1 = ( '01', '02' );
# get the subset from the hash:
@array2 = @hash2{ @array1 };
Done! Neat, eh?
--
John "Many Jars" Porter
------------------------------
Date: 23 Sep 1998 14:47:56 -0500
From: Tim Christian <tim@unt.edu>
Subject: Re: emacs Perl mode and viper-paren-match
Message-Id: <83sohi4nmb.fsf@leonardo.cascss.unt.edu>
That's odd indeed. The one I use works fine on that code:
;; VI-ish paren matching
;; --
;; originally attributed to: michael@uni-paderborn.de
;; embellished by: jxh@cs.wustl.edu
;; Fixed it so that it doesn't move off of a closing brace
;; if no match is found.
;; --
(defun vi-type-paren-match (arg)
"Go to the matching parenthesis if on parenthesis otherwise insert %."
(interactive "p")
(let ((oldpos (point)))
(cond
((looking-at "[{([]")
(forward-sexp 1) (backward-char))
((looking-at "[])}]")
(forward-char)
(condition-case nil
(progn
(backward-sexp 1)
(while (not (looking-at "[{([]")) (forward-char)))
(error (progn
(backward-char)
(error (message "Unbalanced parentheses"))))))
(t (self-insert-command (or arg 1))))))
--
http://www.cas.unt.edu/~tim
UNT named one of nation's most wired colleges: http://www.unt.edu
------------------------------
Date: Wed, 23 Sep 1998 21:29:22 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Enumerating Properties and Methods
Message-Id: <3609427f.4366518@news2.ibm.net>
[Mailed & Posted]
Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz> wrote:
>But even though most of the replys were not very helpfull, you should
>have told us.
>Cause it MATTERS if an object is an ordinary Perl-only object with no
>magic whatsoever
>and if it is a Win32::OLE object.
>
>The methods of Win32::OLE objects are not defined anywhere in any perl
>code.
>They are "AUTOLOADED". So even if you used the MJD's solution you would
>not
>get any helpfull listing. It would list only the "standard" methods
>defined
>within Win32::OLE.pm
>
>I'm not sure, but there may be some method for listing methods and
>properties, but
>it WILL BE Win32::OLE specific. So search the docs of Win32::OLE or
>subscribe to Perl-Win32-Users@lyris.activestate.com and ask there.
>Unless of course Jan Dubois (author of Win32::OLE) comes here and
>answers the question.
I also suggest that when you don't have any documentation about a COM object
then you probably should not use it. But if you think you really MUST use
it, then a COM type info browser is the best way to learn about the object
(if it includes a type library, which some objects, like Lotus Notes,
don't). There is a OLEVW32 utility included with MSC++ or you can even use
the browser included in the VBA editor for Office products (Word/Excel). You
have to add the type library first (using Tools/References I guess), and the
press F2 to open a type library window.
With Win32::OLE you can enumerate the properties of an object using
C<keys %$object>. This only works if the type library is accessible at
runtime. Please look at the eg/properties.pl example in the Win32::OLE
distribution (in libwin32-0.13 from Sarathy). You cannot currently enumerate
the method names from Perl. I do have development versions of
Win32::OLE::TypeInfo and Win32::OLE::TypeLib, but they are still work in
progress. (I need them to write the support for native interfaces I promised
at the Perl conference).
>P.S.: I assume that you are using ActivePerl.
>Build 3xx of ActiveState perl will most probably not have this feature.
ActiveState Perl builds 3xx used C<keys %$object> for something else
(accessing collection members). I did consider that broken, as
$object->{name} is used to set/get property names and therefore the C<keys>
functions should return those property names and not something else. So I
fixed that. :-) You have to use the C<in> function or the Win32::OLE::Enum
module to access collection objects.
-Jan
------------------------------
Date: Wed, 23 Sep 1998 16:04:50 -0300
From: Arved Sandstrom <Arved_37@chebucto.ns.ca>
Subject: Re: hash slices with hashes of hashes
Message-Id: <Pine.GSO.3.95.iB1.0.980923155844.9481C-100000@halifax>
Here's some extra stuff related to Stefan's problem. It just shows a
variety of ways of getting and presenting keys to the basic structure that
Sean already pointed out.
This is more often the primary logic of this problem: what subset of keys
do we want to present, and in what order (could've thrown in sort()).
(Took some liberty with the original data :-) )
__STUFF__
$hp = {
key_a => {
a1 => '1a',
a2 => '2b',
a3 => '3c',
a4 => '4d',
b1 => '5e',
c1 => '6f'
},
key_b => {}
};
@some_keys1 = map {&func1($_)} keys %{$hp->{'key_a'}};
@results1 = @{$hp->{'key_a'}}{ @some_keys1 };
print "@results1\n";
# OR
@some_keys2 = &func2( keys %{$hp->{'key_a'}} );
@results2 = @{$hp->{'key_a'}}{ @some_keys2 };
print "@results2\n";
# OR
# This won't normally work so neatly, but some keys above are amenable
# to an automagical increment
@results = @{$hp->{'key_a'}}{ 'a1' .. 'a3'};
print "@results\n";
sub func1 {
# Abstracted this out from above. Basically ANY code that
# returns a selection of keys from the entire list of keys
$_[0] if $_[0] =~ /2|4/; # example
}
sub func2 {
my (@all_keys) = @_;
my @less_keys = map {$_ if /^b|c/} @all_keys;
@less_keys;
}
------------------------------
Date: 23 Sep 1998 19:13:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6ubh85$iks$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Daniel Grisinger
<dgris@rand.dimensional.com>],
who wrote in article <6ubeor$adm$1@rand.dimensional.com>:
> >Well, you confuse PP-code with Perl API. pp_exist() may be not
> >called, but it is only a wrapper for hv_fetch(...,FALSE) (I did not
> >look into the code, though). And hv_fetch is called before doing
> >newHV() anyway.
>
> But pp_exists isn't a wrapper for hv_fetch, it's a wrapper
> for hv_exists_ent and avhv_exists_ent (which itself is just
> a wrapper around hv_exists_ent), neither of which are
> called when a new HV is created, and neither of which call
> hv_fetch.
>
> Am I missing something?
*Before* newHV() is called, somebody checked that it need to be
called, right? How do you think it did it, consulting the spirit of
Disraeli? ;-)
Ilya
------------------------------
Date: Wed, 23 Sep 1998 12:15:55 -0700
From: Jim Vaught <jvaught@ichips.intel.com>
Subject: Need help with packages
Message-Id: <360948EB.D2ABF839@ichips.intel.com>
I am having a scoping problem that I thought I could solve with
packages, but I can't
quite get it to work. The problem works like this: I have a set of
perl scripts which
represent individual pieces of a system. These scripts will likely
contain many variables
with the same name. I have some setup perl code which defines some
variables and
functions which will be used within each of the scripts. I also have
some backend
code which will access the variables and functions defined in each of
the scripts. The scripts need seperate name spaces since they will have
the same variable names representing different variables. However, I
need them to be able to access all the functions and variables of the
setup code too. It diagrams something like this:
setup
/ | \
script0 script1 script2
\ | /
backend
The scripts already exist and would be painful to modify. They refer to
the variables
and functions without specifying a package (when they were written there
was always
only one script, so everything was done in one package). Therefore it
is not an
acceptable solution to have the scripts use main:: to access the
variables and functions
in the setup code... they must be able to simply specify the name. To
achieve this,
after I change packages to each of the scripts I copy the %main:: symbol
table into
the package. This seems to work except for one problem. Some of the
setup
functions change the value of variables within the scripts. When I call
these functions
they instead change the value of the variables within the setup
package. Here is a
simple example:
package Setup;
sub make_var {$new_var = 7;}
package Script;
$new_var = 13;
&Setup::make_var;
print "Finished with Setup:: <$Setup::new_var>, ";
print "Script:: <$Script::new_var>\n";
This gives:
Finished with Setup:: <7>, Script:: <13>
What I would like is:
Finished with Setup::<>, Script::<7>
Is there any way with Perl that I can specify that I want a function to
behave as if
it belonged to (was declared in) the current package instead of the
package it really was
declared in. By that I mean is there a way to have the default package
for the variables
accessed in a function be determined dynamically (by the package of the
caller) rather than statically (by the current package at compile time).
Thanks,
Jim
******************************************************************
Any opinions or beliefs stated or implied are strictly my own and in no
way reflect the opinions or beliefs of my employer.
------------------------------
Date: Wed, 23 Sep 1998 18:56:34 GMT
From: bjohnsto_usa_net@my-dejanews.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6ubg92$1bg$1@nnrp1.dejanews.com>
In article <906445285.800391@thrush.omix.com>,
Zenin <zenin@bawdycaste.org> wrote:
> bjohnsto_usa_net <bjohnsto_usa_net@my-dejanews.com> wrote:
> : I think that JVM is an increasingly important platform.
> >snip<
>
> I think the *idea* of an open source, language independent,
> platform independent, byte code format is important. The Java
> byte code is likely too closely tied to Java for this to really
> happen. My understanding is that Java byte code can't do lambda
> style functions for instance, thus making things like a Java
> byte code backend for Perl and other languages that much harder,
> if not impossible. Maybe a perl written in Java, but that's
> completely different.
What do you mean by lambda style function?
Do you have any links to information about them or books in which they are
described.
I feel sure that perl could be implemented in byte code.
I am not sure what the efficiency would be.
You are drawing a distinction between a Perl written in Java to a perl which
generates Java Byte code.
I only intended to mean a Perl which is written is Java and 'interprets' perl
source code.
> : As Java gets a decent cross platform GUI, and a safe, fast, solid,
> : widespread system to run foreign code popular platforms, like Perl, will
> : have to have the ability run in and produce the Java Virtual Machine
> : assembler too.
>
> Maybe, we'll see. Java is on the right track, mostly. I'm really
> waiting for the Java world to wake up and realize they aren't
> everything, and that *language* independence is just as important as
> platform independence. I'm a little tired of RMI, the Serializable
> format, and similar "Java only" systems with not so much as even the
> format spec to try to connect to them from another language.
Many existing language independent systems seems to have problems with
complexity and features.
Is there a CORBA interface for Perl?
Although I must say recently bought a book on CORBA and after reading about
half I have developed an interest in Java specific technologies.
I think that the right track for Java is to evolve the language and virtual
machine together to be as powerful, efficient and simple as possible.
It seems to me that serialization which allows the reconstruction of a live
object must be virtual machine specific.
> -Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
Brendan Johnston
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 23 Sep 1998 19:27:10 GMT
From: colmk@innocent.com
Subject: Re: Perl & Java - differences and uses
Message-Id: <6ubi2d$30m$1@nnrp1.dejanews.com>
> : reese, read "computation: finite and infinite state machines" by marvin
> : minsky to learn about what is computable and what is not. computable and
> : algorithm are related. algorithm and methodology are not related.
>
cfaism is the best book of all time.
and is the whole reason i went into computing.
normally the halting problem is presented as a diagonal argument
it just doesn;t feel right
a progam either halts or it doesn't it is a platonic fact!
but if no algorithm can decide for all cases...then...
I need a post-quantum oracle obvsly...
regards,
csm msc
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 23 Sep 1998 21:29:25 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: Perl and Lotus Notes?
Message-Id: <360b46a6.5429557@news2.ibm.net>
[mailed & posted]
Rich Bowen <rbowen@rcbowen.com> wrote:
>1) Are any of you folks in a Notes environment, and how does Perl help
>you there?
>2) Are there any Notes modules available? I did not see any on CPAN, but
>I was not sure if they would be in the database directories or in the
>"strange, masochistic, chains and bondage applications with uncertain
>purposes" directories. (You know, with the Windows modules ...)
>3) Perhaps this is more of a question for the "advocacy" list - how are
>you Notes users justifying your existance to your supervisors?
>4) How can I circumvent the entire Notes juggernaut and still do what I
>enjoy doing? Yes, I have heard of GNotes, but it appears to be still
>very much vaporware.
I know of two people working (or having worked) on Notes modules using the C
or C++ APIs through XS code, but both are still in the pre-alpha phase I
think. If you are using Win32 then you can use the Win32::OLE module to talk
to Notes just like with LotusScript. (Yes, it is slow).
I'm appending my standard sample on how to do this below.
-Jan
use strict;
use Win32::OLE;
my $Notes = Win32::OLE->new('Notes.NotesSession')
or die "Cannot start Lotus Notes Session object.\n";
my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/);
print "The current user is $Notes->{UserName}.\n", ;
print "Running Notes \"$Version\" on \"$Notes->{Platform}\".\n", ;
my $Database = $Notes->GetDatabase('', 'help4.nsf');
my $AllDocuments = $Database->AllDocuments;
my $Count = $AllDocuments->Count;
print "There are $Count documents in the database.\n";
for (my $Index = 1 ; $Index <= $Count ; ++$Index) {
my $Document = $AllDocuments->GetNthDocument($Index);
printf "$Index. %s\n", $Document->GetFirstItem('Subject')->{Text};
my $Values = $Document->GetItemValue('Index_Entries');
foreach my $Value (@$Values) {
print " Index: $Value\n";
}
last unless $Index < 5;
}
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3802
**************************************