[9974] in Perl-Users-Digest
Perl-Users Digest, Issue: 3566 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 27 18:03:22 1998
Date: Thu, 27 Aug 98 15:00:25 -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 Thu, 27 Aug 1998 Volume: 8 Number: 3566
Today's topics:
Re: (Simplest) way to convert string to array of chars? <stepherd@gusun.georgetown.edu>
Re: A perl filter script <cbpkxh@arcochem.com>
Adding attributes using perLDAP? djones@walcoff.com
Re: Argh! NT Perl <stepherd@gusun.georgetown.edu>
ask for help in perl script. <kc391860@er.uqam.ca>
Re: backticks and windows <stepherd@gusun.georgetown.edu>
Basis Database perl hook? (Michael Shavel)
Re: COBOL and Perl <jdporter@min.net>
Re: Code Style (Was: How to sort this associative array <jdporter@min.net>
Re: comp.lang.perl.windows.misc <stepherd@gusun.georgetown.edu>
Re: comp.lang.perl.windows.misc (Larry Rosler)
Re: comp.lang.perl.windows.misc (Nathan V. Patwardhan)
Re: comp.lang.perl.windows.misc (Michael J Gebis)
Re: comp.lang.perl.windows.misc (Larry Rosler)
Re: comp.lang.perl.windows.misc (Larry Rosler)
Re: Determining strlen <dave@nic.com>
Re: Determining strlen <dgris@rand.dimensional.com>
Re: Determining strlen (Michael J Gebis)
Re: Exporting Methods <zenin@bawdycaste.org>
Re: how can I print 10 digit nos. using 0s as place hol <jdporter@min.net>
Re: how can I print 10 digit nos. using 0s as place hol <zenin@bawdycaste.org>
Instance Method References <daedalus@sol.EBay.Sun.COM>
Re: Max value in an array (Larry Rosler)
Re: Misinterpreted => why no true/false keywords? (Mark-Jason Dominus)
Re: need and INI File parser in perl <psuravar@cisco.com>
Re: newbie question <jdw@dev.tivoli.com>
Re: newbie variable question... <nbailie@harris.com>
Re: newbie variable question... (Patrick Timmins)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Aug 1998 16:53:11 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
To: Benjamin Low <b.d.low@unsw.edu.au>
Subject: Re: (Simplest) way to convert string to array of chars?
Message-Id: <35E5C736.46BFD9EC@gusun.georgetown.edu>
Maybe I don't quite understand the question but what's wrong with:
$word = "hello";
@letters = split(//, $word);
??
--Dave Stephens
Benjamin Low wrote:
> What's a simple foolproof way to convert a string to an array, each
> element of which is one character of the string?
>
> e.g. "hello" -> ( h e l l o)
>
> Is there any way of doing this with pack/unpack? I have
>
> @chars = unpack('a' x length($string), $string);
>
> This isn't particularly elegant, if you ask me, especially if $string is
> a constant.
>
> I have these two variations with split:
>
> @chars = split(/.??/, $string);
>
> @chars = split(/0x00*/, $string); # assuming 0x00 isn't in string
>
> Which is better (unpack vs split) from a performance point of view?
> (I've assumed unpack is).
>
> --
> Benjamin Low
> Web Programmer, Communications Unit, University of New South Wales
> (02) 9385 1138 b.d.low@unsw.edu.au b.d.low@ieee.org
------------------------------
Date: Thu, 27 Aug 1998 20:17:19 GMT
From: "Kevin Hawley" <cbpkxh@arcochem.com>
Subject: Re: A perl filter script
Message-Id: <01bdd1ef$b3d65900$2339f9a5@dyyfc1.aca.arcochem.com>
This goes in the .forward file:
|/home/user1/prog_dir/dist_mail.pl
This in the perl program:
@mail_mesg = <STDIN>;
You seem to know what to do from here.
HTH
-Kevin
Phil Barone <pbarone@cape.net> wrote in article
<35E35A90.216E1F58@cape.net>...
> What I would like to do is write a simple perl filter for my mail
> messages.
>
> 1.) grab the incoming mail message(use .forward file?)
> 2.) grab some info from it(I know how to do this once i get it into the
> script)
> 3.) send the modified message it on its way for my mail reader for
> reading
>
> What I don't know is how/where to implement such a thing. An example
> would be nice.
> I have loaded Graham Barr's MailTools kit, but don't know how to use it!
>
> Thanks for any help.
> pbarone@harris.com
>
>
>
>
------------------------------
Date: Thu, 27 Aug 1998 19:46:04 GMT
From: djones@walcoff.com
Subject: Adding attributes using perLDAP?
Message-Id: <6s4d1s$54c$1@nnrp1.dejanews.com>
I have installed Netscapes perLDAP module, and it seem to work fine for
searching updating single value attributes. But I'm having a problem trying
to get it to update attributes that might have more then one value. Even
their modattr.pl script that come with the moduld doesn't seem to work
despite what the documentation says. Any sugestions/comments
-David
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 27 Aug 1998 16:40:42 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
Subject: Re: Argh! NT Perl
Message-Id: <35E5C44A.22C5F502@gusun.georgetown.edu>
For Win32 platforms you must associate the .pl file extension with Perl.exe in
the Windows file types menu. ActiveState perl w/ IIS does all this
automatically, but then you have to deal with all the things that ActiveState
doesn't support.
(From windows explorer VIEW-->Options-->File Types). Add new file type, actions
= open. Define open as the path to Perl.exe
with "%1" after it. Example c:\perl\bin\perl.exe "%1".
Restart your web server. If using Netscape Enterprise or Fastrack don't forget
to edit your mime.type file to include
type=magnus-internal/shellcgi exts=pl
Define a shellcgi directory then restart the server.
Luck.
--Dave Stephens
Bbirthisel wrote:
> Hi Jeff:
>
> >and the files run from the command line but not from the web, .pl files
> >when typed in the browser actually open the prompt box "save file or
> >open"
> >
> >Would appreciate any help.
>
> This is a (quite common, actually) web server setup problem.
> The installer for perl knows how to tell NT about perl - but
> not how to tell "all possible web servers". So it doesn't change
> ANYTHING in the web server. You need to look at the docs
> for your web server. You didn't say which one you have -
> and further advice is VERY server-specific. For Apache and
> IIS, you can check the mail archives at www.ActiveState.com -
> this question has been asked (and answered) regularly.
>
> Good luck,
>
> -bill
> Making computers work in Manufacturing for over 25 years (inquiries welcome)
------------------------------
Date: Thu, 27 Aug 1998 20:53:34 GMT
From: MANIRATH SOUBINH <kc391860@er.uqam.ca>
Subject: ask for help in perl script.
Message-Id: <35E5C74D.4BD1@er.uqam.ca>
hi!
I would like to write a perl script that save form data to
a file in unix server. I've read many examples of perl
script but i've found only the examples that send data
form to email.
Is there anybody who could help me please ?
Laurent,
------------------------------
Date: Thu, 27 Aug 1998 16:04:47 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
To: b_redeker@hotmail.com
Subject: Re: backticks and windows
Message-Id: <35E5BBDF.F7D2E9BD@gusun.georgetown.edu>
I copied you code exactly and it worked just fine on my NT 4.0 box
w/ Perl 5.004_02. Output of the script was:
Output: hey
You must not be holding your mouth right when you hit the Enter key. <grin>
--Dave Stephens
b_redeker@hotmail.com wrote:
> now I am convinced that this must be a FAQ,
> so if you know where to find the answer,
> please send me there
>
> $out = `echo hey`;
> print "Output: $out\n";
>
> In the above, $out doesn't capture the output.
> So what am I doing wrong? (besides using windows =o)
>
> --
> Boudewijn
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 27 Aug 1998 16:39:23 -0400
From: mshavel@erols.com (Michael Shavel)
Subject: Basis Database perl hook?
Message-Id: <mshavel-2708981639230001@130.9.16.207>
Hi
This is probably a long shot but I'll give it a try anyway. Wondering if
anyone has written a perl script (they would be willing to share) which
hooks into a BasisPlus database.
I have BasisPlus 8.2 running on a UNIX box. I'm trying to write a script
that will monitor a directory and import any files (The files will ALL be
Word Docs) that are put there as a single text_stream field into a Basis
Database. I have no problem with the perl stuff but don't really
understand how to hook into the database. The only reference I currently
have is a sample C app (I am not a very experienced C programmer).
If anyone has any suggestions or examples It would be very much appreciated.
Thanks very much.
Mike Shavel
mshavel@erols.com
------------------------------
Date: Thu, 27 Aug 1998 17:15:23 -0400
From: John Porter <jdporter@min.net>
Subject: Re: COBOL and Perl
Message-Id: <35E5CC6B.1467@min.net>
Shaun C. Murray wrote:
>
> In article <35E1ABCE.363550E1@cks.ssd.k12.wa.us>, joneil@cks.ssd.k12.wa.us
> says...
> >
> >I know no COBOL, but I work in an environment where I am surrounded by
> >COBOL people. A 'real world' example: Recently one of these poor COBOL
> >slaves (that's a term of endearment, really) came to me with a extract
> >file from a small database from one of our departments. He was dismayed
> >that the file format was not fixed width, but tab delineated.
>
> I'd be dismayed at your COBOL programmers if that was a valid complaint.
>
> >Apparently either COBOL or COBOL slaves have an affinity for fixed width
> >fields, and he was lamenting all the time it would take him to write a
> >conversion routine. I took the file and with one regex and a printf(),
> >all was well in COBOL land. The PCS was absolutely amazed and
> >appropriately grateful.
>
> Post your perl code and I'm sure the group can do it in less lines in COBOL.
> Then give it to your PCS and tell him to take a refresher course.
I get the impression that "less lines" is not the proper COBOL
esthetic -- whereas it sorta is in Perl culture.
What follows is a complete perl program.
On unix, you might put it in a file named (e.g.) "untab", and
execute it by "perl untab < infile > outfile" (no quotes, of course).
# let's just say the desired field widths are known to be these:
@field_widths = qw( 8 12 15 20 10 );
# read from stdin or the named files; write to stdout.
while(<>){
printf "@{[map{'%'.$_.'s'}@field_widths]}", split /\t/;
}
--
John Porter
------------------------------
Date: Thu, 27 Aug 1998 16:12:08 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Code Style (Was: How to sort this associative array?)
Message-Id: <35E5BD98.14E7@min.net>
Haijo wrote:
>
> $foo = $some_long_variable_name == value ? $some_long_variable_name
> : $some_default;
>
Hideous! Bletcherous! just like code I sometimes see:
XmSomeUngodlyLongMotifFunctionName( widget,
arg1, arg2,
arg3, arg4 );
and always in the company of other similar calls:
XmAnotherBletcherouslyLongMotifFunctionName( widget,
arg1, arg2,
arg3, arg4 );
Since all the function names have different lengths,
all the arg lists end up being indented a different amount.
Of course, you also get this hideous indentation not just from
long function names but from deeply nested code.
I see nothing wrong with this:
XmSomeUngodlyLongMotifFunctionName(
widget,
arg1, arg2,
arg3, arg4
);
Although in if the first arg is a "object", as in Xt/Motif calls,
I might put it up on the same line as the function name.
So, I always write the ternary operator this way:
> $foo = $some_long_variable_name == value
> ? $some_long_variable_name
> : $some_default;
unless it all fits on one line:
printf "%d hit%s", $n, $n == 1 ? '' : 's';
--
John Porter
------------------------------
Date: Thu, 27 Aug 1998 16:18:30 -0400
From: Dave Stephens <stepherd@gusun.georgetown.edu>
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <35E5BF15.781C6DCB@gusun.georgetown.edu>
This whole thread seems absurd. We all use perl. Period. This is a group for
Perl users, right? Many of us use multiple platforms, not just one. I'd hate
to see Win32 posts banned even if I do most of my coding on a Unix box simply
because I am sometimes required to do a little Win32 CGI scripting. Who isn't
required to be a little open to multiple platforms nowadays anyway? Clearly
each O/S has its individual strengths and/or weaknesses (even if Win32's
strengths lie merely in its ubiquity and clunky but easy GUI). Who cares if
some of us use modules slightly differently than others, or some of us compiled
the source code while others installed the binary?
In the words of Clarence Thomas (that icon of American morality and martyrdom)
"People, can't we all get along?"
Dave Stephens
Dan Nguyen wrote:
> Bob Trieger <sowmaster@juicepigs.com> wrote:
> : [ posted and mailed ]
> : Dan Nguyen <nguyend7@msu.edu> wrote:
> : -> IMHO, I realy think there is a need for comp.lang.perl.windows.misc,
> : -> with all the Windows people (who don't know how to read the FAQs and
> : -> wonder why chmod() doesn't work.)
> : ->
> : -> I'd like to hear what some other people think about this.
>
> : How will this help solve the problem with all the *nix and Mac people that
> : don't know how to read FAQs?
>
> How about comp.lang.perl.illiterate.misc
> :)
>
> --
> Dan Nguyen | There is only one happiness in
> nguyend7@msu.edu | life, to love and be loved.
> http://www.cse.msu.edu/~nguyend7 | -George Sand
------------------------------
Date: Thu, 27 Aug 1998 13:28:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <MPG.104f615079d4c9c4989803@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35E5BF15.781C6DCB@gusun.georgetown.edu> on Thu, 27 Aug 1998
16:18:30 -0400, Dave Stephens <stepherd@gusun.georgetown.edu> says...
> This whole thread seems absurd. We all use perl. Period. This is a group for
> Perl users, right? Many of us use multiple platforms, not just one. I'd hate
> to see Win32 posts banned even if I do most of my coding on a Unix box simply
> because I am sometimes required to do a little Win32 CGI scripting. Who isn't
> required to be a little open to multiple platforms nowadays anyway? Clearly
> each O/S has its individual strengths and/or weaknesses (even if Win32's
> strengths lie merely in its ubiquity and clunky but easy GUI). Who cares if
> some of us use modules slightly differently than others, or some of us compiled
> the source code while others installed the binary?
Agreed.
> In the words of Clarence Thomas (that icon of American morality and martyrdom)
> "People, can't we all get along?"
You have trouble adding, but quoting too???
Clarence Thomas ne Rodney King (that icon of American morality and
martyrdom).
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 27 Aug 1998 20:55:06 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <KIjF1.58$V5.424229@shore>
Larry Rosler (lr@hpl.hp.com) wrote:
: Clarence Thomas ne Rodney King (that icon of American morality and
: martyrdom).
"Is that a pubic hair in your coke"? *whack whack whack*
Man of vision -- indeed.
--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>
------------------------------
Date: 27 Aug 1998 21:16:14 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <6s4iav$e6m@mozo.cc.purdue.edu>
gbacon@itsc.uah.edu (Greg Bacon) writes:
}In article <6s20td$srj@mozo.cc.purdue.edu>,
} gebis@fee.ecn.purdue.edu (Michael J Gebis) writes:
}: gbacon@cs.uah.edu (Greg Bacon) writes:
}: }Please provide evidence for the claim that people who post from the
}: }.edu TLD are rude and clueless.
}:
}: The "September" part of Abigail's attribution line.
}That's a reference to the flood of discurteous freshmen every September.
}Most of the freshmen usually learn better or get lost by the end of
}September. Win32 users have had several years. What's the difference?
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Or...Win32 users don't become "new" on an easy to track semester
schedule, so there's alsways a background noise of rudeness instead of
a single intense month of rudeness. The statement "Win32 users have
had several years" may be true for the group, but is almost certainly
false for the individual asking a question here.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 27 Aug 1998 14:25:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <MPG.104f6ebb8da56d0a989805@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <KIjF1.58$V5.424229@shore> on Thu, 27 Aug 1998 20:55:06 GMT,
Nathan V. Patwardhan <nvp@shore.net> says...
> Larry Rosler (lr@hpl.hp.com) wrote:
>
> : Clarence Thomas ne Rodney King (that icon of American morality and
> : martyrdom).
>
> "Is that a pubic hair in your coke"? *whack whack whack*
>
> Man of vision -- indeed.
I was stating no value judgment about Clarence Thomas, just correcting a
misattributed quotation. Let's not get involved in politics here,
PLEASE.
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 27 Aug 1998 14:49:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: comp.lang.perl.windows.misc
Message-Id: <MPG.104f7458747bc4a9989806@nntp.hpl.hp.com>
In article <6s49qq$j0f$2@info.uah.edu> on 27 Aug 1998 18:51:06 GMT, Greg
Bacon <gbacon@itsc.uah.edu> says...
> In article <6s20td$srj@mozo.cc.purdue.edu>,
> gebis@fee.ecn.purdue.edu (Michael J Gebis) writes:
> : gbacon@cs.uah.edu (Greg Bacon) writes:
> : }Please provide evidence for the claim that people who post from the
> : }.edu TLD are rude and clueless.
> :
> : The "September" part of Abigail's attribution line.
>
> That's a reference to the flood of discurteous freshmen every September.
> Most of the freshmen usually learn better or get lost by the end of
> September. Win32 users have had several years. What's the difference?
IIRC, that September 1993 date refers to the introduction of a Web
browser on Windows 3.1 systems, providing ready access to the Web (and
ultimately to Usenet) for the unwashed (ar at any rate, un-lynx-ed and
un-mosaic-ed) hordes of non-Unix folks. Nothing specific about .edu
there -- they used Apply anyway :-)
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 27 Aug 1998 16:06:48 -0400
From: Dave Wreski <dave@nic.com>
Subject: Re: Determining strlen
Message-Id: <35E5BC57.AA9F102C@nic.com>
}he did say he figure that out. read the posting, he needs substr or
}some other perl hack to truncate.
> Wouldn't it be cool if length could be an lvalue?
> length($str)=80;
Umm.. actually, I thought I understood how to find the length. The problem is I need to
pull out just the URL from the string, and take the length of that, not the entire
string.
If I do something like:
if ($str =~ /<A HREF=http:/)
...
it works ok, but I don't understand why the following doesn't work:
if ($str =~ /<A HREF=http:*>/)
...
Argh, very frustrating, and the FAQ is more complicated than I"m ready for right now..
I just haven't had the time to learn how to do this..
Thanks,
Dave
------------------------------
Date: Thu, 27 Aug 1998 21:10:36 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Determining strlen
Message-Id: <6s4h67$cmk$1@rand.dimensional.com>
[posted to comp.lang.perl.misc and mailed to the cited author]
In article <35E5BC57.AA9F102C@nic.com>
dave@nic.com wrote:
>it works ok, but I don't understand why the following doesn't work:
>
> if ($str =~ /<A HREF=http:*>/)
That says to match the literal string `<A HREF=http', followed
by 0 or more colons, followed by a literal `>'. It matches
these-
<A HREF=http::::::::::::::::::::::::::::::::::::::::::::>
<A HREF=http:>
<A HREF=http>
To get it to match the whole string you're trying for
this will work (I think Larry Rosler posted something
similar)-
if ($str =~ /<A HREF=http:.*?>/)
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
Dave Clark
------------------------------
Date: 27 Aug 1998 21:01:29 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Determining strlen
Message-Id: <6s4hf9$ds3@mozo.cc.purdue.edu>
nvp@shore.net (Nathan V. Patwardhan) writes:
}Michael J Gebis (gebis@fee.ecn.purdue.edu) wrote:
}: Wouldn't it be cool if length could be an lvalue?
}: length($str)=80;
}Sounds like you need to subscribe to perl5-porters. :-)
Every time I'm off perl5-porters, I wish I was on it.
Every time I'm on perl5-porters, I wish I was off it.
I'm in an "off" cycle right now.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 27 Aug 1998 21:39:56 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Exporting Methods
Message-Id: <904253919.664825@thrush.omix.com>
Jan Krynicky <JKRY3025@comenius.ms.mff.cuni.cz> wrote:
>snip<
: I would use
: package Msql;
: sub myquery {
: my $dbh = shift;
: # Just stick the method here, dummy.
: }
: package main; # or whatever it was
Why worry what package you started in when perl can automatically
bring you back:
package whatever;
{
package Msql;
sub myquery {
my $dbh = shift;
# Just stick the method here, dummy.
}
}
## We're now automatically back in whatever's package space now.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Thu, 27 Aug 1998 16:46:42 -0400
From: John Porter <jdporter@min.net>
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <35E5C5B1.433A@min.net>
Here's a mind-blower for you newbies.
perl
do_it( 111222 ); # number from wherever
sub do_it {
my $n = 10000 * shift;
my $r = \substr($n,6,4);
for ( 1 .. 9999 ) {
$$r = sprintf "%04d", $_;
print "$n\n";
}
}
--
John Porter
------------------------------
Date: 27 Aug 1998 21:49:47 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: how can I print 10 digit nos. using 0s as place holders
Message-Id: <904254510.629653@thrush.omix.com>
John Porter <jdporter@min.net> wrote:
: Here's a mind-blower for you newbies.
You might want to put a "use 5.005" statement at the top of
that, just to be a little nicer to the newbies. :-)
-Ya, ya it worked in lesser perls, but it also core dumps in
them too. :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Thu, 27 Aug 1998 14:23:48 -0700
From: MICHAEL JONES <daedalus@sol.EBay.Sun.COM>
Subject: Instance Method References
Message-Id: <35E5CE64.A1092372@sol.EBay.Sun.COM>
Hi,
I'm trying to set up a derived object that can use specific set/get
methods for certain fields while using the base class' set/get
methods for the rest. Her is what I'm attempting:
package ClassB;
@ISA = qw( ClassA );
$fields = { { 'field_name' => \ClassB->set_this_field } };
sub set_this_field { .. }
package ClassA;
sub set {
if ( $self->{ 'fields' }->{ 'field_name' }->{ 'fn_name' } ) {
$self->( $self->{ 'fields' }->{ 'field_name' } ) ( $field_name,
$value );
} else {
$self->{ 'fields' }->{ 'field_name' }->{ 'value' } = $value;
}
}
My question is, what should be the syntax to make
$fields->{ 'field_name' }->{ 'fn_name' } a reference to
$self->set_this_field.
Also, what is the syntax to call the function at the other end.
I've tried the above example... it just calls the subroutine when
I declare the hash field.
Thanks in advance.
_______________________________________________________________________
"Brought low by an ending so cliche it could have oozed from the
powerbook of the laziest Hollywood hack!" - Sideshow Bob
szaijan@ternea.com daedalus@sol.ebay.sun.com
_______________________________________________________________________
------------------------------
Date: Thu, 27 Aug 1998 13:31:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Max value in an array
Message-Id: <MPG.104f61e9bd08fde9989804@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <35E46899.4B9A92D6@gpu.srv.ualberta.ca> on Wed, 26 Aug 1998
14:57:13 -0500, Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> says...
%: Larry Rosler wrote:
%: >
%: > In article <6s1i2u$9pm$3@marina.cinenet.net> on 26 Aug 1998 17:53:34
GMT,
%: > Craig Berry <cberry@cinenet.net> says...
%: > ...
%: > > Why not just
%: > >
%: > > foreach (@_) { $max = $_ if $_ > $max };
%: > ...
%: >
%: > In 5.005, it can even be done this way, for the braces-impaired:
%: >
%: > $max = $_ if $_ > $max foreach @_;
%: >
%: > Neat, huh?
%: >
%: > (I can't test it, because no 5.005 yet. Sigh...)
%:
%: not quite, from perlsyn:
%:
%: Any simple statement may optionally be followed by a
%: SINGLE modifier, just before the terminating semicolon (or
%:
%: you have two statement modifiers (if and foreach)...although:
%:
%: $max<$_ and $max=$_ foreach @_;
%: $max<$_ and $max=$_ for @_;
%:
%: both work fine with 5.00502
Copy. Paste. Don't read very closely. Don't test before posting.
BUT: At least have the good sense to say 'not tested'. :-)
As for 'foreach' vs. 'for', have you tried grepping anything for 'for'?
I hope not, for beforehand I can fortunately afford to inform you it is
not a comfortable effort. Even your own source, if it has (ugh!)
comments.
--
(Yet Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 27 Aug 1998 16:40:32 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Misinterpreted => why no true/false keywords?
Message-Id: <6s4g80$2u4$1@monet.op.net>
In article <904244138.713210@thrush.omix.com>,
Zenin <zenin@bawdycaste.org> wrote:
> use constant true => 1;
I'm on a campaign to wipe out `use constant'.
Here's why:
use constant true => 1;
loads in five files and 1,094 lines of code (!!!) and can be replaced with
*true = sub () { 1 };
which does exactly the same thing and is shorter to type anyway!
So, the question you have to ask yourself: Is irrational glob fear
worth the expense of 1,094x blowup in code size?
You see, the campaign is really a campaign to educate people about how
to use typeglobs. Since there's only one way to use typeglobs,
education doesn't take very long.
http://www.plover.com/~mjd/perl/TPC/Hardware-notes.html#Manual_Exporting
Get educated!
------------------------------
Date: Thu, 27 Aug 1998 14:33:17 -0700
From: Prasad Suravarapu <psuravar@cisco.com>
Subject: Re: need and INI File parser in perl
Message-Id: <35E5D09D.3129@cisco.com>
Mike Stok wrote:
>
> In article <35E5A89B.725C@cisco.com>,
> Prasad Suravarapu <psuravar@cisco.com> wrote:
>
> >Actually, I did search CPAN before I posted here. The search didn't
> >seem to work well on random words like ini and config. It needed
> >module or author names etc. Someone's got to point me to the right
> >way to search for useful stuff on CPAN.
> >
> >Thanks to Mike Stok <mike@stok.co.uk> for pointing me to the
> >right module.
>
> One of the better things to look through is Jon Orwant's "front page" for
> CPAN
>
> http://www.perl.com/CPAN/CPAN.html
I get the following when I go that page, anyone know why??
-----
Forbidden
You don't have permission to access /CPAN.html on this server.
-----
-Prasad
--
Prasad Suravarapu
Cisco Systems, Inc.
408-526-7997
------------------------------
Date: 27 Aug 1998 13:05:04 -0500
From: "Jim Woodgate" <jdw@dev.tivoli.com>
Subject: Re: newbie question
Message-Id: <obg1eib8rz.fsf@alder.dev.tivoli.com>
No.unsoiliciteds@dead.end (Norman UNsoliciteds) writes:
> written posting that started out as a good intention. One other small
> consideration I'd like to make is that not everybody is using a Un*x
> system - so "perl -de" or "perl -f perlguts(3)", might not mean very much
> as there is no way of looking up the man pages to find out what that all
> means (not being on un*x).
I have perl5 running on an NT box, both perl -de 42 and perldoc -f
<your favorite command> work perfectly.
--
Jim Woodgate
Tivoli Systems
E-Mail: jdw@dev.tivoli.com
------------------------------
Date: Thu, 27 Aug 1998 16:35:40 -0400
From: Nathan Bailie <nbailie@harris.com>
Subject: Re: newbie variable question...
Message-Id: <35E5C31C.1BCD@harris.com>
As usual, There Is More Than One Way To Do It (that is the
Perl saying). Here is a basic way to do it, although
I am sure there are many more efficient methods:
$test = "/home/users/me/cool";
@dirs = split ?/?, $test;
print "$dirs[3]\n";
In this case, your output would be "me"
The split command is very useful. As I used it, it searches
a '/' in the line and uses it to separate the line into various
fields. These are assigned into the array 'dirs.' The '@'
designates taht dirs is an array. I printed out array field
3. The array starts counting at 0 (unless you modify the $
variable which you should not do). In this case, field 0 is
blank since there is no text before the first / in the line.
The '?/?' part of the split command that I used is called a
standard expression. You should look this up and read up on
it. Usually, a standard expression is written with slashes,
such as /truth/ which means search for truth. However since
I was looking for a "/" in this case, it is easier to use
a different character than slash to form the limits of the
standard expression. It is cool that Perl allows
this. An alternative that *should* work would be to use
a backslash to escape the slash that you are searching for
like this:
@dirs = split /\//, $test;
Looks weird, huh?
Hope this helps you out.
Nathan Bailie
nbailie@harris.com
Misagh Ziaei wrote:
>
> Hello,
>
> Here's a question: I have a variable, that is a path string. An
> example...
>
> $test = "/home/users/me/cool";
>
> Is there a way I can strip away all the text except the 'me' part? I
> mean, I want 'me' to be variable, but I don't want all the other
> directories with it. And, under my circumstances, I don't think I can
> make another variable or point to an existing one that might have 'me'.
> I hope I was clear enough. Any help would be appreciated!
>
> - Misagh
------------------------------
Date: Thu, 27 Aug 1998 21:11:41 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: newbie variable question...
Message-Id: <6s4i2c$beq$1@nnrp1.dejanews.com>
In article <35E594BB.8BBD1CC8@nortel.ca>,
Misagh Ziaei <pepstud@nortel.ca> wrote:
> Hello,
>
> Here's a question: I have a variable, that is a path string. An
> example...
>
> $test = "/home/users/me/cool";
>
> Is there a way I can strip away all the text except the 'me' part? I
> mean, I want 'me' to be variable, but I don't want all the other
> directories with it. And, under my circumstances, I don't think I can
> make another variable or point to an existing one that might have 'me'.
> I hope I was clear enough. Any help would be appreciated!
>
> - Misagh
>
Use:
$test =~ s!/home/users/([^/]+).*!$1!;
if I understand you, that is.
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
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 3566
**************************************