[21894] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4098 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 11 14:06:45 2002

Date: Mon, 11 Nov 2002 11:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 11 Nov 2002     Volume: 10 Number: 4098

Today's topics:
    Re: "Can't coerce array into hash" (theIrish1)
    Re: A vision for Parrot <donal.k.fellows@man.ac.uk>
    Re: A vision for Parrot <joe+usenet@sunstarsys.com>
    Re: A vision for Parrot <goldbb2@earthlink.net>
    Re: A vision for Parrot <dnew@san.rr.com>
    Re: change text colour? <andrew_harton@agilent.com>
    Re: change text colour? <spikey-wan@bigfoot.com>
    Re: change text colour? <tk@WINDOZEdigiserv.net>
    Re: change text colour? <andrew_harton@agilent.com>
        Changing color in a GIF image? (C Z)
    Re: Changing color in a GIF image? <addi@umich.edu>
    Re: fetch all the bouncing e-mailaddresses <nobody@dev.null>
    Re: fetch all the bouncing e-mailaddresses <nobull@mail.com>
    Re: How to call C routines from perl? (robertbu)
    Re: How to call C routines from perl? <goldbb2@earthlink.net>
        illegal use of comment ? (Tammy)
    Re: illegal use of comment ? <tk@WINDOZEdigiserv.net>
    Re: illegal use of comment ? (Villy Kruse)
    Re: illegal use of comment ? (Walter Roberson)
    Re: illegal use of comment ? <tk@WINDOZEdigiserv.net>
        ms word search regex <lance@augustmail.com>
    Re: Proper pipe handling <goldbb2@earthlink.net>
        regex for trimming leading or trailing tabs and spaces? <bob@bobber.com>
    Re: regex for trimming leading or trailing tabs and spa <nobull@mail.com>
    Re: Simple, almost stupid question! <goldbb2@earthlink.net>
    Re: Upgrade to Perl 5.6.x ? <tp601553@cia.gov>
        user interfaces (text) (john harrold)
    Re: user interfaces (text) <twhu@lucent.com>
    Re: Windows and nonblocking IO <goldbb2@earthlink.net>
    Re: Windows and nonblocking IO <troc@netrus.net>
        xml <esamson@web.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 11 Nov 2002 06:17:15 -0800
From: irish@babybrains.net (theIrish1)
Subject: Re: "Can't coerce array into hash"
Message-Id: <119f52ad.0211110617.502a3164@posting.google.com>

Joe Schaefer <joe+usenet@sunstarsys.com> wrote in message news:<m33cq8lm1d.fsf@mumonkan.sunstarsys.com>...
> irish@babybrains.net (theIrish1) writes:
> 
> > Can't coerce array into hash at dump.pl line 90.
> 
> [...]
> 
> > 80  my $ref = $orasql->fetchrow_hashref;
>                                   ^^^^
> 
> 
> > 81  my @columns = sort keys %$ref;
> 
> [...]
> 
> > 88  do {
> > 89  $counter++;
> > 90  $insert->execute(map {$ref->{$_}} @columns); 
>                        ^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> That's a hash slice:       @$ref{@columns}
> 
> > 91  } while ($ref = $orasql->fetchrow_arrayref);
>                                         ^^^^^
> 
> The first time through the do {...} block, $ref is
> a hashref.  The second time through, $ref is an arrayref.
> I'm pretty sure you want to use fetchrow_hashref here 
> instead.

Ok, my next question is... how did that happen, and how did I miss that?

(it was a long day)

Thanks

Irish


------------------------------

Date: Mon, 11 Nov 2002 15:26:54 +0000
From: "Donal K. Fellows" <donal.k.fellows@man.ac.uk>
Subject: Re: A vision for Parrot
Message-Id: <3DCFCC3E.204D9B45@man.ac.uk>

Daniel Pfeiffer wrote:
> this morning it struck me that it would be nice to have Parrot not only run
> Perl 6 and similar byte code, but that any of the common interpreted
> languages be compiled to this same byte code.
> 
> Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe even bash
> script the same interpreter library would be used.  Then likely it would
> already be in memory speeding up start time.

A common bytecode that Perl, Python, Ruby and Tcl would all compile to?  Hmm. 
Scary, and for several reasons.  Firstly, I'm not at all convinced that the
object models are compatible enough.  And secondly, how are you going to avoid
requiring a resident interpreter/compiler to handle the case where you've got
dynamic code coming from a source that doesn't generate parrot bytecodes
directly (e.g. a normal programmer^Wperson!)  After that, there's worrying about
security models to do as well.  ;^)

