[16326] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3738 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 18:10:38 2000

Date: Tue, 18 Jul 2000 15:10:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963958221-v9-i3738@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 18 Jul 2000     Volume: 9 Number: 3738

Today's topics:
        JOB Offered <bbkling@earthlink.net>
        Making a Perl module <samara_biz@hotmail.com>
        Making a Perl module? <samara_biz@hotmail.com>
        Modify every file in a directory tony121076@my-deja.com
        Non-printed characters <gte097p@prism.gatech.edu>
    Re: Numerical evaluation in string <lauren_smith13@hotmail.com>
        Open Off-Server-File <phoe6us@my-deja.com>
    Re: Open Off-Server-File <tony_curtis32@yahoo.com>
    Re: Open Off-Server-File <lauren_smith13@hotmail.com>
    Re: Open Off-Server-File <phoe6us@my-deja.com>
    Re: Passing and using multidimensional array references bchodo@my-deja.com
        Passing command line regexp into perl program  <donald.l.mccorvey@boeing.com>
        pattern matching <xlhuang@mtu.edu>
    Re: pattern matching (Andrew J. Perrin)
        perl code help cheych@my-deja.com
    Re: perl code help (Clinton A. Pierce)
    Re: perl code help <lauren_smith13@hotmail.com>
        Perl job offered San Mateo Perm zack3011@my-deja.com
    Re: Perl job offered San Mateo Perm <care227@attglobal.net>
    Re: Perl job offered San Mateo Perm (Eric Bohlman)
        POE 0.11: event driven state machines, also supports Pe (Rocco Caputo)
        Problem with bitwise unpack <craig.arnold@boeing.com>
        re problem (Hugh Lawson)
    Re: re problem (Andrew J. Perrin)
    Re: re problem (Clinton A. Pierce)
    Re: re problem (Abigail)
    Re: re problem (Craig Berry)
    Re: re problem (Hugh Lawson)
        Splitting on a number: help please <rosie@dozyrosy.plus.com>
    Re: Splitting on a number: help please <sariq@texas.net>
    Re: Splitting on a number: help please <christian@fabel.dk>
    Re: Splitting on a number: help please (Clinton A. Pierce)
    Re: Splitting on a number: help please (Craig Berry)
    Re: Suggestion for syntax change <sumus@aut.dk>
    Re: watch out for the mod operator! <stephenk@cc.gatech.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 18 Jul 2000 18:50:38 GMT
From: Bob Kling <bbkling@earthlink.net>
Subject: JOB Offered
Message-Id: <3974A6AA.CC7B0767@earthlink.net>

Programmer - WORK AT HOME -Full Time
Ideal person would be strong in Perl, with some Java, and some SQL.
Server admin skills a big plus; Unix and some NT
-------
Also it would be a super help if anyone reading this could tell me if
there is a job posting service that has a "work at home" or
"tele-commuting " job section? The big job sites do not have this
category. Thank you very
much.

Bob
bob@tokensystems.com



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

Date: Tue, 18 Jul 2000 14:08:06 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Making a Perl module
Message-Id: <39749D05.35D6FDE4@hotmail.com>

Hi,

I'm having troubles getting a function in a module work. I've read
perldocs, but it didn't help me. I thought I did everything what perldoc
tells to do to make a module. Here's my code:

I have my PerlScript:

<%
use strict;
use vars qw( $Response );

use lib "C:/InetPub/wwwroot";

use Example1;

my $string = output("Hello from simple script!");

$Response->Write($string);
%>

and I have my module file:

package example1;

use strict;
use warnings;


BEGIN {
 use Exporter ();
 my ($VERSION, @ISA, @EXPORT);

 $VERSION = 1.00;
 @ISA = qw(Exporter);
 @EXPORT = qw( &output );
}

sub output{

 my $to_print = shift;


 return $to_print;
}


END { }

1;

When I run the PerlScript I get this error:

#my $string = %Example1::output("Hello from simple script!"); my $string
= output("Hello from simple script!"); error '80004005'

Undefined subroutine &main::output called.

/example1.asp, line 12

