[10076] in Perl-Users-Digest
Perl-Users Digest, Issue: 3669 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 9 13:07:23 1998
Date: Wed, 9 Sep 98 10:00:21 -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, 9 Sep 1998 Volume: 8 Number: 3669
Today's topics:
Re: ??? if ($fr "$test" $threshold) ??? <aqumsieh@tigre.matrox.com>
Re: Another newbie OO question <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Another newbie OO question <rick.delaney@shaw.wave.ca>
Re: Another newbie OO question <rick.delaney@shaw.wave.ca>
column extraction from a string <raj.subramani@citicorp.com>
Re: column extraction from a string (Matt Knecht)
Re: grouping list of ARRAY refs with grep ? <jdporter@min.net>
Re: grouping list of ARRAY refs with grep ? <uri@sysarch.com>
Re: How do you supply cleartext password and be secure <bbense+comp.lang.perl.misc.Sep.09.98@telemark.stanford.edu>
Re: How to read an UTF-8 encoded string (Sean McAfee)
Re: How to read an UTF-8 encoded string (Abigail)
Re: How to read an UTF-8 encoded string (Sean McAfee)
Internet Developer Job Vacancy richardashrowan@my-dejanews.com
Re: Looking for a programm in Perl!:=) (Sean McAfee)
Re: Manpage Wrapper dave@mag-sol.com
Re: merge arrays and strings beju@my-dejanews.com
Newbie Nested Reference Syntax Question <careys@paciolan.com>
Re: Newbie Nested Reference Syntax Question <rick.delaney@shaw.wave.ca>
Re: Newbie Nested Reference Syntax Question (Sean McAfee)
Re: Off topic, but ... [Was Re: Perl & Java - differenc <merlyn@stonehenge.com>
Re: Off topic, but ... [Was Re: Perl & Java - differenc <jimbo@soundimages.co.uk>
Proposal: relative_time() for Time::Local module <sidi@angband.org>
sprintf error in Perlis and PerlScript David@iqtexas.com
Re: Test language in perl <jdporter@min.net>
Re: Test language in perl <uri@sysarch.com>
Re: Test language in perl <merlyn@stonehenge.com>
unsubscribe (Michael Chen)
Re: Why Perl ? <jdporter@min.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 09 Sep 1998 10:58:25 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: ??? if ($fr "$test" $threshold) ???
Message-Id: <x3yiuix5o4u.fsf@tigre.matrox.com>
jack.haberle@bigfoot.com writes:
>
> I'm trying to apply a set of tests to some analysis results. Info about the
> tests to be applied is stored in an Oracle DB. For example, a test of
> whether a flowrate is greater than a threshold: I am getting $test = '>' and
> $threshold = 500 correctly from the database, but as I have the brain of a
> turnip I can't seem to be able to figure out an if clause that will apply the
> test and tell me whether or not I pass.
One way to do it would be using eval:
$test = ">";
$fr = 1000;
$threshold = 500;
$command = <<HERE;
if ($fr $test $threshold) {
print "It works\n";
} else {
print "It doesn't\n";
}
HERE
eval $command;
__END__
outputs: It works
hope this helps,
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: 09 Sep 1998 17:00:58 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: awrobinson@amoco.com
Subject: Re: Another newbie OO question
Message-Id: <8390jts53p.fsf@vcpc.univie.ac.at>
Re: Another newbie OO question, Andrew
<awrobinson@amoco.com> said:
Andrew> I want to pass a parameter to the initialization
Andrew> when I create an object. What is the syntax for
Andrew> doing this? If it is described in either the perlobj
Andrew> or perltoot pages, it went over my head. I apologize
Andrew> for that.
Well, firstly remember there's no special syntax for
constructors or methods...
Andrew> I know this is the syntax if I create the object
Andrew> without a parameter: $o = Stuff->new();
... and you can see this, it looks exactly (hmmm :-) like a
subr call.
Andrew> sub new() { my $class = shift; my $self = {}; bless
Andrew> $self, $class; $self->initialize(); return $self; }
You can get at the parameters passed just as you would in an
ordinary subroutine, e.g.
sub new {
my $class = shift;
my $self = bless {
name => 'tony',
age => 32,
@_,
};
$self;
}
Then I can do things like
my $var = Package->new(name => 'wally', age => 35);
You're free to treat the parameters in any way you want.
Here I am using them as a hash, this is commonly used to
pass named parameters, these generally being considered
more polite than positional ones. But also you could do:
sub new {
my $class = shift;
my $self = bless {};
my ($name, $age) = @_;
$self->{name} = $name;
$self->{age} = $age;
$self;
}
use as
my $var = Package->new('tina', 28);
Add syntax to taste.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Wed, 09 Sep 1998 15:21:18 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Another newbie OO question
Message-Id: <35F69E70.B8B3E139@shaw.wave.ca>
[posted & mailed]
Andrew W. Robinson wrote:
>
> What does the package syntax look like if I create the object
> with a parameter: $o = Stuff->new('hup');
>
> #!/usr/bin/perl
> # File Stuff.pm
>
> package Stuff;
>
> sub new() {
> my $class = shift;
> my $self = {};
> bless $self, $class;
> $self->initialize();
> return $self;
> }
Methods are just subroutines (hence sub new) where the first parameter
is the name of the package. So you probably want to use the values
passed to the sub.
sub new { # got rid of prototyping brackets
my $class = shift;
my @parms = @_;
my $self = {};
bless $self, $class;
$self->initialize(@parms);# could just put @_ in here directly
return $self;
}
In this case you want to pass the parameters to method initialize, which
presumably wants to use them.
> sub initialize() {
Again, get rid of those prototyping brackets. I find it interesting
that you even get the package name passed in when you declare the
subroutine that way. That's pretty cool if it works. I didn't test it
so I'm just taking your word that it does.
Have a good read of perlsub.
sub initialize {
> my $self = shift;
> # A miracle occurs and $myparm appears...
No miracle, just an assignment.
my @myparms = @_;
or
my $myparm = $_[0];# if you are only passing one parameter
> $self->{'stufflist'} = $self->setStuff($myparm);
> }
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 09 Sep 1998 15:33:54 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Another newbie OO question
Message-Id: <35F6A169.21BFCD91@shaw.wave.ca>
[posted & copy sent to original poster]
Rick Delaney wrote:
>
> Again, get rid of those prototyping brackets. I find it interesting
> that you even get the package name passed in when you declare the
> subroutine that way. That's pretty cool if it works. I didn't test it
> so I'm just taking your word that it does.
>
> Have a good read of perlsub.
>
I took my own advice and found the relevant section:
Method calls are not influenced by prototypes either, because the
function to be called is indeterminate at compile time,
because it depends on inheritance.
So forget what I said about prototyping, except that it seems pointless
in method declarations. That will teach me to talk about a feature I
never use.
I hope the *other* part of my reply helps.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 09 Sep 1998 16:51:13 +0100
From: Raj Subramani <raj.subramani@citicorp.com>
Subject: column extraction from a string
Message-Id: <35F6A3F1.63778B11@citicorp.com>
I am executing a ps command on a remote machine
using Net::Telnet module which returns a list of strings:
raj 7146 7088 220 12:10:38 ttypa 207:23 foo
raj 7134 7088 220 12:10:27 ttypa 156:26 foo
raj 7140 7088 220 12:10:33 ttypa 157:43 foo
I need to extract the pid numbers which are in the 2nd
column (i.e 7146, 7134 and 7140).
The perlfunc faq says this can be done using either
unpack or substr. I have tried (boy, have I tried) and
failed.
At the moment I am going through a rather convoluted
process to extract this 2nd column (spliting the string
into a list and cycling through this list etc etc).
Would there be a more elegant way of extracting the 2nd
column?
Much appreciated squire(s).
Cheers
--
Raj Subramani
------------------------------
Date: Wed, 09 Sep 1998 16:12:13 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: column extraction from a string
Message-Id: <xNxJ1.86$Mo5.504588@news2.voicenet.com>
Raj Subramani <raj.subramani@citicorp.com> wrote:
>I am executing a ps command on a remote machine
You need to check out:
http://perl.oreilly.com/cookbook/prog_psgrep.html
Or better yet, buy the book!
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Tue, 08 Sep 1998 11:56:21 -0400
From: John Porter <jdporter@min.net>
Subject: Re: grouping list of ARRAY refs with grep ?
Message-Id: <35F553A5.CCAE5099@min.net>
Phil R Lawrence wrote:
> > my @beginning_list= (['abc','def','abc'],
> ['def','abc'],
> ['ghi','jkl','jkl'],
> ['jkl','ghi','jkl'],
> ['mno','pqr']
> );
>
> I want to group together those references that share the same 1st two
> elements (regardless of order) in a new array. So, output
> should be:
> (
> [
> ['abc','def','abc'],
> ['def','abc']
> ],
> [
> ['ghi','jkl','jkl'],
> ['jkl','ghi','jkl']
> ],
> ['mno','pqr']
> ]
> )
my @beginning_list = (
[qw( abc def abc )],
[qw( def abc )],
[qw( ghi jkl jkl )],
[qw( jkl ghi jkl )],
[qw( mno pqr )]
);
my %temp_hash;
for ( @beginning_list ) {
push @{$temp_hash{join '', sort @{$_}[0,1] }}, $_;
}
my @grouped_list = map { $temp_hash{$_} } sort keys %temp_hash;
hth,
John Porter
------------------------------
Date: 09 Sep 1998 12:26:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: grouping list of ARRAY refs with grep ?
Message-Id: <x7soi1z1zh.fsf@sysarch.com>
>>>>> "JP" == John Porter <jdporter@min.net> writes:
JP> Phil R Lawrence wrote:
JP> my @beginning_list = (
JP> [qw( abc def abc )],
JP> [qw( def abc )],
JP> [qw( ghi jkl jkl )],
JP> [qw( jkl ghi jkl )],
JP> [qw( mno pqr )]
JP> );
JP> my %temp_hash;
JP> for ( @beginning_list ) {
JP> push @{$temp_hash{join '', sort @{$_}[0,1] }}, $_;
JP> }
JP> my @grouped_list = map { $temp_hash{$_} } sort keys %temp_hash;
nice design. but wouldn't a hash slice in the last line be cleaner and
maybe faster?
my @grouped_list = @temp_hash{ sort keys %temp_hash } ;
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 9 Sep 1998 15:16:39 GMT
From: <bbense+comp.lang.perl.misc.Sep.09.98@telemark.stanford.edu> ;
Subject: Re: How do you supply cleartext password and be secure in Perl (was Perl compiler)
Message-Id: <6t664n$i6$1@nntp.Stanford.EDU>
In article <35F5B553.BD339387@america.net>,
Garry Williams <garry@america.net> wrote:
>Garry Williams wrote:
>>
>> Peter A Fein wrote:
>> >
>> > Garry Williams <garry@america.net> writes:
>> > >
>> > > I don't understand. Why not setuid?
>> > >
>> > > Have the script run as your own ID and make a file with the secrets in
>> > > it readable *only* by you. It's as secure as the file system.
>> >
>> > What about security holes in the script? Even if you don't make it
>> > setuid 0, but rather something else, it still necessarily leaves the
>> > possibility of reading the password file open.
>>
>> Can you be more specific? "Scrub" the environment data you use. What's
>> the problem?
- - core files. If I can get the program to core dump I can read
the password. (On some os's this is as simple as kill -10) The
original post was in the context of a multi-user system. Your
method is indeed one of the methods I outlined. It's a
reasonable compromise. Security is always a balance between
functionality and risk. You always need to ask yourself
"is the bar high enough?"
- - The real risk of passwords is that at some point you need to use
them, this means putting them on the network in 99% of most
applications. If this happens in cleartext, the security of the
system is minimal.
- - Booker C. Bense
Version: 2.6.2
iQCVAwUBNfab0wD83u1ILnWNAQGDyQP+MQflCymSs54d3X6gTPSXYipgZDUOykwd
JfxXE98aiuLW6/imkbJqyhJKUIlIgjvlQLFMccZrlX4ekivR1YSNWorR8FV0FLDC
O3vwk4xUPmjM4jymBhDDFzjnRDHAOPU12N5obpjxtXUztHvUUhwOrgEp7JWWnSqX
65MpSue2JNQ=
=avII
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 09 Sep 1998 15:00:16 GMT
From: mcafee@galaga.rs.itd.umich.edu (Sean McAfee)
Subject: Re: How to read an UTF-8 encoded string
Message-Id: <4KwJ1.1805$F7.7674295@news.itd.umich.edu>
In article <6t5rfm$m03$1@due.unit.no>,
Morten Simonsen <mortensi@idt.ntnu.no> wrote:
>I am trying to communicate between a Java applet of mine, and a Perl
>server. The applet sends a UTF-8 encoded string to my server. The
>server receives it, but not in plain text. The result can be viewed in
>the jed editor: (and not for example in pico or even emacs, trying to
>cat the file, corrupts the keyboardoutput, forcing me to reset the
>terminal)
>Input: ^@^NActivityKey:A0
>Now, how can I read this string properly? (Someone said something
>about unpack(), but I don't know..) The point is probably that ^N = 14
>= length("ActivityKey:A0"), but so what? Can I just always skip the
>first two bytes of the input?
Yes, but only if you're certain that all of the characters are ASCII
characters.
>Can some please enlighten me?
Are you sending the data using Java's DataOutputStream.writeUTF8() method?
If you can possibly use a PrintWriter instead, its print() method will
convert the UTF8 string into your local encoding, which might be just what
you need. Otherwise, here's some code I wrote which will read UTF8 strings
(part of an on-again off-again plan to compose Java.pm):
----------------------------------------------------------------------
sub readShort {
my $in = shift;
my $buf;
read($in, $buf, 2);
unpack("n", $buf);
}
sub readUTF8 { # pass ref to typeglob as single parameter
my $in = shift;
my $len = readShort($in);
my ($i, $c, $d, $e, $buf, @result);
read($in, $buf, $len);
for ($i = 0; $i < $len; $i++) {
$c = ord(substr($buf, $i, 1));
if (($c & 0x80) == 0) {
push(@result, $c);
} elsif (($c & 0xe0) == 0xc0) {
$d = ord(substr($buf, ++$i, 1));
push(@result, ($c & 0x1f) << 6 | ($d & 0x3f));
} elsif (($c & 0xf0) == 0xe0) {
$d = ord(substr($buf, ++$i, 1));
$e = ord(substr($buf, ++$i, 1));
push(@result, ($c & 0x0f) << 12 | ($d & 0x3f) << 6 | ($e & 0x3f));
} else {
die "Bad UTF8 string\n";
}
}
\@result;
}
----------------------------------------------------------------------
The function returns an array of Unicode character values in the range
0-65535. Converting these to one's local encoding is an exercise for the
reader.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 9 Sep 1998 15:53:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to read an UTF-8 encoded string
Message-Id: <6t68af$erh$1@client3.news.psi.net>
Morten Simonsen (mortensi@idt.ntnu.no) wrote on MDCCCXXXV September
MCMXCIII in <URL: news:6t5rfm$m03$1@due.unit.no>:
++ I am trying to communicate between a Java applet of mine, and a Perl
++ server. The applet sends a UTF-8 encoded string to my server. The
++ server receives it, but not in plain text.
What do you mean, "not in plain text"? If you have someone encoded your
UTF-8 encoding, you'll have to decode it again.
Currently, perl doesn't do UTF-8 natively, strings are 8bit characters.
Perl 5.006 (of which the first development versions are available)
can handle UTF-8 internally.
++ The result can be viewed in
++ the jed editor: (and not for example in pico or even emacs, trying to
++ cat the file, corrupts the keyboardoutput, forcing me to reset the
++ terminal)
That's a problem with your terminal. You might need a UTF-8 aware
terminal driver.
++
++ Input: ^@^NActivityKey:A0
++
++ Now, how can I read this string properly? (Someone said something
++ about unpack(), but I don't know..)
That entirely depends what you want to do with it. If it's just store
and forward, who care that those bytes are a UTF-8 encoding. If you
want to count characters, or do character based substitutions, you're
out of luck. Wait for 5.006 or get a development version.
++ The point is probably that ^N = 14
++ = length("ActivityKey:A0"), but so what? Can I just always skip the
++ first two bytes of the input? Can some please enlighten me?
No. Nothing in the UTF-8 standard says that strings start by encoding
their length. If the first 2 bytes somehow indicate the length of the
string, than that's a convention your Java applet uses. That has nothing
to do with Perl.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
------------------------------
Date: Wed, 09 Sep 1998 16:13:27 GMT
From: mcafee@galaga.rs.itd.umich.edu (Sean McAfee)
Subject: Re: How to read an UTF-8 encoded string
Message-Id: <HOxJ1.1817$F7.7721201@news.itd.umich.edu>
In article <6t68af$erh$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>++ The point is probably that ^N = 14
>++ = length("ActivityKey:A0"), but so what? Can I just always skip the
>++ first two bytes of the input? Can some please enlighten me?
>No. Nothing in the UTF-8 standard says that strings start by encoding
>their length. If the first 2 bytes somehow indicate the length of the
>string, than that's a convention your Java applet uses.
Actually, it's a convention Java itself uses--a modified UTF8 which
Pascal-izes strings with an initial length word (length of the encoding in
bytes, not number of characters encoded), and also encodes the null
character in an alternate way.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 09 Sep 1998 15:46:20 GMT
From: richardashrowan@my-dejanews.com
Subject: Internet Developer Job Vacancy
Message-Id: <6t67sc$et1$1@nnrp1.dejanews.com>
Internet developer/Network support
Based in Penrith, Cumbria, UK
(Edge of the Lake District)
As a key player in the Collectible World Studios online team you will assume a
technical lead in the implementation and maintenance of back-end Web systems,
PERL coding, Web servers and SQL databases, alongside some basic Microsoft NT
administration duties. A hunger for knowledge and a desire for personal
development is essential. The successful candidate will have a combination of
two or more of the following skills; CGI/PERL, SQL, NT/UNIX administration,
Windows 95 networks, HTML.
Contact:
Richard Ashrowan
Online Director
Collectible World Studios
http://www.collectibleworld.com
Tel: 01768 892733 Fax: 01768 892722
Wetheriggs Pottery | Clifton Dykes | Penrith | Cumbria | CA10 2DH
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 09 Sep 1998 15:25:21 GMT
From: mcafee@galaga.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Looking for a programm in Perl!:=)
Message-Id: <B5xJ1.1811$F7.7691212@news.itd.umich.edu>
In article <35F68DD8.2F355C2B@wanadoo.fr>,
Plate Forme Jeunes Diplomes <plateforme@wanadoo.fr> wrote:
> That is that I have ever wrote, and now, I can't do anything.
> The loop doesn't work.
Yes, it does.
> The searchnig string doesn't work.
No, it doesn't.
> The print doesn't work...
Yes, it does.
> #!/usr/bin/perl
If this first line is indented in your program, it shouldn't be.
>open (FILE,"/win95/Perl/dr129a.htm") or die ("Impossible de trouver le fichier
>: $!");
>while (<FILE>) {
>chomp;
>$offre=$1 if ~m/(Offre.*?X)/s;
This line should be:
$offre = $1 if m/(Offre.*?X)/;
What you were probably trying to do is this:
$offre = $1 if $_ =~ m/(Offre.*?X)/s;
The "~" must always be a part of "=~" when matching a pattern, and the "=~"
is a link between the thing being matched against and the pattern. You can
omit the explicit link when the thing being matched against is $_ (as it is
here). The /s flag on the pattern is useless because it only affects
strings with newline characters in them, and your "chomp" takes out the
single newline character at the end of the input string.
Incidentally, you can also omit the "m" before the pattern if your
delimiter character is "/" (as it is here), so your statement can reduce to
this:
$offre = $1 if /(Offre.*?X)/;
>$date=$1 if ~m/(Date.*?98)/s;
>$Ale=$1 if ~m/(Ale.*?TD)/s;
>$duree=$1 if ~m/(Recherche.*?FONT)/s;
>$descriptif= $1 if ~m/(CENTER.*?FONT)/s;
>$lieu=$1 if ~m/(Lieu.*?FONT)/s;
>$horaires =$1 if ~m/(Horaires.*?FONT)/s
Change all of these lines in a similar way, and your script should work.
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 09 Sep 1998 15:41:10 GMT
From: dave@mag-sol.com
Subject: Re: Manpage Wrapper
Message-Id: <6t67il$ehq$1@nnrp1.dejanews.com>
In article <35F67C53.18B30AEA@nrgn.com>,
pstarbard@nrgn.com wrote:
> A few years ago I remember downloading a script that would strip tagged
> lines from a perl script and generate a man page automatically. I think
> it was called "wrapman" or something like that. I have since switched
> jobs and the scipt was lost in the process. If anyone has heard of it
> or anything like it please let me know where I can find it.
>
> Any help is greatly appreciated.
Alan,
Sounds like you mean pod2man which is bundled with your Perl distribution. To
get help on the various tags that POD (or 'Plain Old Documentation') consists
of type 'perldoc perlpod'.
hth,
Dave...
--
dave@mag-sol.com
London Perl M[ou]ngers: <http://www.mag-sol.com/London.pm/>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 09 Sep 1998 15:45:47 GMT
From: beju@my-dejanews.com
Subject: Re: merge arrays and strings
Message-Id: <6t67rb$eso$1@nnrp1.dejanews.com>
thanks for feedback, your pointers and solutions.
very much thanks to all of you who helped me...
greetings...
..beju.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Wed, 9 Sep 1998 08:31:17 -0700
From: "Carey Sublette" <careys@paciolan.com>
Subject: Newbie Nested Reference Syntax Question
Message-Id: <6t66v2$hig$1@nnrp2.crl.com>
I have been fiddling with this for quite a while but just cannot get the
syntax to do this right.
I'm trying to create a hash, whose values are references to anonymous hashes
(whose values are in turn references to lists of arbitrary length). The
whole purpose of this is to read in a multi-column table of values line by
line and sort it into categories (the keys to the first hash) and
subcategories (the keys to the second level hashes).
I can generate the first level hash just fine but creating the anonymous
references is mystifying me (yes, I have been studying the perlref manpage,
the book "Learning Perl" is of no help at all).
undef %master;
while (<MASTERLIST>) {
chomp;
@fields = split(/\t/,$_);
$master{$fields[$headerfield1]} = [ $fields[$headerfield2],
$fields[$namefield], $fields[$commentfield]];
#Does this create a reference to an anonymous array correctly?
#And what to do about the second level hash, for which
$fields[$headerfield2] would be the key?
};
close(MASTERLIST);
unless (open OUT, ">Output.txt"){
die "Couldn't open Output.txt\n";
};
@masterKey = sort keys %master;
foreach $masterKey (@masterKey) {
print OUT ($masterKey, "\n");
print OUT ($master{$masterKey}); #This just prints stuff like
"ARRAY(0xca48f8)", symbol table entries right?
}
Thanks for any help straightening out my thinking here.
Carey Sublette
------------------------------
Date: Wed, 09 Sep 1998 15:48:41 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Newbie Nested Reference Syntax Question
Message-Id: <35F6A4D5.5978586A@shaw.wave.ca>
[posted & mailed]
Carey Sublette wrote:
>
> I can generate the first level hash just fine but creating the
> anonymous references is mystifying me (yes, I have been studying the
> perlref manpage, the book "Learning Perl" is of no help at all).
perlref is a good place to start, but you cannot do without perldsc, the
Perl Data Structures Cookbook. This is the ultimate reference until you
become familiar with the syntax. After that it is still probably worth
taking a look at now and then.
--
Rick Delaney
rick.delaney@shaw.wave.ca
------------------------------
Date: Wed, 09 Sep 1998 15:52:23 GMT
From: mcafee@galaga.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Newbie Nested Reference Syntax Question
Message-Id: <XuxJ1.1815$F7.7707856@news.itd.umich.edu>
In article <6t66v2$hig$1@nnrp2.crl.com>,
Carey Sublette <careys@paciolan.com> wrote:
>I'm trying to create a hash, whose values are references to anonymous hashes
>(whose values are in turn references to lists of arbitrary length). The
^^^^^
<mode type=pedantic> "arrays" </mode>
>whole purpose of this is to read in a multi-column table of values line by
>line and sort it into categories (the keys to the first hash) and
>subcategories (the keys to the second level hashes).
>I can generate the first level hash just fine but creating the anonymous
>references is mystifying me (yes, I have been studying the perlref manpage,
>the book "Learning Perl" is of no help at all).
Time to invest in "Programming Perl", and/or read the perlref manpage.
>undef %master;
>while (<MASTERLIST>) {
> chomp;
> @fields = split(/\t/,$_);
> $master{$fields[$headerfield1]} = [ $fields[$headerfield2],
>$fields[$namefield], $fields[$commentfield]];
> #Does this create a reference to an anonymous array correctly?
Yes.
> #And what to do about the second level hash, for which
>$fields[$headerfield2] would be the key?
I'm not entirely clear on what you want to do; is it like this?
%master =
{ $fields[$headerfield1] =>
{ $fields[$headerfield2] =>
[ $fields[$namefield], $fields[$commentfield] ],
...
},
...
};
If so, change your assignment to this:
$master{$fields[$headerfield1]}->{$fields[$headerfield2]} =
[ $fields[$namefield], $fields[$commentfield] ];
Or, for short (using an array slice and the fact that -> is optional
between brackets):
$master{$fields[$headerfield1]}{$fields[$headerfield2]} =
[ @fields[$namefield, $commentfield ] ];
If there was an entry with first-level header "FOO" and second-level header
"BAR", you would access it like this:
$arrayref = $master{"FOO"}{"BAR"};
print $arrayref->[0], $arrayref->[1]; # for example
>};
>close(MASTERLIST);
>unless (open OUT, ">Output.txt"){
> die "Couldn't open Output.txt\n";
> };
>
>@masterKey = sort keys %master;
>foreach $masterKey (@masterKey) {
> print OUT ($masterKey, "\n");
> print OUT ($master{$masterKey}); #This just prints stuff like
>"ARRAY(0xca48f8)", symbol table entries right?
No, stringified references. This is one way to print out your data
structure:
$" = ", ";
while (($key1, $val1) = each %master) {
# now $key1 = header 1, $val1 = ref to hash
while (($key2, $val2) = each %$val1) {
# $key2 = header 2, $val2 = ref to array
print "header1 = $key1, header2 = $key2, list = @$val2\n";
}
}
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: Wed, 09 Sep 1998 16:36:44 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Off topic, but ... [Was Re: Perl & Java - differences and uses]
Message-Id: <8c7lzdz1it.fsf@gadget.cscaper.com>
>>>>> "Bill" == Bill 'Sneex' Jones <sneaker@sneex.fccj.org> writes:
Bill> Oh I don't know, I don't think anyone will miss
Bill> Washington State :]
Hey, watch out. We have to have *some* insulating buffer
to keep the Canadians from flooding into Oregon.
Washington - the great DMZ.
Ditto for California (shielding us from Mexico). :)
Just another post I'll probably regret tomorrow, :)
--
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@teleport.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: 09 Sep 1998 17:45:21 +0100
From: Jim Brewer <jimbo@soundimages.co.uk>
Subject: Re: Off topic, but ... [Was Re: Perl & Java - differences and uses]
Message-Id: <uk93dmdzy.fsf@jimbosntserver.soundimages.co.uk>
Randal Schwartz <merlyn@stonehenge.com> writes:
>
> >>>>> "Bill" == Bill 'Sneex' Jones <sneaker@sneex.fccj.org> writes:
>
> Bill> Oh I don't know, I don't think anyone will miss
> Bill> Washington State :]
>
> Hey, watch out. We have to have *some* insulating buffer
> to keep the Canadians from flooding into Oregon.
>
> Washington - the great DMZ.
> Ditto for California (shielding us from Mexico). :)
>
> Just another post I'll probably regret tomorrow, :)
Hey, what about the Atlantic Ocean. That's a REAL DMZ. Shielding us
from North America. Funny that. Big, cold, deep. Perfect.:)
--
Jim Brewer
e-mailed courtesy copies are unappreciated, please refrain.
------------------------------
Date: 9 Sep 1998 04:34:52 GMT
From: Chris Sidi <sidi@angband.org>
Subject: Proposal: relative_time() for Time::Local module
Message-Id: <6t50hc$gd4$1@news-int.gatech.edu>
I've been doing a lot of relative time stuff recently, like finding
midnight today or last Sunday midnight. I don't want to use a big
Date/Time module that parses a string for every conceivable absolute and
relative time format, but I can't just subtract hours, minutes, and
seconds because of daylight savings shifts.
I'd like to propose this lightweight subroutine for finding relative time
for inclusion in Time::Local:
sub reltime {
my ($start_time, $delta_secs) = @_;
my $rel_time = $start_time + $delta_secs;
my $start_isdst = (localtime($start_time))[8];
my $rel_isdst = (localtime($rel_time))[8];
my $shift_hours = $start_isdst - $rel_isdst;
if ($shift_hours and
$rel_isdst == (localtime($rel_time+$shift_hours*3600))[8] ) {
$rel_time += $shift_hours*3600;
}
return $rel_time;
}
Usage:
use Time::Local;
my $t1 = timelocal(0,0,12,5,3,98); #12:00pm jump forward day
#Midnight that day - wrong
my $m1 = $t1-12*60*60; print scalar localtime $m1,"\n";
#Midnight that day - right
my $m2 = reltime($t1, -12*60*60); print scalar localtime $m2,"\n";
#1:30am on leap forward day
my $one30am = reltime($m2, +1.5*60*60);
#There is no 2:30am on leap forward day, so IMO 1:30am + 1hr should equal
#3:30am (i.e. no correcting for dst shift). Otherwise, people might have
#infinite loops if reltime($one30am, +60*60) == $one30am
my $hour_later = reltime($one30am, +60*60);
print scalar localtime $hour_later, "\n";
If you think there's a better name for the subroutine (like
correct_for_dst_shift()), let me know. All comments and references
appreciated.
Thanks,
Chris Sidi
--
perl -le '$_=" "x63 ."#";while(s/ #+/"#"." "x(-2+length$&)."#"/eg){print}'
------------------------------
Date: Wed, 09 Sep 1998 16:40:59 GMT
From: David@iqtexas.com
Subject: sprintf error in Perlis and PerlScript
Message-Id: <6t6b2r$jff$1@nnrp1.dejanews.com>
When ever I use sprintf in Perlis or ASP(PerlScript), errors are returned.
When the line is commented out, the program runs smoothly.
When the line is not commented and I use Perl.exe, the program runs smoothly.
...
y=1034.5635;
x=sprintf("%.1f",y);
...
Is anyone having this problem? I have the most recent version of ActivePerl.
I'm using a work around but it's clumsy, slow and crazy.(Note data is always
+)
if (y =~ m/^(\d+\.\d)\d*$/) {
x=$1;
} elsif (y =~ m/^(\d+)$/) {
x=$1.'.0';
}
yuk!
Thanks for any help,
David
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Tue, 08 Sep 1998 11:39:00 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Test language in perl
Message-Id: <35F54F94.F7CDFCA4@min.net>
Ken VanCouvering wrote:
>
> Are there any examples of BASIC like test languages written in perl?
> We have a language already in place that is currently implemented by
> translating to FORTRAN and compiling.
> I would like to replace and extend this by using a perl core for the
> parse and eval loop.
Interesting. Can you post the grammar for this language?
I bet someone could whip up a parser for it pretty quick.
John Porter
------------------------------
Date: 09 Sep 1998 12:05:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Test language in perl
Message-Id: <x7vhmxz2yv.fsf@sysarch.com>
>>>>> "JP" == John Porter <jdporter@min.net> writes:
JP> Ken VanCouvering wrote:
>> Are there any examples of BASIC like test languages written in
>> perl? We have a language already in place that is currently
>> implemented by translating to FORTRAN and compiling. I would like
>> to replace and extend this by using a perl core for the parse and
>> eval loop.
JP> Interesting. Can you post the grammar for this language?
JP> I bet someone could whip up a parser for it pretty quick.
there is a version of yacc (byacc IIR) which can generate perl (instead
of C) code which does the parsing of the yacc grammar. if you can write
the grammar in yacc and use perl (more fun than lex) for the tokenizing,
you would have what you want.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 09 Sep 1998 16:39:29 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Test language in perl
Message-Id: <8c3ea1z1e9.fsf@gadget.cscaper.com>
>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
Uri> there is a version of yacc (byacc IIR) which can generate perl (instead
Uri> of C) code which does the parsing of the yacc grammar. if you can write
Uri> the grammar in yacc and use perl (more fun than lex) for the tokenizing,
Uri> you would have what you want.
As an avid CPAN watcher, may I also point out Parse::Yapp (yacc for
Perl, nicely done) and Parse::Lex (lex for Perl), amazingly both done
by people in ".fr" with no knowledge of each other. What is it about
reinventing standard tools in France, anyway? :)
I'm still waiting for them to both do a project that uses each other's
tools. Then we can see if it all plays together.
print "Just another Perl hacker,"
--
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@teleport.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: Wed, 09 Sep 1998 10:07:50 -0500
From: mchen@aud.alcatel.com (Michael Chen)
Subject: unsubscribe
Message-Id: <35F699C6.1484ECA2@aud.alcatel.com>
unsubscribe
------------------------------
Date: Tue, 08 Sep 1998 11:31:08 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Why Perl ?
Message-Id: <35F54DBC.1BE4957F@min.net>
Jerry Pank wrote:
>
> Is there a way, with a $atan$pawn O$ to use command line perl (and not
> have the results scroll off into oblivion)?
>
> Yes, yes. I know get a prope...
It doesn't have to be "get a proper OS". You can make do with a
proper shell program. I highly recommend 4-Win (or whatever the
current incarnation is called; it was originally 4-DOS) by
JP Software. Not unix-compatible at all, but highly capable and
customizable, with aliases, history, scripting language, etc.
If you're on NT, a cmd.exe window can have scroll buffering (not
the same as command history, though it has that too).
Right click on the window title bar, select "Properties...", and
the "Layout" pane; in the "Screen Buffer Size" box, make the
height be something large, like 500. This is your scroll-back
buffer size.
John Porter
------------------------------
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 3669
**************************************