One way forward, at least with Tcl, would be to implement a Tcl interpreter in
terms of parrot bytecodes (rather like Jacl is a Tcl interp written in Java) but
that tends to bring out questions like "why bother?"  Could it be done without
requiring a chunky auxiliary C library to provide little things like
cross-platform select() support?  This sort of thing tends to make me suspicious
that this is little more than a pipe-dream, well, at least as far as Tcl's
concerned.  (I don't know the other languages nearly well enough to comment in a
useful way.)

Alternatively, formulate Parrot as a sort-of disjoint union of the bytecodes
used in each language, so unifying them without unifying anything.  >:^D

Donal.
-- 
Donal K. Fellows   http://www.cs.man.ac.uk/~fellowsd/   donal.fellows@man.ac.uk
-- OK, there is the MFC, but it only makes the chaos object orientated.
                                        -- Thomas Nellessen <nellessen@gmx.de>


------------------------------

Date: 11 Nov 2002 10:54:08 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A vision for Parrot
Message-Id: <m3u1ioje5b.fsf@mumonkan.sunstarsys.com>

"Donal K. Fellows" <donal.k.fellows@man.ac.uk> writes:

[Scary ... worrying ... security ... suspicious ... pipe-dream]

Brazil (1985).

-- 
Joe Schaefer     "The eternal mystery of the world is its comprehensibility."
                                               --Albert Einstein



------------------------------

Date: Mon, 11 Nov 2002 12:55:18 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: A vision for Parrot
Message-Id: <3DCFEF06.9E74A794@earthlink.net>

Donal K. Fellows wrote:
> 
> Daniel Pfeiffer wrote:
> > this morning it struck me that it would be nice to have Parrot not
> > only run Perl 6 and similar byte code, but that any of the common
> > interpreted languages be compiled to this same byte code.
> >
> > Then no matter whether running a Perl 6, Python, Ruby, Tcl maybe
> > even bash script the same interpreter library would be used.  Then
> > likely it would already be in memory speeding up start time.
> 
> A common bytecode that Perl, Python, Ruby and Tcl would all compile
> to?  Hmm. Scary, and for several reasons.  Firstly, I'm not at all
> convinced that the object models are compatible enough.

If you were writing a VM for one language, and then tried to extend it
for the others, then I would agree wholeheartedly.  However, it's no
more strange than using MSIL for C++ and VB and other languages.

> And secondly, how are you going to avoid requiring a resident
> interpreter/compiler to handle the case where you've got
> dynamic code coming from a source that doesn't generate parrot
> bytecodes directly (e.g. a normal programmer^Wperson!)

In all cases that I can think of, your dynamic code is essentially a
string which gets eval()ed (with a language-dependent eval).  The
solution is to make the eval() function/operator compile into a sequence
of operations along the lines of: Load the compiler for this language,
(if it's not already loaded), pass that string to the compiler, run the
generated bytecode.

> After that, there's worrying about security models to do as well.  ;^)
> 
> One way forward, at least with Tcl, would be to implement a Tcl
> interpreter in terms of parrot bytecodes (rather like Jacl is a Tcl
> interp written in Java)

Considering that Jcl and Jython exist, it seems like a reasonable goal
would be to make an interpreter which turns Java's .class files into
Parrot .pasm files.  Once that tool exists, one could simply translate
Jcl and Jython into parrot... there would be no need to re-implement
them.

And one day, in the distant future, there will be a Perl6 decompiler,
which will turn Parrot bytecode into Perl6.  Then we'll be able to
convert the translated Jython and Jcl into Perl6 :)

> but that tends to bring out questions like "why bother?"  Could it be
> done without requiring a chunky auxiliary C library to provide little
> things like cross-platform select() support?

No matter *what* language you're using, some sort of interface to select
or poll will be needed, and that interface would be implemented in C.

Whether it's "chunky" or not depends on how that interface appears on
the high-level end of things.

> This sort of thing tends to make me suspicious that this is little
> more than a pipe-dream, well, at least as far as Tcl's concerned.  (I
> don't know the other languages nearly well enough to comment in a
> useful way.)
> 
> Alternatively, formulate Parrot as a sort-of disjoint union of the
> bytecodes used in each language, so unifying them without unifying
> anything.  >:^D

The set of bytecodes which Parrot will be using has been decided, and
while it's not fixed in stone, it's quite unlikely to get a whole other
language's bytecodes added to it.