Could you possibly point to me if I have an error somewhere in my code?
I've been trying to get it to work for a few hours already with no
success :(

Thanks!!!

Alex



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

Date: Tue, 18 Jul 2000 14:11:18 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Making a Perl module?
Message-Id: <39749DC6.A8243F63@hotmail.com>

Hi,

I'm having troubles getting a function in a module work. I've read
perldocs, but it didn't help me. I thought I did everything what perldoc

tells to do to make a module. Here's my code:

I have my PerlScript:

<%
use strict;
use vars qw( $Response );

use lib "C:/InetPub/wwwroot";

use Example1;

my $string = output("Hello from simple script!");

$Response->Write($string);
%>

and I have my module file:

package example1;

use strict;
use warnings;


BEGIN {
 use Exporter ();
 my ($VERSION, @ISA, @EXPORT);

 $VERSION = 1.00;
 @ISA = qw(Exporter);
 @EXPORT = qw( &output );
}

sub output{

 my $to_print = shift;


 return $to_print;
}


END { }

1;

When I run the PerlScript I get this error:

#my $string = %Example1::output("Hello from simple script!"); my $string

= output("Hello from simple script!"); error '80004005'

Undefined subroutine &main::output called.

/example1.asp, line 12

Could you possibly point to me if I have an error somewhere in my code?
I've been trying to get it to work for a few hours already with no
success :(

Thanks!!!

Alex



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

Date: Tue, 18 Jul 2000 20:31:02 GMT
From: tony121076@my-deja.com
Subject: Modify every file in a directory
Message-Id: <8l2eq6$a26$1@nnrp1.deja.com>

I have 30 to 50 text files in a directory. They are all formated the
same (a simple database). I need to change the 6th column of every entry
in every file of the directory. How should I go about this? Thank you
for your time and attention.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Jul 2000 20:41:23 GMT
From: Kevin Hannbih Wong <gte097p@prism.gatech.edu>
Subject: Non-printed characters
Message-Id: <8l2fdj$2rv$1@news-int.gatech.edu>

I'm writing a simple script that simply prompts the user for his/her and
phone number and stores it into a file. The thing is when the user hits
the backspace key it will go back and let you type over the character, but
when you go back and examine the output file you will see all those
backspace characters entered. 
Is there anyway I can get around this?

-- 
Kevin Wong
gte097p@prism.gatech.edu
khwong@cc.gatech.edu


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

Date: Tue, 18 Jul 2000 11:25:02 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Numerical evaluation in string
Message-Id: <8l27bs$sb1$1@brokaw.wa.com>


Vinod K. Menon <anuragmenon@my-deja.com> wrote in message
news:8l25kp$2gp$1@nnrp1.deja.com...
>
> for example (I know the format is not right..just giving the idea!)
>
> if I wanna do something like string = " 1/($keyVal/$len -1)) is the
> answer"
>
> I want it to evaluate to something like
> and print
>
> 0.33 is the answer

Why not calculate the value before putting it in the string?

$answer = 1/($keyVal/$len -1);
$string = "$answer is the answer";

Programming Perl isn't a competition to cram everything into one line.

Lauren
--
Yes, I know there are Perl competitions to cram everything into one line.





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

Date: Tue, 18 Jul 2000 18:02:14 GMT
From: Phoebus <phoe6us@my-deja.com>
Subject: Open Off-Server-File
Message-Id: <8l262n$2un$1@nnrp1.deja.com>

this seems like sort of a stupid question, but opening local files is a
snap, but when i have tried to open a file off a different server, it
defaulted to my error subroutine

open(IN, "http://some.server.com/file") or die("can't open file");

is this something that is possible or do i need some dealing with
syntax, i know i can reach the file because i can get there with my
browser.  i am running activesite perl on a win 95 comp using the
windows version of apache.

PS sorry for double posting in the de.comp.lang.perl.cgi forum, i
didn't realize till after that this was the english one...


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Jul 2000 13:16:02 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Open Off-Server-File
Message-Id: <871z0rgv8d.fsf@limey.hpcc.uh.edu>

>> On Tue, 18 Jul 2000 18:02:14 GMT,
>> Phoebus <phoe6us@my-deja.com> said:

> this seems like sort of a stupid question, but opening
> local files is a snap, but when i have tried to open a
> file off a different server, it defaulted to my error
> subroutine

> open(IN, "http://some.server.com/file") or die("can't
> open file");

What you're trying to open here is not a file.  It's a
remote resource on another server.  You don't know whether
its underlying representation is a file or not.

Perl separates local and remote resources.  So this means
you need a different method of getting data remotely, in
this case with HTTP:

    perldoc LWP

has the overview, and

    perldoc lwpcook

has some examples of retrieving data over the web.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Tue, 18 Jul 2000 11:26:33 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Open Off-Server-File
Message-Id: <8l27ep$sfj$1@brokaw.wa.com>


Phoebus <phoe6us@my-deja.com> wrote in message
news:8l262n$2un$1@nnrp1.deja.com...
> this seems like sort of a stupid question, but opening local files is a
> snap, but when i have tried to open a file off a different server, it
> defaulted to my error subroutine
>
> open(IN, "http://some.server.com/file") or die("can't open file");
>
> is this something that is possible or do i need some dealing with
> syntax, i know i can reach the file because i can get there with my
> browser.  i am running activesite perl on a win 95 comp using the
> windows version of apache.

This would definitely be a great way to open remote files, if only it
worked.  Try the LWP module instead.

perldoc LWP

Lauren





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

Date: Tue, 18 Jul 2000 19:35:17 GMT
From: Phoebus <phoe6us@my-deja.com>
Subject: Re: Open Off-Server-File
Message-Id: <8l2bhk$79r$1@nnrp1.deja.com>

wow thanx for getting back to me so soon, you would think perl/cgi
would have an easier way to do this...it seems i have to install the
whole lwp module (and its related stuff) just to get one silly
function, but thank you so much for the quick and direct answers.

andrew


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 20:49:51 GMT
From: bchodo@my-deja.com
Subject: Re: Passing and using multidimensional array references
Message-Id: <8l2ft8$av1$1@nnrp1.deja.com>

I think I understand now about the reference. The value passed to the
function is just a reference(location) of the array. I have
to "dereference" it to use it as an array (no strict "refs").

OK. But the next step is this: the function I pass it to is recursive.
I understand how to send it to the function the first time. But how
would the function send the arrayref to itself the Nth time? I thought
that because it was just a reference, I could just pass it as a
variable (i.e. fname($arrayref)), but I get a "reference is not an
array ref" message. How does a function pass an array reference it
received to itself to be used in the same way without counting the
depth of the call tree?

In article <3bRRVR$TPY@openbazaar.net>,
  elephant@squirrelgroup.com.bbs@openbazaar.net (jason) wrote:
> bchodo@my-deja.com wrote ..
> >I have a large array that I want to pass to a subroutine. I passed
the
> >reference (\@array) to keep from having to pass the array, but now
I'm
> >having trouble accessing individual elements in the file (i.e.)
> >I thought that I could do:
> >.
> >.
> >.
> >prog(\@array);
>
> here you pass a reference to an array .. a scalar
>
> >sub prog {
> >my @array = shift;
>
> here you assign a scalar to an array which will have the effect of
> setting the first element of your array to that scalar .. ie. the
array
> reference from outside will be in $array[0]
>
> you need to realise that an array reference is a scalar .. it is store
> in a scalar variable .. take a look at
>
>   perldoc perlref
>
> --
>   jason -- elephant@squirrelgroup.com --
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 21:12:47 GMT
From: Don McCorvey <donald.l.mccorvey@boeing.com>
Subject: Passing command line regexp into perl program 
Message-Id: <3974C84F.9F0B1EF3@boeing.com>

I'm tweaking a program which reads in two fields out of a text file,
pattern matches on one field, and prints out any records which match.
One version of the program works but matches against the entire printed
record which I run through perl's grep function to select out the
matching ones.

The version which doesn't work attempts to look at the fields as the
text file is read in and matches it:

        if (field2 =~ eval($regexp) {

            print field1, "\t", field2, "\n";

        }

Where $regexp is a parameter provided in quotes on the command line.
($regexp = $ARGV[0])

Whenever I run this particular variation of the program, it returns ALL
of the records in the file, even when the other version, using the
identical regexp returns the correct result - but cannot be used with a
"^" pattern match operator since field1 is already prepended to each
record in the array.

Can someone please explain what I'm doing wrong ?

Thanks,

Don McCorvey
Houston, Tx



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

Date: Tue, 18 Jul 2000 15:02:51 -0400
From: Xiang Long Huang <xlhuang@mtu.edu>
Subject: pattern matching
Message-Id: <3974A9DB.C3A4FDFF@mtu.edu>

Hi everyone,

I want to match a pattern with a new line inside the pattern, like
following:

"... funcA
Trying... "

When I use the following statement to match, it doesn't work.

    open INPUT, filename;
    $temp1 = <INPUT>;
    if ($temp1=~m/funcA\nTrying/)
      {
        print STDOUT "find a newline \n";
      }

Anybody knows why? Thanks.


--
Long





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

Date: 18 Jul 2000 15:13:21 -0400
From: aperrin@socrates.berkeley.edu (Andrew J. Perrin)
Subject: Re: pattern matching
Message-Id: <u3dl745gu.fsf@socrates.berkeley.edu>

Xiang Long Huang <xlhuang@mtu.edu> writes:

> Hi everyone,
> 
> I want to match a pattern with a new line inside the pattern, like
> following:
> 
> "... funcA
> Trying... "
> 
> When I use the following statement to match, it doesn't work.
> 
>     open INPUT, filename;
>     $temp1 = <INPUT>;
>     if ($temp1=~m/funcA\nTrying/)
>       {
>         print STDOUT "find a newline \n";
>       }
> 
> Anybody knows why? Thanks.

Sure - because when you assign <INPUT> to a scalar variable, it reads
only a single line of the file into the variable.  Unless you've
changed $/ you're only getting up to the first newline.

Use array context and join, or change $/ if you know what you're doing.

-- 
--------------------------------------------------------------
Andrew J. Perrin,  Ph.D.  Candidate,  Sociology,  UC  Berkeley
Consulting:     Solaris-Linux-NT-Samba-Perl-MS Access-Postgres
aperrin@socs.berkeley.edu - http://demog.berkeley.edu/~aperrin
--------------------------------------------------------------


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

Date: Tue, 18 Jul 2000 19:23:32 GMT
From: cheych@my-deja.com
Subject: perl code help
Message-Id: <8l2aqv$6o9$1@nnrp1.deja.com>

I don't understand the following lines of perl code, can anyone explain
to me? Thanks a lot.

$temp = '30';
my $misc = 'unit'.$temp;
$misc = ($$misc)? "\"$$misc\"":'NULL';

what means "$$misc"
Yuchun


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 20:23:31 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: perl code help
Message-Id: <713d5.42370$fR2.387494@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <8l2aqv$6o9$1@nnrp1.deja.com>,
	cheych@my-deja.com writes:
> I don't understand the following lines of perl code, can anyone explain
> to me? Thanks a lot.
> 
> $temp = '30';
> my $misc = 'unit'.$temp;
> $misc = ($$misc)? "\"$$misc\"":'NULL';
> 
> what means "$$misc"

Someone is trying to tell if a variable named $unit30 has something in
it.  This is called a symbolic reference and is usually a sign of 
bad program design choices.

In the "perlref" manual page, you can read up on symbolic references
and why they're usually considered a bad idea.

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 18 Jul 2000 13:26:08 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: perl code help
Message-Id: <8l2ees$26v$1@brokaw.wa.com>


<cheych@my-deja.com> wrote in message news:8l2aqv$6o9$1@nnrp1.deja.com...
> I don't understand the following lines of perl code, can anyone explain
> to me? Thanks a lot.
>
> $temp = '30';
> my $misc = 'unit'.$temp;
> $misc = ($$misc)? "\"$$misc\"":'NULL';
>
> what means "$$misc"

It's a 'symbolic reference' that refers to the value located in the scalar
$unit30.  It is usually considered very bad programming practice to use
symbolic references.  The same effect can be had with a hash (or in cases of
sequential values, an array).

$temp = 30; # you don't need to quote bare numbers
$misc = $mischash{$temp} ? $mischash{$temp} : 'NULL';

Now the variable $misc contains the contents of $mischash{$temp} if its
contents evaluate to true, otherwise it is assigned 'NULL'.  Be aware that
this will not work if the contents of $mischash{$temp} contains an empty
string or zero.

perldoc strict

Lauren





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

Date: Tue, 18 Jul 2000 18:25:40 GMT
From: zack3011@my-deja.com
Subject: Perl job offered San Mateo Perm
Message-Id: <8l27f5$esh$1@nnrp2.deja.com>

First, let me apologize for sending this out if this is the wrong place for
this type of message. My needs are Perl apecific, so this seemed like a good
place to look.

I need to hire at least two very strong Perl coders right away! Here is the
info about the gig.

Zack Network is the Internet's leading server-side infomediary. Using its
unique ability to sit between users and the Web, the company has introduced a
new paradigm of online content or functionality delivery: a next generation
enabling technology. Zack's server-side application platform, the Zack
Engine, is designed exclusively for Internet Service Providers and content
providers. The technology can deliver any type of content or functionality to
users in real time anywhere on the Internet.

We provide a very fun and flexible work environment, realizing that happy
engineers are productive engineers.  We work under the premise that a
balanced life is key to avoiding burnout; we want all Zack employees to have
a life outside of work.  Apart from a great salary you will get pre-IPO
options, great benefits and three weeks vacation time!


Software Engineers (Server-side)

We are looking for multiple engineers with a passion for coding mostly in
Perl and some C. Server-side Software Engineers work on the internals of our
optimized, non-blocking, single-threaded proxy server. Using Perl, C, C++,
and HTTP and TCP/IP at the protocol level.

Required Experience

Software Engineers should have a strong understanding of networking
protocols, in particular HTTP and/or TCP/IP. 2 years of programming in Perl
and/or C is a required minimum in a UNIX/Linux environment. Pluses include
experience with Perl XS and BSD Sockets, shared memory, SQL, distributed
databases, router configuration, IP masquerading and web server development.

If you are interested please send a not eto staffing@zack.com

Otherwise I am sorry to take up your time.

Cheers!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 18 Jul 2000 14:58:47 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Perl job offered San Mateo Perm
Message-Id: <3974A8E7.A421F26B@attglobal.net>

zack3011@my-deja.com wrote:
> 
> First, let me apologize for sending this out if this is the wrong place for
> this type of message. My needs are Perl apecific, so this seemed like a good
> place to look.

apecific?  Did you sneeze while typing that?

> I need to hire at least two very strong Perl coders right away! Here is the
> info about the gig.

I'm 6'2" and weigh 250lbs.  Im strong as a bear, I tell you!  I tore 
up some ligaments in my right shoulder playing football, but I can 
still lift a ton.  Hire me me me!

> Zack Network is the Internet's leading server-side infomediary. 

Are there other server side infomediaries? 

> Using its unique ability to sit between users and the Web, 

What makes this unique?  

> the company has introduced a
> new paradigm of online content or functionality delivery: a next generation
> enabling technology. 

Sounds like an AOL wanna-be.

> Zack's server-side application platform, the Zack
> Engine, is designed exclusively for Internet Service Providers and content
> providers. The technology can deliver any type of content or functionality to
> users in real time anywhere on the Internet.

You mean the rest of the Internet isn't real time?  Its time 
delayed?  I'm mad now!
 
> We provide a very fun and flexible work environment, realizing that happy
> engineers are productive engineers.  

Engineers enjoy being bitter.  Do you support bitterness?  (clue:
have lots of things around for them to complain about.)

> We work under the premise that a
> balanced life is key to avoiding burnout; we want all Zack employees to have
> a life outside of work.  Apart from a great salary you will get pre-IPO
> options, great benefits and three weeks vacation time!

So you want them to restrict their life outside of work to those
3 weeks?  

> Software Engineers (Server-side)
> 
> We are looking for multiple engineers with a passion for coding mostly in
> Perl and some C. Server-side Software Engineers work on the internals of our
> optimized, non-blocking, single-threaded proxy server. Using Perl, C, C++,
> and HTTP and TCP/IP at the protocol level.
      
Did you copy and paste that from your glossies?

> Pluses include
> experience with Perl XS and BSD Sockets, shared memory, SQL, distributed
> databases, router configuration, IP masquerading and web server development.

Your programmers are going to be writing router configs?  Oh my.
But hey, you want XS experience!  yay!

> Otherwise I am sorry to take up your time.

You are not.  Don't lie.


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

Date: 18 Jul 2000 21:02:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Perl job offered San Mateo Perm
Message-Id: <8l2glt$uef$7@slb6.atl.mindspring.net>

zack3011@my-deja.com wrote:
: Zack Network is the Internet's leading server-side infomediary. Using its
: unique ability to sit between users and the Web, the company has introduced a
: new paradigm of online content or functionality delivery: a next generation
: enabling technology. Zack's server-side application platform, the Zack
: Engine, is designed exclusively for Internet Service Providers and content
: providers. The technology can deliver any type of content or functionality to
: users in real time anywhere on the Internet.

Was this the output of an AS (Artificial Stupidity) program?



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

Date: 17 Jul 2000 07:47:27 -0500
From: troc@netrus.net (Rocco Caputo)
Subject: POE 0.11: event driven state machines, also supports Perl/Tk and Event
Message-Id: <aX1d5.30061$8V2.917954@news-east.usenetserver.com>

Good morning!  POE 0.11 has been released on an unsuspecting populace.

The previous CPAN release, version 0.10, was in March.  Testers and
bleeding-edge developers, however, have assisted in eleven subversions
since then.  One of the results of everyone's fine work is that the
changes since 0.10 are too long to list here.  They are available at
<http://www.newts.org/~troc/poe-public/Changes>, however.

This incarnation has been in active development since 1998 and is the
product of several people's time and effort.  I've tried to ACK or
thank everyone in the main manpage and Changes file, but I'm sure I've
forgotten someone.  Thank you all, even if you're not in there.

So, what is POE?

POE is a class for state machines and an event loop that drives them.
It is written entirely in Perl, if you don't count its dependence on a
nonstandard XS module, Filter::Util::Call.

POE cooperates with two other event loops: Perl/Tk and Event.  It
transparently maps its own resource watchers to whichever loop it sees
at load time.  If neither is available, it uses its own select loop.

POE contains a high-level I/O library.  This library evolved out of
common code that the author was tired of rewriting.  It is built with
all public functions, which makes it optional, easily replaced, and
portable across the three event loops POE supports.  Its SocketFactory
class, for example, works the same whether POE is watching socket
handles with its own select loop, Tk::fileevent, or Event->io.

POE's distribution includes several example and tutorial programs.
They are documented in the main POE manpage, but they aren't installed.
They should run fine from wherever they're unpacked, though, and
people are encouraged to look through them.

Thanks for reading.

-- Rocco Caputo / troc@netrus.net




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

Date: Tue, 18 Jul 2000 20:45:01 GMT
From: Craig Arnold <craig.arnold@boeing.com>
Subject: Problem with bitwise unpack
Message-Id: <3974C1CD.C85F7A38@boeing.com>

Hello,

I have a problem with unpacking bits from a hex word.  It appears that
Perl is unpacking a whole byte for each specifier, rather than the
number of bits, so that a 16-bit word will only fill 2 variables, and
the first will be the only one that gets the correct data.  This appears
to conflict with the documentation I have seen for pack and unpack,
which states that "the "b" and "B" fields pack a string that many bits
long," but doesn't say anything specific about how the unpack function
should work.  If I do an unpack "B16", I get all the bits in the correct
order.

If anybody out there knows about this and has an explanation, I'd
appreciate the info.  I'm running Perl 5.00502 on HP-UX 10.20 and
ActivePerl 5.00503 on Win32.

Thanks,

Craig Arnold

#!/usr/local/bin/perl -w

$status = "D0EB" ;

# 11010 0     0     0    111    0     1     0     1     1
($rt, $meb, $ins, $srq, $res, $bcr, $bus, $ssf, $dbc, $trm) = unpack
"B5B1B1B1B3B1B1B1B1B1", pack "H4", $status ;

                      #  Prints:        Expected:
print "rt : $rt\n"  ; #  rt : 11010     rt : 11010
print "meb: $meb\n" ; #  meb: 1         meb: 0
print "ins: $ins\n" ; #  ins:           ins: 0
print "srq: $srq\n" ; #  srq:           srq: 0
print "res: $res\n" ; #  res:           res: 111
print "bcr: $bcr\n" ; #  bcr:           bcr: 0
print "bus: $bus\n" ; #  bus:           bus: 1
print "ssf: $ssf\n" ; #  ssf:           ssf: 0
print "dbc: $dbc\n" ; #  dbc:           dbc: 1
print "trm: $trm\n" ; #  trm:           trm: 1




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

Date: Tue, 18 Jul 2000 19:29:38 GMT
From: hlawson@triad.rr.com (Hugh Lawson)
Subject: re problem
Message-Id: <slrn8n9d5r.5gt.hlawson@localhost.localdomain>

I'm studying regular expressions. I have a string like this:

 "all cows eat grass not some cows"

Or like this: "all cows eat grass, not some cows, all cows"

What I'm looking for is a single re that will substitute for the second
instance of "cows" the word "sheep", but not change any subsequent
instances of "cows".  The following does not work in both cases:

$a = "all cows eat grass not some cows";

$a =~ s/(^.*?cows\b)(.*)(cows)/$1$2sheep/;

print $a;
output: all cows eat grass not some sheep

$b = "all cows eat grass, not some cows, all cows";
$b =~ s/(^.*?cows\b)(.*)(cows)/$1$2sheep/;

print $b;
output: all cows eat grass, not some cows, all sheep

I've succeed at doing this with the split function, but I cannot
crack the code on doing it with an re.

-- 
Hugh Lawson
Greensboro, North Carolina
hlawson@triad.rr.com



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

Date: 18 Jul 2000 16:04:26 -0400
From: aperrin@socrates.berkeley.edu (Andrew J. Perrin)
Subject: Re: re problem
Message-Id: <uzonf2oj9.fsf@socrates.berkeley.edu>

hlawson@triad.rr.com (Hugh Lawson) writes:

> I'm studying regular expressions. I have a string like this:
> 
>  "all cows eat grass not some cows"
> 
> Or like this: "all cows eat grass, not some cows, all cows"
> 
> What I'm looking for is a single re that will substitute for the second
> instance of "cows" the word "sheep", but not change any subsequent
> instances of "cows".


Almost.... this one works.

 s/(^.*?cows\b)(.*?)(cows)/$1$2sheep/;

You need the non-greedy match to insure that it picks the *next*
instance of 'cows' instead of the *last* one.

-- 
--------------------------------------------------------------
Andrew J. Perrin,  Ph.D.  Candidate,  Sociology,  UC  Berkeley
Consulting:     Solaris-Linux-NT-Samba-Perl-MS Access-Postgres
aperrin@socs.berkeley.edu - http://demog.berkeley.edu/~aperrin
--------------------------------------------------------------


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

Date: Tue, 18 Jul 2000 20:18:44 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: re problem
Message-Id: <EY2d5.42347$fR2.387494@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <slrn8n9d5r.5gt.hlawson@localhost.localdomain>,
	hlawson@triad.rr.com (Hugh Lawson) writes:
> What I'm looking for is a single re that will substitute for the second
> instance of "cows" the word "sheep", but not change any subsequent
> instances of "cows".  The following does not work in both cases:
> 
> $a =~ s/(^.*?cows\b)(.*)(cows)/$1$2sheep/;

Close!  A quick tinkering with your version and I get:

        s/^(.*?cows\b.*?)cows/$1sheep/;

for $i (
"all cows eat grass",
"all cows eat grass not some cows",
"all cows eat grass not some cows not these cows",
"all cows eat grass not some cows not these cows nor those cows",)
{
        $_=$i;
        s/^(.*?cows\b.*?)cows/$1sheep/;
        print "$_\n";
}

results in:

all cows eat grass
all cows eat grass not some sheep
all cows eat grass not some sheep not these cows
all cows eat grass not some sheep not these cows nor those cows

That's what you wanted, right?

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: 18 Jul 2000 16:27:39 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: re problem
Message-Id: <slrn8n9gf2.3do.abigail@alexandra.delanet.com>

Hugh Lawson (hlawson@triad.rr.com) wrote on MMDXIII September MCMXCIII in
<URL:news:slrn8n9d5r.5gt.hlawson@localhost.localdomain>:
&& I'm studying regular expressions. I have a string like this:
&& 
&&  "all cows eat grass not some cows"
&& 
&& Or like this: "all cows eat grass, not some cows, all cows"
&& 
&& What I'm looking for is a single re that will substitute for the second
&& instance of "cows" the word "sheep", but not change any subsequent
&& instances of "cows".  The following does not work in both cases:
&& 
&& $a = "all cows eat grass not some cows";
&& 
&& $a =~ s/(^.*?cows\b)(.*)(cows)/$1$2sheep/;
&& 
&& print $a;
&& output: all cows eat grass not some sheep
&& 
&& $b = "all cows eat grass, not some cows, all cows";
&& $b =~ s/(^.*?cows\b)(.*)(cows)/$1$2sheep/;
&& 
&& print $b;
&& output: all cows eat grass, not some cows, all sheep
&& 
&& I've succeed at doing this with the split function, but I cannot
&& crack the code on doing it with an re.


Here's a generic solution.

    my $text  = "cows";
    my $new   = "sheep";
    my $occur =  2;       # Replace second "cows" with "sheep".
    s{^((?:(?:(?!$text).)*$text){${\($occur - 1)}}(?:(?!$text).)*)$text}
     {${1}$new}s;


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


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

Date: Tue, 18 Jul 2000 20:27:17 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: re problem
Message-Id: <sn9fd5u01nk146@corp.supernews.com>

Hugh Lawson (hlawson@triad.rr.com) wrote:
: I'm studying regular expressions. I have a string like this:
: 
:  "all cows eat grass not some cows"
: 
: Or like this: "all cows eat grass, not some cows, all cows"
: 
: What I'm looking for is a single re that will substitute for the second
: instance of "cows" the word "sheep", but not change any subsequent
: instances of "cows".

  s/(cows.*?)cows/${1}sheep/

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: Tue, 18 Jul 2000 20:33:34 GMT
From: hlawson@triad.rr.com (Hugh Lawson)
Subject: Re: re problem
Message-Id: <slrn8n9gto.5ju.hlawson@localhost.localdomain>

On 18 Jul 2000 16:27:39 EDT, Abigail <abigail@delanet.com> wrote:
>Hugh Lawson (hlawson@triad.rr.com) wrote on MMDXIII September MCMXCIII in
><URL:news:slrn8n9d5r.5gt.hlawson@localhost.localdomain>:
>&& I'm studying regular expressions. I have a string like this:

[snip]
>
>Here's a generic solution.
>
>    my $text  = "cows";
>    my $new   = "sheep";
>    my $occur =  2;       # Replace second "cows" with "sheep".
>    s{^((?:(?:(?!$text).)*$text){${\($occur - 1)}}(?:(?!$text).)*)$text}
>     {${1}$new}s;

A big thank-you to Abigail, Andrew, and Clinton for the replies.  They
came so swiftly that it will take me more time to study them (re's are
very abstract) that it took to get an answer.

-- 
Hugh Lawson
Greensboro, North Carolina
hlawson@triad.rr.com



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

Date: Tue, 18 Jul 2000 20:33:23 +0100
From: Rosemary I H Powell <rosie@dozyrosy.plus.com>
Subject: Splitting on a number: help please
Message-Id: <MPG.13dec100de7837e5989692@usenet.plus.net>

Given that I have (a whole batch of) data containing strings in the form 
(3 or 4 letter month)(2 digit year) e.g sept99 or may00, is there a 
neater way to convert it into the form Sept-99, May-00, than my (working) 
attempt:

$result = join ("-",(split (/\d/,,ucfirst($month))),(substr($month,-2)));

I thought I might be able to split just on the split (/\d/... but this 
only gives me the first half of the string, so I've ended up with 
something a little cack-handed.

Thanks, Roseamry

-- 
----------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosie@dozyrosy.plus.com    |
|                             Work: r.i.h.powell@rl.ac.uk      |
|                       http://NeedleworkSamplers.com/         |
|                       http://www.dozyrosy.plus.com/          |
|                       http://www.CavalierKingCharles.com/    |
----------------------------------------------------------------


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

Date: Tue, 18 Jul 2000 14:55:04 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Splitting on a number: help please
Message-Id: <3974B618.F94B9E98@texas.net>

Rosemary I H Powell wrote:
> 
> Given that I have (a whole batch of) data containing strings in the form
> (3 or 4 letter month)(2 digit year) e.g sept99 or may00, is there a
> neater way to convert it into the form Sept-99, May-00, than my (working)
> attempt:
> 
> $result = join ("-",(split(/\d/,,ucfirst($month))),(substr($month,-2)));

s/(\D+)(\d+)/\u$1-$2/;

perldoc perlre

- Tom


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

Date: Tue, 18 Jul 2000 21:56:37 +0200
From: Christian Vandsų <christian@fabel.dk>
Subject: Re: Splitting on a number: help please
Message-Id: <3id9nsgacinc1l6capgt9uc672pqe3djn6@4ax.com>

On Tue, 18 Jul 2000 20:33:23 +0100, Rosemary I H Powell
<rosie@dozyrosy.plus.com> wrote:

>Given that I have (a whole batch of) data containing strings in the form 
>(3 or 4 letter month)(2 digit year) e.g sept99 or may00, is there a 
>neater way to convert it into the form Sept-99, May-00, than my (working) 
>attempt:
>
>$result = join ("-",(split (/\d/,,ucfirst($month))),(substr($month,-2)));
>

Try this: 

 my $result = $1."-".$2 if ($month=~ m/^(\w{3,4})(\d\d)$/g);

/Christian


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

Date: Tue, 18 Jul 2000 20:28:57 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Splitting on a number: help please
Message-Id: <d63d5.42407$fR2.387494@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <MPG.13dec100de7837e5989692@usenet.plus.net>,
	Rosemary I H Powell <rosie@dozyrosy.plus.com> writes:
> Given that I have (a whole batch of) data containing strings in the form 
> (3 or 4 letter month)(2 digit year) e.g sept99 or may00, is there a 
> neater way to convert it into the form Sept-99, May-00, than my (working) 
> attempt:
> 
> $result = join ("-",(split (/\d/,,ucfirst($month))),(substr($month,-2)));

My first crack at it:

$a="sept99";
$a=~s/([a-z]+)(\d+)/ucfirst($1)."-".$2/e;
print $a;

Winds up with "Sept-99" as expected...

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours! 
  clintp@geeksalad.org         for details see http://www.geeksalad.org
"If you rush a Miracle Man, 
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 18 Jul 2000 20:32:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Splitting on a number: help please
Message-Id: <sn9fmk5l1nk116@corp.supernews.com>

Rosemary I H Powell (rosie@dozyrosy.plus.com) wrote:
: Given that I have (a whole batch of) data containing strings in the form 
: (3 or 4 letter month)(2 digit year) e.g sept99 or may00, is there a 
: neater way to convert it into the form Sept-99, May-00, than my (working) 
: attempt:
: 
: $result = join ("-",(split (/\d/,,ucfirst($month))),(substr($month,-2)));

Sure.  Among other WTDI:

  ($result = $month) =~ s/([a-z]{3,4})(\d{2})/\u$1-$2/;

 ...and that goes out of its way to avoid converting things that don't
match the pattern.  You could make it briefer by changing the quantifiers
to +.

-- 
   |   Craig Berry - http://www.cinenet.net/users/cberry/home.html
 --*--  "Beauty and strength, leaping laughter and delicious
   |   languor, force and fire, are of us." - Liber AL II:20


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

Date: 18 Jul 2000 22:20:49 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Suggestion for syntax change
Message-Id: <ya2zdwbi.fsf@macforce.sumus.dk>

"Keith G. Murphy" <keithmur@mindspring.com> writes:

> Jakob Schmidt wrote:
> > 
> > I just asked if this specific example wouldn't
> > be ugly.
> > 
> > Well, wouldn't it?
[...]

> I think I like it.

And so does Bart. Maybe I just need to get used to the thought.

Can you give a similar example of operator polymorphism from the Perl
syntax for my troubled eyes?

-- 
Jakob


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

Date: Tue, 18 Jul 2000 17:47:34 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: watch out for the mod operator!
Message-Id: <3974D076.4F80C3E3@cc.gatech.edu>

W Kemp wrote:

> >Your number may be too large to be corectly handled as an integer in some
> >perl functions.  Try using Math::BigInt:
>
> the number is over 2**40 !

I knew that.  I said it *may* be too large because on my system (Win98, perl
5.005_03) I had no trouble using + - * or / on that number, just %.  I
expected BigInt to work correctly on all platforms.

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3738
**************************************


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