[7717] in Perl-Users-Digest
Perl-Users Digest, Issue: 1343 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 19 17:27:24 1997
Date: Wed, 19 Nov 97 14:00:21 -0800
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, 19 Nov 1997 Volume: 8 Number: 1343
Today's topics:
Re: 2 quicks questions, really <usenet-tag@qz.little-neck.ny.us>
Re: Available modules to check script performance (Scott Anthony Hamilton)
cgi-lib question <jmkizer@pagesz.net>
Downcase/Upcase <oesteve@stonehenge.ac.upc.es>
Re: Downcase/Upcase (Jeremy D. Zawodny)
Re: Error for target `depend' when installing <chris_braiotta@harvard.edu>
Re: exclusive file rights (Jeremy D. Zawodny)
Here we go again... If you know perl PLEASE HELP ME!! (Scott DiNitto)
Re: how to invoke sendmail for mailing list? (Jordyn A. Buchanan)
Re: how to invoke sendmail for mailing list? <usenet-tag@qz.little-neck.ny.us>
Re: how to reference index into array by it's value (E.None Archibald)
Re: max size of cookie? <usenet-tag@qz.little-neck.ny.us>
Re: modules, ignoring Tom Phoenix <usenet-tag@qz.little-neck.ny.us>
MS Access Perl OLE Problem mike.dudziak@stoner.com
Re: Regexp that's bugging me (Greg Bacon)
Re: Regexp that's bugging me (Jeff Stampes)
Re: Regexp that's bugging me <usenet-tag@qz.little-neck.ny.us>
Re: returning value of executed program (E.None Archibald)
Re: selecting shell type in UNIX (Andrew M. Langmead)
Re: Split <usenet-tag@qz.little-neck.ny.us>
Re: Tk/Motif/Embedded Perl question (Ken Fox)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Nov 1997 21:30:51 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: 2 quicks questions, really
Message-Id: <eli$9711191659@qz.little-neck.ny.us>
Tom Harrington <tph@rmi.net> wrote:
> Alan (ahecker@interport.net) wrote:
> : 1st question revolves around a sample config file, which contains the
> : following lines:
Lines are in file. Okay.
> : 1:\BThis is a test
> : 2:\BThe time is:\T
...
> : Now, I've been having a hell of a time trying to get this to work out.
> : First, I tried:
> : ($loop, $b, $text, $t) = (\d)\:\\(\w)(.*)\\(*);
This approach works best if you have a backslashed character at the
begining and end always, and never anywhere else. Is that true?
Obviously not given the two sample lines you provided.
> : and variations thereof. Most of the time, I get many "undefined
> : variable" messages. But, as many of you already know, I should just hire
> : out someone to do regexes for me at this point.
You will get that always if you try to shoe horn line 1 style things
into a line 2 style parser.
> The backslashes in the text make this one kinda challenging.
> Keep in mind that "\B" will be seen as an escaped "B", but an
> escaped "B" has no special meaning, it's just a "B". The following
Huh? I got the impression that perl would *not* be evaluating these.
Besides, \B is special in regular expressions, so it won't always
be a "B", sometimes it will be a zero-width assertion that there is
no word boundary at that point.
My guess for what you want is:
($num, $line) = /^(\d+):(.*)/; # break into a number and the rest
@elem = split /(\\\w)/, $line; # split into text and metas
@text = grep /^[^\\]/, @elem; # grab the text bits
@meta = grep /^\\/, @elem; # grab the meta bits
But feel free to discuss in more detail what you want.
Elijah
------
@elem will have null strings for your examples, @text and @meta won't
------------------------------
Date: 19 Nov 97 21:23:53 GMT
From: sah@uow.edu.au (Scott Anthony Hamilton)
Subject: Re: Available modules to check script performance
Message-Id: <sah.879974633@wumpus>
Craig Morris <cdm2@formalsys.ca> writes:
>Hello,
>Does anyone know of any Perl packages, modules, etc...
>that can be used to scan a script for performance bottlenecks.
>I seem to recall hearing about one but I can't remember the
>name. Any help would be appreciated.
This is a FAQ. Look at Benchmark.pm and Devel::DProf.pm.
I would find a code coverage module useful aswell, although I'm
not aware of the existence of one. Something in the line of the 'tcov'
tool that is shipped with some Unix compilers. Anyone looking for a
project? :)
--
Scott Hamilton / sah@uow edu au / KeyID C3107E75
87 FE 1D C3 DE 20 37 FB 6F 30 6A 8A D1 38 9A B5
------------------------------
Date: Wed, 19 Nov 1997 16:13:57 -0500
From: "Janyne M. Kizer" <jmkizer@pagesz.net>
Subject: cgi-lib question
Message-Id: <Pine.LNX.3.95.971119161016.20090B-100000@nina.pagesz.net>
I am relatively new to perl and I am not a programmer, however I have
managed to inherit a script that is not working and I need to fix it. The
script calls cgi-lib.pl
require "cgi-lib.pl";
... much latter in script
&ReadParse(*input);
When I run the script from the command line using perl script.pl, the
following error message is generated:
Content-type: text/html
<html><head><title>cgi-lib.pl: Unknown request method:
</title></head>
<body><h1>cgi-lib.pl: Unknown request method:
</h1>
</body></html>
cgi-lib.pl: Unknown request method
What is this "unknown request method" error message and how do I get rid
or it? Thanks!
Janyne
DogGoneFast Flyball Club Therapy, Flyball, Agility, Obedience
=======================================================================
Janyne Kizer, CNE-3, CNE-4 Apex, NC
Hannah (Cedarwoods Crosscreek Duet, CGC) jmkizer@bigfoot.com
Penny CGC - Rescue Lab http://www.pagesz.net/~jmkizer/
=======================================================================
Greater Raleigh Dog Training Club CUR Station #90
------------------------------
Date: 19 Nov 1997 20:44:37 GMT
From: Octavi Esteve-Volart <oesteve@stonehenge.ac.upc.es>
Subject: Downcase/Upcase
Message-Id: <64vj3l$7hr$1@diable.upc.es>
Hi guys,
I know this is very basic, but how can I downcase/upcase
a string in Perl?
(could you please e-mail me the answer? I'm not a frequent
news user)
Thanks a lot in advance!
Octavi Esteve-Volart
<oesteve@ac.upc.es>
------------------------------
Date: Wed, 19 Nov 1997 21:11:46 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Downcase/Upcase
Message-Id: <347355ce.4981212@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On 19 Nov 1997 20:44:37 GMT, Octavi Esteve-Volart
<oesteve@stonehenge.ac.upc.es> wrote:
>I know this is very basic, but how can I downcase/upcase
>a string in Perl?
Look in the documentation. Check the perlfunc manpage for "uc" and
"lc" functions.
>(could you please e-mail me the answer? I'm not a frequent
>news user)
I'm tempted not to just because you asked.
If you're not willing to look for the answer here, why should I post
it?
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Wed, 19 Nov 1997 16:24:24 -0500
From: Chris Braiotta <chris_braiotta@harvard.edu>
Subject: Re: Error for target `depend' when installing
Message-Id: <347358FA.15D2055A@harvard.edu>
> Chris Braiotta wrote in message <3469F736.B95140CD@harvard.edu>...
> >Halp! I'm trying to install perl 5.004_04 on a Sparc 10 running Solaris
> >2.4. When the Configure program gets to the "make depend" step, I get
> >the following error:
> >
> > make: Fatal error: Command failed for target `depend'
> >
> >Any ideas? I and my sysadmin are stumped.
Thanks to all those who submitted suggestions. The winner is....download GNU
make. Sun's make just didn't do it. Once I download GNU make, it worked like
a charm.
Chris Braiotta
UIS Helpdesk
------------------------------
Date: Wed, 19 Nov 1997 20:29:06 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: exclusive file rights
Message-Id: <34734bb5.2396616@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On Wed, 19 Nov 97 14:26:07 -0500, bsa@void.apk.net (Brandon S. Allbery
KF8NH; to reply, change "void" to "kf8nh") wrote:
>In <8c7ma44xz7.fsf@gadget.cscaper.com>, on 11/19/97 at 10:03 AM,
> Randal Schwartz <merlyn@stonehenge.com> said:
>+-----
>> (re: removing text about advisory file locking from perlfunc.pod/flock)
>| The statement is CORRECT as it stands.
>| What would make you think otherwise?
>+--->8
>
>You did miss the beginning of the thread. flock() is advisory on Unix, but
>is(?) mandatory on Win32. (Which I would chalk up as "another reason to prefer
>Unix for such work", but that's another story. Besides, who am I to throw
>stones? ---EMX's flock() is a stub, so Perl currently does no file locking at
>all on OS/2. Sigh.)
But according to the folks on the p5p list, OS/2 at least supports
mandatory locks. I was under the impression that Perl does (or would
in the near future) make use of it in flock().
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Wed, 19 Nov 1997 20:52:50 GMT
From: sdinitto@kronos.com (Scott DiNitto)
Subject: Here we go again... If you know perl PLEASE HELP ME!!
Message-Id: <34735098.87044944@news>
I have a big problem I am stumped on. I am trying to grab a value from
a scalar in a module. The problem is, the variables in the module are
dynamicly created. So I can not hardcode the variable in my main
program. I am having trouble figuring out how to grab the value I need
from the module and place it in my main program. What I have tried to
do in effect is create a scalar variable from the value of another
scaler... look below:
---
dfk.pl exerpt
------
package brain;
@LV3VolumeSplit = split (/\//,
@main::VolumeList[$main::LoopCountA])
$LV3VolumeJoin = join ("", @main::LV3VolumeSplit);
**As you can see here, I have this array "VolumeList" that
contains volume names that I use for other purposes. I decided to use
the volume names without the forward slashes as variable names in a
package that pertain to the amount of times the volume has been "hit"
according to my program... so if a volume /usr/home was "hit" in my
program, then I wanted an entry to brain.pm to say "$usrhome = 1" and
if hit again "usrhome = 2" and so on... By using the above method, I
am able to get the variable name I need in $LV3VolumeJoin.
$VolVarJoin = "$LV3VolumeJoin";
$main::LV3Value = $$VolVarJoin;
print "$VolVarJoin $$VolVarJoin\n$LV3VolumeJoin\n";
**Here is where I have been having my main problems. I need a
variable in the main package to hold the value of "$usrhome" (which is
1024 look below...)in brain.pm. Why am I using the pointer?? I really
don't need to, but for awhile it looked like a possible solution. it
wasn't. Basicly, what I would like is to be able to do is take the
value of $LV3VolumeJoin (usrhome) and turn it in to a scalar inside
the brain package ($usrhome) that I can use to grab the value 1024 I
want. Is this even possible? How would I go about doing this? If I try
something like $main::LV3Value = $LV3VolumeJoin, I simply get the word
"usrhome" assigned to it. I want the value from $usrhome assigned to
it. I thought if I set up a pointer, $$VolVarJoin could point to
$VolVarJoin ($LV3VolumeJoin) which would then translate to "usrhome"
and try and reference $usrhome's value. But for some reason, the hard
reference doesn't like to see the $ inside of a definition. So am I
basicly screwed here??
package main;
open (BrainCreate, ">>brain.tmp");
print BrainCreate "\$$LV3VolumeJoin= $LV3Value;\n";
close BrainCreate;
};
***Appearantly creating the module file.
brain.pm
---------
#!/usr/bin/perl
#This file is a module. A package is defined here
package brain;
#Variables are to be inserted below and are automaticly generated
$usrhome = 1024;
1;
**The module containing the value I want inported to my main
program.
SD
------------------------------
Date: Wed, 19 Nov 1997 15:08:38 -0500
From: jordyn@bestweb.net (Jordyn A. Buchanan)
Subject: Re: how to invoke sendmail for mailing list?
Message-Id: <jordyn-ya02408000R1911971508380001@news.bestweb.net>
kevink@NOSPAM-mit.edu wrote:
> At first I was looping on the list of subscribers and
> doing this:
>
> system ("/usr/lib/sendmail $subscriber < $letter");
>
> but when I saw how slow it was I moved the loop into
> a shell script:
>
> #/bin/sh
> letter=$1
> for i in `grep command that gets subscribers`
> do
> /usr/lib/sendmail $i < $letter
> done
>
> which I invoke from the perl script, but it doesn't
> look any faster. The reason I did this was because
> I figured the slowness was due to system's having to
> fork a process each time and wait for it to die,
> but now I think it's just that sendmail is so slow.
Sendmail is definitely a large portion of the delay here. The key to
making it work better is to have each sendmail process handle more than one
subscriber, say 25 or so. Just set up the sendmail command like this:
/usr/lib/sendmail name1 name2 name3... < $letter
Make sure that your letter contains a To: header and this should have the
same effect as inserting a big Bcc: list. Generally speaking, I'd say this
question belongs more in a sendmail-related mailing list than one on perl.
Jordyn
|---------------------------------------------------------------|
|Jordyn A. Buchanan jordyn@bestweb.net|
|Bestweb Corporation http://www.bestweb.net|
|Senior System Administrator +1.914.271.4500|
|---------------------------------------------------------------|
------------------------------
Date: 19 Nov 1997 19:59:20 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: how to invoke sendmail for mailing list?
Message-Id: <eli$9711191542@qz.little-neck.ny.us>
Kevin Kelleher <kevink@NOSPAM-mit.edu> wrote:
> Premise: I can't create mail aliases on my ISP, yet I want to
> run a group of email discussion lists.
If you have sendmail, qmail, or MMDF and access to the envelope
address (eg procmail is your MDA) you probably can create aliases, of
a limited sort. See <URL:http://www.netusa.net/~eli/faq/addressing.html>.
> At first I was looping on the list of subscribers and doing this:
> system ("/usr/lib/sendmail $subscriber < $letter");
You probably want -oi on that sendmail. You can use more than one address
on the command line, too. SmartList defaults to four concurrent runs of
sendmail each sending to twenty people.
> but when I saw how slow it was I moved the loop into a shell script:
That is not going to make things faster.
> which I invoke from the perl script, but it doesn't look any faster.
> The reason I did this was because I figured the slowness was due to
> system's having to fork a process each time and wait for it to die,
> but now I think it's just that sendmail is so slow.
Most of the time is spent connecting to the remote site and transmitting
the message (I would bet). This is not a sendmail problem or a perl problem.
> kevink@mit . edu (address altered to avoid spam)
It works great for avoiding lots of other mail as well.
Elijah
------
thinks of "Krazy Kevin" when he sees that address
------------------------------
Date: 19 Nov 1997 21:29:55 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: how to reference index into array by it's value
Message-Id: <64vloj$ddt$2@tepe.tezcat.com>
Abigail <abigail@fnx.com> wrote:
: ++ $a = 0;
: ++ %hash = map { $a++ => $_ } qw (zero one two three four five);
: I guess you mean:
: %hash = map {($_ => $a ++)} qw (zero one two three four five);
Yes, i did. Bah. The qw() comment was also misspoken.
*skulks off to cringe in the careless posting corner*
-e.
------------------------------
Date: 19 Nov 1997 20:03:51 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: max size of cookie?
Message-Id: <eli$9711191552@qz.little-neck.ny.us>
kim slack <kas5670@vaxb.isc.rit.edu> wrote:
> How much data can you fit in a cookie? Geoff
What kind of cookie? I saw a great shortbread recipe the other day,
but is is off-topic here.
Elijah
------
remembers when alt.crackers used to discuss the Tricuit Operating System (TOS)
------------------------------
Date: 19 Nov 1997 20:42:36 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: modules, ignoring Tom Phoenix
Message-Id: <eli$9711191624@qz.little-neck.ny.us>
Jeremy D. Zawodny <jzawodn@wcnet.org> wrote:
> You see, some believe that Tom isn't actually a person, but he is in
> fact a very smart Perl script that is able to recognize and answer
> commonly asker Perl questions[1].
And Kibo doesn't grep Usenet for his name.
> If that's the case, it's fun to see how many you can answer before he
> does. By my count, there are roughly 12 people who engage in this game
> on a semi-regular basis.
brain d foy, I happen to know, has secured a copy of the TomPhoenix.pm
script and done some work chaning the style of the replies. You probably
noticed "he" beat "Tom" this week for top poster, with only a slightly
different response library. The "brian" version is better tuned towards
web and CGI questions.
> [1] Actually, I met Tom at the Perl conference this Summer. :-)
Well, I've met brian at ny.pm meetings.
Elijah
------
specializes in RE questions
------------------------------
Date: Wed, 19 Nov 1997 15:53:31 -0600
From: mike.dudziak@stoner.com
Subject: MS Access Perl OLE Problem
Message-Id: <879975882.9507@dejanews.com>
When I try to open MS Access with the OLE Module on my NT 4.0 system
using perl 5.001 or 5.003 Access Opens for about half a second then
closes. The code is as follows:
$app = CreateObject OLE "Access.Application" ;
$app->{'Visible'} = 1;
$app->OpenDatabase('db1.mdb');
$app->OpenTable('ms_access');
Access does open correctly but immediately closes and the databases do
not open.
Can anybody tell me what the problem is??? Also - I have done alot with
Excel and Word OLE Perl, and they both work fine.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 19 Nov 1997 19:59:30 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Re: Regexp that's bugging me
Message-Id: <64vgf2$b5e$1@info.uah.edu>
[Posted and mailed]
In article <34732A15.DE6@fprsdev3.fmr.com>,
Rick Meldrum <rjk@fprsdev3.fmr.com> writes:
: I am attempting to change one of the parameters in a command string:
:
: $command = 'myprog -a arga -b bbb -c argc'
:
: I need to change the string after -b to "argb",
[ snip ]
$command =~ s/-b\s*.*?(?=\s+|$)/-b argb/g;
or the /x version:
$command =~ s{
-b ## find the option
\s* ## skip any whitespace present
.*? ## gobble the argument
(?=\s+|$) ## stopping at a run of whitespace or end of string
}
"-b argb"gx;
Hope this helps,
Greg
--
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF
------------------------------
Date: 19 Nov 1997 21:20:03 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Regexp that's bugging me
Message-Id: <64vl64$pkg$1@neocad.com>
Rick Meldrum (rjk@fprsdev3.fmr.com) wrote:
: I am attempting to change one of the parameters in a command string:
: $command = 'myprog -a arga -b bbb -c argc'
: $command =~ s:(^.*-b)\s*\S+\s+(.+$):$1 $new_argb $2:;
Why bother messing with the whole command? The only thing you
care about is "If there is a -b foo, change it to -b bar", right?
$command =~ s/-b\s*\S+/-b newarg/;
HTH,
Jeff
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: 19 Nov 1997 21:41:35 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Regexp that's bugging me
Message-Id: <eli$9711191724@qz.little-neck.ny.us>
Rick Meldrum <rjk@fprsdev3.fmr.com> wrote:
> $command = 'myprog -a arga -b bbb -c argc'
> I need to change the string after -b to "argb", I don't know how
> many args are there - or if the -b is even there - and I don't
> know the current value of the -b parameter. This works great...
> $command =~ s:(^.*-b)\s*\S+\s+(.+$):$1 $new_argb $2:;
> ...until the -b bbb is the last arg... Any suggestions?
It fails for other cases you haven't encountered yet, too. (You might
never encounter them though....)
$command =~ s: \s -b \s* \S+ : -b $new_argb:x;
Assuming none of the argument have spaces -- which makes things very tricky.
You only need to know that -b follows some space and has some argument after
it. Forget about the rest of the context, it will just slow you down. I
used /x here to add extra spaces for clarity.
Elijah
------
#!/usr/bin/perl -- -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P&,\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
------------------------------
Date: 19 Nov 1997 21:38:43 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: returning value of executed program
Message-Id: <64vm93$ddt$3@tepe.tezcat.com>
Pat Trainor <ptrainor@bbnplanet.net> wrote:
: Here's a poser:
(OBfoyanswer: a poser is "a puzzling or baffling question," from
"pose" as in "pose a question.")
: how to execute a perl script that calls a unix command, and have the
: output, not return vaalue, returned as a scalar, an array, hash, whatever.
: For example, execute a who and conduct a regex match on the
: output, doing something if a certain user is on-line.
either use the `shelloutcommand` syntax (taking the return), or the
open(FOO,"shellcommand|") || &my_open_failed_oh_no()
syntax, reading from the FOO filehandle.
-e.
--after having a moment of doubt as to whether 'pose' was indeed the
correct spelling, after typing it 3 times. odd phenomenon.
------------------------------
Date: Wed, 19 Nov 1997 20:42:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: selecting shell type in UNIX
Message-Id: <EJwuv4.C5L@world.std.com>
Dan Temple <dant@lsil.com> writes:
>Is there a way to specify which UNIX shell gets called when
>you run a system() command in Perl 5?
>I always get a "sh", although as a user all defaults are "tcsh".
The unix versions of perl intentionally call /bin/sh explicitly (when
it has to call a shell. If the command line is simple enough, it runs
the program itself.) It does this for a couple of reasons:
It increases the portability of scripts. They won't fail when someone
moves the script to a different machine (which may a may not have a
shell other than /bin/sh), when a different user runs the script, or
when the user changes their SHELL environment variable.
It allows possibilities for redirection that are impossible with csh
and its derivatives. Things like "$output = `command 2>/tmp/foo.$$`"
If you want a different shell, you can call it explicitly:
system('tcsh', '-c', $commandline)
or
system("tcsh -c $commandline");
and if you do that, you may find that things start acting funny when a
particlar users aliases or other configuration items start interfering
with what your script is trying to do. In that case, you might want to
look at tcsh's "-f" option.
--
Andrew Langmead
------------------------------
Date: 19 Nov 1997 21:05:20 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Split
Message-Id: <eli$9711191648@qz.little-neck.ny.us>
brian d foy <comdog@computerdog.com> wrote:
> "cadavis" <cadavis@spam.eos.ncsu.edu> wrote:
> >Craig Davis|cdavis@cnp.net
> >$user_name = "Craig Davis"
> >$user_email = "cdavis"
> >$userdomain = "cnp.net"
> $_ = q<Craig Davis|cdavis@cnp.net>;
> m/^ (.*?) [|] (.*?) @ (.*?) $/xg;
Finish it brian, finish it:
($user_name,$user_email,$userdomain) = m/^ (.*?) [|] (.*?) @ (.*?) $/x;
The /g is not needed.
It is really doubtful that the *? is needed, anyway. For this example
just * will give the same results. If you have | or @ in feilds, it
might or might not be useful, but that would require more specifications.
Elijah
------
($user_name,$user_email,$userdomain) = split /[@|]/; # also works
------------------------------
Date: 19 Nov 1997 20:18:46 GMT
From: fox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Tk/Motif/Embedded Perl question
Message-Id: <64vhj6$lh1@eccws1.dearborn.ford.com>
Brian Wheeler <bdwheele@indiana.edu> writes:
> Peter Lagerweij <lagerwey@knmi.nl> writes:
> > Is it possible to use Perl/Tk within a Motif application? I have Perl
> > embedded in a Motif application, and I'd like to have the possibility
> > for user scripts to pop up Tk dialog boxes for simple user interaction.
> > This concept works in the test harness (which doesn't use Motif), but
> > when integrated with the Motif application, I get a curious error ...
This is definitely possible, but you won't be able to use the trivial
event loop for either toolkit. Pick which toolkit you want to run the
controlling event loop in. Then add the file handle for the display
of the slave toolkit as an input source. Whenever you get input
on the slave file handle, invoke the slave's run-one-event command.
Don't expect selections or drag and drop to work between the toolkits.
I don't have any examples laying around, but this is well described
in the documentation for both Tk and Xt. (BTW, you need a recent
release of Tk, but Xt R4 or better will do. Is Perl/Tk derived from
a version of Tk with the necessary event loop support?)
There were some projects underway to embed a Tk widget into an Xt
shell. This can probably be generalized to create a real Tk/Xt
integration similar to the Fresco/Xt integration. It's been a while
since I checked into these projects so they may have been abandoned.
> Hmm. I don't know the answer to your question, but I do have a
> _related_ question: Is it possible to embed perl in a motif application
> and _use_ motif?
Absolutely! I'm working on a Motif module that provides full access
to the X, Xt and Xm libraries. I'm supporting both C-style and OO-style
interfaces. I released an alpha about two months back. The system
built fine in a variety of environments, so I'm reasonably sure that
I'm on the right development track. Unfortunately I got busy with
other projects and I'm just now back into Motif development. I'd like
to have a final release by year end.
Here's a small example, from my (presently terrible) documentation:
--
# This is fairly standard Motif. The Perl interface is much easier
# to use than the C interface because XmStrings are automatically
# created and destroyed and callbacks can be anonymous subroutines.
my $button = XtCreateManagedWidget("button", xmPushButtonWidgetClass, $parent,
XmNlabelString, 'OK',
XmNlabelType, XmSTRING);
XtAddCallback($button, XmNactivateCallback, sub { exit }, 0);
...
if (XtIsManaged($button)) {
XtSetValues($button, XmNbackground, 'yellow');
}
# However, Motif is still cumbersome because there are lots of
# functions and resource names. The OO Widget interface improves this
# by providing fewer, more powerful functions and short alias names
# for common resources. In this example, by setting the text alias
# the widget's XmNlabelString and XmNlabelType attributes are both changed.
# The callback is also registered at widget creation time instead of in
# a separate command.
my $button = give $parent -button, -text => 'OK', -command => sub { exit };
...
if (query $button -managed) {
change $button -bg => 'yellow';
}
--
There are many nice things about the module, so I'm quite anxious to
get it released. I'm using it primarily as an embedded module so it has
decent support for hooking into an existing application interface. For
instance, we have hybrid C++/Motif + UIM/X + Perl/Motif applications
and they work very well.
> If it is...couldn't there be a perl plugin to netscape? client side
> scripting would be way cool...
Why does everything seem to revolve around the web now? Doesn't anybody
have anything better to do? ;) You can definitely create a Perl plug-in
for netscape. (Somebody probably already has.) That question has
nothing whatsoever to do with Motif or Tk though.
- Ken
--
Ken Fox (kfox@ford.com) | My opinions or statements do
| not represent those of, nor are
Ford Motor Company, Powertrain | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section | "Is this some sort of trick
| question or what?" -- Calvin
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 1343
**************************************