Assuming you thouroughly understand Tcl's bytecodes, why not take a look
at Parrot, and see whether the set of bytecodes that parrot supports is
sufficient to do everything that Tcl's bytecodes do?

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


------------------------------

Date: Mon, 11 Nov 2002 18:29:14 GMT
From: Darren New <dnew@san.rr.com>
Subject: Re: A vision for Parrot
Message-Id: <3DCFF6FB.40426F8E@san.rr.com>

Benjamin Goldberg wrote:
> In all cases that I can think of, your dynamic code is essentially a
> string which gets eval()ed (with a language-dependent eval).  The
> solution is to make the eval() function/operator compile into a sequence
> of operations along the lines of: Load the compiler for this language,
> (if it's not already loaded), pass that string to the compiler, run the
> generated bytecode.

Seems like an awful lot of overhead for every keystroke, window event,
and async file operation.


------------------------------

Date: Mon, 11 Nov 2002 15:13:56 -0000
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: change text colour?
Message-Id: <1037027449.569483@cswreg.cos.agilent.com>

Linux.ie wrote:
> is it possilbe to change the colour of the text in ms-dos to green ???

Okay, from some of the responses you've already got, it looks like
you could have phrased your question a little better.  If you want
your Perl script to output green text, you should look into using
the Win32::Console module.  Here's an example you can check out...

use Win32::Console;
my $CON = new Win32::Console(STD_OUTPUT_HANDLE);
my $attr = $CON->Attr();
$CON->Attr($::FG_GREEN);
$CON->Write("Hello World\n");
$CON->Attr($::FG_LIGHTGREEN);
$CON->Write("Hello World\n");
$CON->Attr($attr);



Andrew

--
$s="acehJklnoPrstu ";$_="4dbce078c32ae92a6e30152a";
split//;for(0..$#_){print substr($s,hex $_[$_],1);}




------------------------------

Date: Mon, 11 Nov 2002 16:11:57 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: change text colour?
Message-Id: <aqoktp$cil$1@newshost.mot.com>


"Andrew Harton" <andrew_harton@agilent.com> wrote in message
news:1037027449.569483@cswreg.cos.agilent.com...
> Linux.ie wrote:
> > is it possilbe to change the colour of the text in ms-dos to green ???
>
>
> use Win32::Console;
> my $CON = new Win32::Console(STD_OUTPUT_HANDLE);
> my $attr = $CON->Attr();
> $CON->Attr($::FG_GREEN);
> $CON->Write("Hello World\n");
> $CON->Attr($::FG_LIGHTGREEN);
> $CON->Write("Hello World\n");
> $CON->Attr($attr);


Alternatively try this:

system ("color 02");

This gives green text on a black background.

Type help color at the dos prompt, for further colour information.

R.






------------------------------

Date: Mon, 11 Nov 2002 16:43:45 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: change text colour?
Message-Id: <einvsu81lpcg7ssv3retpvrsc1avh61voi@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Mon, 11 Nov 2002 16:11:57 -0000, "Richard S
Beckett" <spikey-wan@bigfoot.com> managed to scribble:

| 
| "Andrew Harton" <andrew_harton@agilent.com> wrote in message
| news:1037027449.569483@cswreg.cos.agilent.com...
| > Linux.ie wrote:
| > > is it possilbe to change the colour of the text in ms-dos to
| > > green ??? 
| >
| >
| > use Win32::Console;
| > my $CON = new Win32::Console(STD_OUTPUT_HANDLE);
| > my $attr = $CON->Attr();
| > $CON->Attr($::FG_GREEN);
| > $CON->Write("Hello World\n");
| > $CON->Attr($::FG_LIGHTGREEN);
| > $CON->Write("Hello World\n");
| > $CON->Attr($attr);
| 
| 
| Alternatively try this:
| 
| system ("color 02");
| 
| This gives green text on a black background.
| 
| Type help color at the dos prompt, for further colour information.
| 

system() should be used as little as possible; surely the 8 lines above
aren't too much?


  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc/egCjNZg8h4REKEQLKcwCeKZXJL2oTioxAgCHGkLdiu1g7h1MAniiE
jnkAE0RDzdnAnKChFwgw0C2N
=D3Oc
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


------------------------------

Date: Mon, 11 Nov 2002 17:51:27 -0000
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: change text colour?
Message-Id: <1037036899.251379@cswreg.cos.agilent.com>

tk wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on Mon, 11 Nov 2002 16:11:57 -0000, "Richard S
> Beckett" <spikey-wan@bigfoot.com> managed to scribble:
>
[snip]
>>
>> Alternatively try this:
>>
>> system ("color 02");
>>
>> This gives green text on a black background.
>>
>> Type help color at the dos prompt, for further colour information.
>>
>
> system() should be used as little as possible; surely the 8 lines
> above aren't too much?
>

 ..especially since system("color 02") may not work, depending on
which version of dos / windows is being used, and only changes the
text colour for the entire screen, whereas using the Win32::Console
module would allow attributes to be set for individual regions (as
in my example).

Andrew

--
$s="acehJklnoPrstu ";$_="4dbce078c32ae92a6e30152a";
split//;for(0..$#_){print substr($s,hex $_[$_],1);}




------------------------------

Date: 11 Nov 2002 09:26:01 -0800
From: caryz@hotmail.com (C Z)
Subject: Changing color in a GIF image?
Message-Id: <9d6eae4c.0211110926.73bd9f56@posting.google.com>

All, I am trying to change one color in a gif image to another (say
change all red spots to blue spots) (output preferrably in GD format
so I can do more stuff). Searched CPAN and internet, not very lucky. I
am wondering if any one of you could give me some directions?
Thanks,

CZ


------------------------------

Date: 11 Nov 2002 13:10:26 -0500
From: Arnar Mar Hrafnkelsson <addi@umich.edu>
Subject: Re: Changing color in a GIF image?
Message-Id: <xfsvznsgm0z1.fsf@blue.engin.umich.edu>

caryz@hotmail.com (C Z) writes:

> All, I am trying to change one color in a gif image to another (say
> change all red spots to blue spots) (output preferrably in GD format
> so I can do more stuff). Searched CPAN and internet, not very lucky. I
> am wondering if any one of you could give me some directions?
> Thanks,
> 
> CZ

Imager.pm can do general color conversions:

http://www.eecs.umich.edu/~addi/perl/Imager/

It's very likely that Image::Magick has ways to do this also.  Less likely
but still possible that GD.pm can do this.

-- Arnar.


------------------------------

Date: Mon, 11 Nov 2002 15:29:32 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: fetch all the bouncing e-mailaddresses
Message-Id: <3DCFCCAD.60703@dev.null>



Leif Wessman wrote:

>[...] I want to go thru all the bounce-mails and fetch all occurrences
> of e-mailadresses like this:
> 
> open IN, "<$ARGV[0]" or die "open: $!";
> while ($line = <IN>) {
> 	if ($line =~ /^[a-zA-Z0-9\-\._]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)
> {
> 	print $1;
> 	}
> }
> close IN;
> 
> But the problem is that $1 does not contain anything at any point. How
> should I write to fetch out the addresses??


$1 will contain whatever the sub-regex within the first pair of 
parantheses matches. Your first pair of parentheses contains

\[?

meaning that you are asking your computer to print a left square bracket 
if it happens to occur after the @ character in the e-mails. Sure 
enough, when I tested your script against

elvis@[presley.com

it dutifully printed
[

Your list probably doesn't contain any addresses with [ as the first 
character of the domain name; that's why you don't get any output.



------------------------------

Date: 11 Nov 2002 18:30:38 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: fetch all the bouncing e-mailaddresses
Message-Id: <u98z002c35.fsf@wcl-l.bham.ac.uk>

leifwessman@hotmail.com (Leif Wessman) writes:

> I have a file full of e-mailaddresses that bounced when we sent out
> our latest newsletter.

> Now I want to go thru all the bounce-mails and fetch all occurrences
> of e-mailadresses like this:

Other people have addresses your Perl question but I'm reluctant to
let this pass without pointing out the falicy in your approach (even
though this is off topic).

Mail bounces do not always contain the original address that you sent
out because the mail may have passed through one or more forwarding
accounts before it bounces.

Modern list management s/w encodes the recipient into return path so
that bounces are easily identifyable.

For any mailing list big enough to warrant any form of automation I
strongly recommend using standard list management software rather than
rolling your own.


------------------------------

Date: 11 Nov 2002 06:58:36 -0800
From: robertbu@hotmail.com (robertbu)
Subject: Re: How to call C routines from perl?
Message-Id: <8c7725ac.0211110658.56579232@posting.google.com>

> I'm looking for informaton on how to call C routines from Perl.

I am in the midst of exploring both embedding and extending perl with 
C myself.

> The routines are in the a lib file, but I do have the source.
> Is this a common/easy thing to do?

To extend perl there are three ways I know of, and a possible forth.
Inline.pm - see http://www.perl.com/pub/a/2001/02/inline.html
XS        - start with perldoc perlxstut
SWIG      - A more script language independent solution, but
apparently
            not used much in practice.
DLL       - I believe it is possible to create some perl wrapper subs
and
            hand pack/unpack the parameters to the routines.  I
believe that
            is how Win32 routines are supported.

I've only experimented with XS.  It is very easy to follow the
perlxstut document and get samples up and running.  It is also easy to
make modifications and have the build process break.  And therefore I
have
a stack of to-be-read stuff before I go back to XS again (so the
process
is more than a magic incantation). 
 
> That might make things harder, but I really don't know much about the
> windows part of it. Maybe someone with Activestate on Win experience
> can jump in here.

I am building on XP with VS 7.0.  In order to build I had to 
add perl\lib\core to the include path.  I also had to comment
out the line #define·USE_ITHREADS in config.h in the core 
directory.  Everything seems to work, but I have no idea what
effect changing this #define has.
 
> 
> You could also embed a perl interpreter in a C application, in that
> case (see the perlembed documentation). 

Simple cases of embedding worked just fine following 
perldoc perlembed.  There are a variety of ways of interacting 
with the interpreter, and I've only explored a couple.  You will
need to link with perl56.lib from the core directory.
 
Advanced Perl Programming also has a couple of chapters on embedding
and extending Perl.  For embedding, I found a couple of function calls
names were wrong (or perhaps they were right when the book was written
and have since been change), and had to go exploring in perl.h to
find the right names.

== Rob ==


------------------------------

Date: Mon, 11 Nov 2002 13:20:50 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How to call C routines from perl?
Message-Id: <3DCFF502.A760DCFA@earthlink.net>

Martien Verbruggen wrote:
> 
> On Mon, 11 Nov 2002 14:06:19 +1300,
>         Jim Williams <not.me@nowhere.com> wrote:
> > **** Post for FREE via your newsreader at post.usenet.com ****
> >
> > I'm looking for informaton on how to call C routines from Perl.
> > Is this possible?
> 
> Yes.
> 
> > The routines are in the a lib file, but I do have the source.
> > Is this a common/easy thing to do?
> 
> Yes, very common. It could be easy, depending on your requirements,
> and which of the possible paths you decide to follow.
> 
> > Do you have to recompile Perl?
> 
> No, as long as you can make your library available as some sort of
> shared object file (DLL on windows), or you can compile the whole of
> it as a Perl module.
> 
> > I'm using activestate perl on Windows XP.
> 
> That might make things harder, but I really don't know much about the
> windows part of it. Maybe someone with Activestate on Win experience
> can jump in here.

If Win32::API works on Windows XP, then being on XP should be no
significant bar to calling your C functions from Perl.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


------------------------------

Date: 11 Nov 2002 09:07:33 -0800
From: MsMillerMCP@aol.com (Tammy)
Subject: illegal use of comment ?
Message-Id: <7f01d63c.0211110907.5794b89@posting.google.com>

Is the following legal in perl?

#$feedback_recipient = "michael";

I know the # pound is the comment denotation, but I wasn't sure about
there being a space in between and or  the dollar sign being a
problem?

Thanks!


------------------------------

Date: Mon, 11 Nov 2002 17:10:20 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: illegal use of comment ?
Message-Id: <94pvsusihmqp9nsdlemvqj3mtonlvnq734@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on 11 Nov 2002 09:07:33 -0800,
MsMillerMCP@aol.com (Tammy) managed to scribble:

| Is the following legal in perl?
| 
| #$feedback_recipient = "michael";
| 
| I know the # pound is the comment denotation, but I wasn't sure about
| there being a space in between and or  the dollar sign being a
| problem?
| 
| Thanks!

# (being a hash, not £ pound) should work without spaces.


Regards,

  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc/kuCjNZg8h4REKEQJjnACg+s+YST7BOGjL4Oa4axCjOGr84skAoMZ7
i/NAmPQGvHpNQv1rvipJq611
=A9ZH
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


------------------------------

Date: 11 Nov 2002 18:02:50 GMT
From: vek@station02.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: illegal use of comment ?
Message-Id: <slrnasvs69.mu9.vek@station02.ohout.pharmapartners.nl>

On Mon, 11 Nov 2002 17:10:20 GMT,
    tk <tk@WINDOZEdigiserv.net> wrote:


>
># (being a hash, not £ pound) should work without spaces.
>
>


That us a US thing.  # is the pound sigh over there, that is, not
pound sterling but the unit of weight.


Villy


------------------------------

Date: 11 Nov 2002 18:26:07 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: illegal use of comment ?
Message-Id: <aqosnv$oo7$1@canopus.cc.umanitoba.ca>

In article <slrnasvs69.mu9.vek@station02.ohout.pharmapartners.nl>,
Villy Kruse <nobody> wrote:
:On Mon, 11 Nov 2002 17:10:20 GMT,
:    tk <tk@WINDOZEdigiserv.net> wrote:

:># (being a hash, not £ pound) should work without spaces.

:That us a US thing.  # is the pound sigh over there, that is, not
:pound sterling but the unit of weight.

In the US and Canada, the usual symbol for pounds weight is  lbs
I very rarely see  #  used for weight in Canada -- I can't remember
the last time.

I saw  #  for weight several times in England when I was last there
a short number of years ago.

Here in Canada, '#' would usually be called "number sign" or "sharp sign"
(as in music.)


Here's a bit of trivia: the official name of the character '#' is
'octathorpe'. It's an invented name from the last part of the 20th
century: apparently although the symbol existed long before, it didn't
have a name before that.
--
Inevitably, someone will flame me about this .signature.


------------------------------

Date: Mon, 11 Nov 2002 18:26:12 GMT
From: tk <tk@WINDOZEdigiserv.net>
Subject: Re: illegal use of comment ?
Message-Id: <qhtvsu0qccls321la25fdhlup9vicfoelo@4ax.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on 11 Nov 2002 18:02:50 GMT,
vek@station02.ohout.pharmapartners.nl (Villy Kruse) managed to
scribble:

| On Mon, 11 Nov 2002 17:10:20 GMT,
|     tk <tk@WINDOZEdigiserv.net> wrote:
| 
| 
| >
| ># (being a hash, not £ pound) should work without spaces.
| >
| >
| 
| 
| That us a US thing.  # is the pound sigh over there, that is, not
| pound sterling but the unit of weight.
| 
| 
| Villy

Ooo, thank for clearing that up Villy.

We (in the UK) use 'lb' for pounds in weight.. hence my confusion =)


Regards,

  tk

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPc/2gijNZg8h4REKEQI1mgCfYi9d6ni4IlPrDeUKhJ98Gg7+dnoAoMzP
T/yV0YMGjSl6qrWG6VM8wOKF
=p8qf
-----END PGP SIGNATURE-----

--
+--------------------------+
|     digiServ Network     |
|      Web solutions       |
| http://www.digiserv.net/ |
+--------------------------+

  Remove WINDOZE to reply


------------------------------

Date: Mon, 11 Nov 2002 09:54:29 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: ms word search regex
Message-Id: <pan.2002.11.11.15.54.29.122210.22318@augustmail.com>

I am trying to pull some numbers from a ms word doc.
Currently, I am using Win32::OLE to open the word doc
then search the doc.

The problem I am having is that I am not able to 
get the contents of test.doc into $file so that I
can search $file.

What step am I missing?


my $Word = Win32::OLE->GetActiveObject('Word.Application')
  || Win32::OLE->new('Word.Application', 'Quit');
$Word->{'Visible'} = 1;
$Word->Documents->Add || die("Unable to create document ", 
   Win32::OLE->LastError());
my $MyRange = $Word->ActiveDocument->Content;
my $Document = $Word->Documents->Open({FileName=>"p:\\docs\\perl\\test.doc"});

{local $/=undef;my $file=$Document}

my $file =~ /TABLE\s*167.*?MALE.*?(?:(\d\d\.\d)\D+){3}/s;
my $num1 = $1;
print "\n\n  $num1 \n\n";




------------------------------

Date: Mon, 11 Nov 2002 12:59:50 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Proper pipe handling
Message-Id: <3DCFF016.4D3C4F93@earthlink.net>

Starling wrote:
> 
> If someone could help me with this I'd really appreciate it.  I'm
> trying to learn how to work with pipes and forks in perl, and have
> been getting intermittent errors.  When I run the following program
> without the debug flag, it works (so far...).  When I run it with the
> -d flag, it doesn't work, usually, but sometimes manages to spit out
> the data before silently exiting.  I know I must be doing something
> wrong, but am not sure where my logic falls short of the truth.

What precisely do you want your program to do, anyway?

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


------------------------------

Date: Mon, 11 Nov 2002 17:50:12 GMT
From: Bob <bob@bobber.com>
Subject: regex for trimming leading or trailing tabs and spaces?
Message-Id: <3DCFEDD3.2090909@bobber.com>

Hi I have a line like this:

Entry 1<>Text 45<>aa/gg[t]/gg<>%89

Where <> is a tab or a combination of spaces and tabs.  So I could have 
only a \t, or \s\t\t, etc.  The only rule seems to be that there is 
always at least one tab separating columns, and there are no tabs in the 
fields.

I need to split this line into an array, such that:
$array[0] = "Entry 1";
$array[1] = "Text 45";
$array[2] = "aa/gg[t]/gg";
$array[3] = "%89";

I had originally written a regex like this:
$_ =~ /^([^\t])+\t([^\t]+)\t([^\t]+)\t([^\t]+).*$/;

and then did @array = ( $1, $2, $3, $4 ), but this is not a good enough 
regex because I was assuming that the file format would not change ( 
yup, big mistake ) and it has suddenly stopped working because the 
number of tabs changed in between one of the columns... something that 
will happen again.

What is the proper regex to match this stuff and stuff it in an array 
that is more robust?

Thanks!
B



------------------------------

Date: 11 Nov 2002 18:11:12 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: regex for trimming leading or trailing tabs and spaces?
Message-Id: <u9d6pc2czj.fsf@wcl-l.bham.ac.uk>

Bob <bob@bobber.com> writes:
> Subject: regex for trimming leading or trailing tabs and spaces?

This appears to be FAQ: "How do I strip blank space from the
beginning/end of a string?"

> Hi I have a line like this:
> 
> Entry 1<>Text 45<>aa/gg[t]/gg<>%89
> 
> Where <> is a tab or a combination of spaces and tabs.  So I could
> have only a \t, or \s\t\t, etc.  The only rule seems to be that there
> is always at least one tab separating columns, and there are no tabs
> in the fields.

Are you sure - knowing what you want to do is a very important step in
working out how to do it.

> I need to split this line into an array, such that:
> $array[0] = "Entry 1";
> $array[1] = "Text 45";
> $array[2] = "aa/gg[t]/gg";
> $array[3] = "%89";

Sounds like you are saying you want to split on /\s*\t\s*/

my @array = split /\s*\t\s*/;

> I had originally written a regex like this:
> $_ =~ /^([^\t])+\t([^\t]+)\t([^\t]+)\t([^\t]+).*$/;
>
> and then did @array = ( $1, $2, $3, $4 ),

Appart from m// bing the wrong tool for the job there are many things
wrong with that!

The whole point of =~ is to tell Perl "don't use $_ use something else
instead".

Don't use // in a void context then say ($1, $2, $3, $4)... just use //
in an array context.

Look at where you are closing the first capture.  $1 will capture only
the last character before the first tab.

> What is the proper regex to match this stuff and stuff it in an array
> that is more robust?

If you really insist on using a screwdriver to drive nails here's how
to simulate split() using m//...

@array = /^(.+?)\s*\t\s*(.+?)\s*\t\s*(.+?)\s*\t\s*(.+)/;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Mon, 11 Nov 2002 14:11:24 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Simple, almost stupid question!
Message-Id: <3DD000DC.430BD712@earthlink.net>

F. Xavier Noria wrote:
> 
> In article <aqjk7j$ant$1@news.ya.com>, F. Xavier Noria wrote:
> 
> >    cat foo.pairs | while read old new; do
> >    perl -pi -e "s/$old/$new/g" foo.txt; done
> 
> Sorry, I forgot to escape the variables for perl there:
> 
>     cat foo.pairs | while read old new; do
>     perl -pi -e "s/\\Q$old\\E/quotemeta($new)/ge" foo.txt; done

You can avoid writing out quotemeta, and avoid the /e, by doing:

      cat foo.pairs | while read old new; do
      perl -pi -e "s/\\Q$old\\E/\\Q$new\\E/g" foo.txt; done

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


------------------------------

Date: Mon, 11 Nov 2002 15:50:37 GMT
From: Tweetie Pooh <tp601553@cia.gov>
Subject: Re: Upgrade to Perl 5.6.x ?
Message-Id: <Xns92C3A12C39E86TweetiePooh@62.253.162.105>

"Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk> honoured 
comp.lang.perl.misc on Mon 11 Nov 2002 11:32:49a with 
news:aqo4ei$r34$1$8302bc10@news.demon.co.uk:

> Derek,
> 
> "Derek Thomson" <derek@wedgetail.com> wrote in message
> news:3DCF4709.2010203@wedgetail.com...
>> You learn a new thing every day. And it's another way to make people
>> *finally* trade up to 5.6 :)
> 
> Where can I find the most compelling statement of why my project's
> Development Manager should give the green light for an upgrade from Perl
> 5.00404 (!!) to 5.6 (on Solaris 2.6)?
> 
> And which 5.6.x is the most stable for reassuring frightened "suits" ?
> 
> Thanks,
> Clyde
> 
> 
> 

I have used 5.6.0, 5.6.1 and 5.8 on Solaris (5.5 - 5.8) without problem.  Now 
this won't satisfy the suits.

What you can do is to install 5.6+ in /usr/local since the standard Sun perl 
is elsewhere.  Now add the modules you need into both perl's.  If some mods 
need the later version the problem is solved.

Now run the program.  If it works in the old version but not the new since it 
uses an old feature then you may have problems stepping up.  If it works in 
the new not the old you now have your arguement.  If it works in both why do 
you need to update?

In any case you can still put the new perl in a different location and start 
new projects in the newer perl and leave the old stuff where it is.


------------------------------

Date: 11 Nov 2002 06:14:58 -0800
From: jmh17@pitt.edu (john harrold)
Subject: user interfaces (text)
Message-Id: <31d0e2b6.0211110614.20ec6766@posting.google.com>

hey.

i've got a database app that i wrote as a cgi application. when i was
writing it, i put all of the mechanics into perl modules-effectively
separating the userinterface and the actual actions being preformed.
now i want to write a consol user interface to the application. i have
a few questions:

o is it possible to use some set of libraries that 
  will allow me to abstract out the menuing to make 
  a gui implementation easier in the future?
o can someone suggest a good book or another source
  convering the creation of text based user 
  interfaces?

thanks.


------------------------------

Date: Mon, 11 Nov 2002 13:02:50 -0500
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: user interfaces (text)
Message-Id: <aqorct$6pr@netnews.proxy.lucent.com>

"john harrold" <jmh17@pitt.edu> wrote in ...
> hey.
>
> i've got a database app that i wrote as a cgi application. when i was
> writing it, i put all of the mechanics into perl modules-effectively
> separating the userinterface and the actual actions being preformed.
> now i want to write a consol user interface to the application. i have
> a few questions:
>
> o is it possible to use some set of libraries that
>   will allow me to abstract out the menuing to make
>   a gui implementation easier in the future?

use Tk;
download Tk from cpan

> o can someone suggest a good book or another source
>   convering the creation of text based user
>   interfaces?

http://www.perltk.org/contrib/perltk-01/index.htm
Mastering Perl/Tk by Steve Lidie & Nancy Walsh




------------------------------

Date: Mon, 11 Nov 2002 13:23:46 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Windows and nonblocking IO
Message-Id: <3DCFF5B2.DE2B0B1F@earthlink.net>

edgue@web.de wrote:
> 
> Hi there,
> 
> what I read from past postings is that
> there is no way to fork() with ActiveState
> and later do non-blocking communication between
> parent and child process.
> 
> Is that still true - or has that changed with
> the perl 5.8 beta that is available from
> ActiveState?

It's never been true -- as long as you didn't try and use pipes for that
communication.  For example, you could create a socket for the purpose.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


------------------------------

Date: Mon, 11 Nov 2002 18:44:43 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: Windows and nonblocking IO
Message-Id: <slrnasvug0.8ma.troc@eyrie.homenet>

On Mon, 11 Nov 2002 13:47:38 +0100, edgue@web.de wrote:
> what I read from past postings is that
> there is no way to fork() with ActiveState
> and later do non-blocking communication between
> parent and child process.

IPC::Run is supposed to support it.  You may want to look at how it's
done there.

-- Rocco Caputo - troc@pobox.com - http://poe.perl.org/


------------------------------

Date: Mon, 11 Nov 2002 18:47:34 +0100
From: "Elvis" <esamson@web.de>
Subject: xml
Message-Id: <aqoqi2$v8r$00$1@news.t-online.com>

hi I'm looking for some hints how to convert a xml file (without dtd) =
into a textfile

e.g.

house
  room: living;
  room: kitchen;
  price: 100000
  street: kingstr
house
  room: living;
  room: living;
  room: bath;
  price: 90000
  street: hiltonstr

that converting to

type;room1;room2;room3;price;street;
house;living;litchen; ;100000;kingstr;
house;living;living;bath;90000;hiltonstr;

Thanks for your help in advance,
Elvis


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4098
***************************************


home help back first fref pref prev next nref lref last post