[25315] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7560 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 23 11:06:12 2004

Date: Thu, 23 Dec 2004 08:05:09 -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           Thu, 23 Dec 2004     Volume: 10 Number: 7560

Today's topics:
    Re: Change file creation date? (Peter Scott)
    Re: Example of perl script downloading a web page? <tadmc@augustmail.com>
    Re: generating a session id ioneabu@yahoo.com
    Re: How can script find its host's name/IP address? <karlUNDERSCOREkramsch@yahooPERIODcom.invalid>
    Re: How can script find its host's name/IP address? <gbeeker@gmail.com>
    Re: How can script find its host's name/IP address? <matternc@comcast.net>
    Re: How to navigate the docs? (Anno Siegel)
    Re: Is zero even or odd? jmfbahciv@aol.com
    Re: Is zero even or odd? <salesEXTRACT@anasoft.co.uk>
    Re: Is zero even or odd? <gweast@mathworks.com>
    Re: Is zero even or odd? <jamie_5_not_valid_after_5_Please@charter.net>
    Re: Is zero even or odd? <dirk@neopax.com>
    Re: Is zero even or odd? <hadrainc@earthlink.net>
    Re: Is zero even or odd? <salesEXTRACT@anasoft.co.uk>
        monitor for sleeping processes <lee_h_shannon@hotmail.com>
        Perl interface to Unix ps? <jkrugman345@yahbitoo.com>
    Re: Perl interface to Unix ps? <dug@plusthree.com>
    Re: Perl vs. .Net regular expressions tconti@hotmail.com
        Problem with Open Perl IDE <chris_breemer@nl.compuware.com>
    Re: reg expression with input line <nobull@mail.com>
    Re: reg expression with input line <sam.wun@authtec.com>
        return truely random number? <sam.wun@authtec.com>
    Re: return truely random number? <matternc@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Dec 2004 12:58:06 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Change file creation date?
Message-Id: <yhzyd.570987$%k.427268@pd7tw2no>

In article <cqcnu0$rp6$2@sun3.bham.ac.uk>,
 Brian McCauley <nobull@mail.com> writes:
>Chris Mattern wrote:
>> You can't.  There's no such thing as "file creation time", at least not
>> on a Windows or UNIX computer.  The filesystem does not track such a
>> statistic.
>
>Er, NTFS5 does.  (I think earlier NTFS did too).

VMS too.  (Excuse me, OpenVMS.)

-- 
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/


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

Date: Thu, 23 Dec 2004 06:03:07 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Example of perl script downloading a web page?
Message-Id: <slrncslcvr.5ir.tadmc@magna.augustmail.com>

Dr Ann Huxtable <annhuxtable@research.de.edu> wrote:

> Any one know of an example of a Perl script downloading a web page 
> (actually a web based form), passing in parameters to contol box, user 
                        ^^^^
> name, password etc, refreshing the page and then saving page to a file?


Anyone who has checked the Perl FAQ before posting to the
Perl newsgroup knows of such an example.


   perldoc -q form

       How do I automate an HTML form submission?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 23 Dec 2004 06:49:51 -0800
From: ioneabu@yahoo.com
Subject: Re: generating a session id
Message-Id: <1103813391.302838.297640@f14g2000cwb.googlegroups.com>

My only reason for not wanting to use it is that it requires that
Apache:Session:MySQL requires the use of a hash as follows:

#establish new session
tie %session, "Apache::Session::MySQL",undef,
{
Handle=>$dbh,
LockHandle=>$dbh
}; #just an example of starting a new session

The %session hash is tied to an object of the Apache::Session::MySQL
class which allows the user to store and retrieve session related
persistant data from the MySQL database using the familiar hash as an
interface rather than querying the database directly.  In my limited
work with sessions and related persistant data, I feel more comfortable
dealing directly with the database.  Maybe the Apache:Session way is
more portable.  Since I do not use the %session hash for anything other
than to access the produced session ID or to validate if an existing ID
is valid, I found myself passing around %session almost as a dummy
variable.  I decided to experiment with creating the session ID myself
for these reasons.  Admittedly, my method was inferior to the way the
Apache:Session module does it.  To be honest, a big weak point in my
programming skills in any language is studying other people's code.  I
wrongly thought that it would be more instructive and fun to write my
own session ID generator based on Perl's random number generator.  My
original posted code was admittedly poor by Perl standards and as I
previously stated, I wish I had thought of the right way myself.  I
should read all basic material on dealing with arrays and hashes over
and over until it sinks in.  When I finally took the little bit of time
and effort it took to look into the workings of Apache:Session and see
the MD5 way they do it, I wrongly thought that my way was just as good
because who will ever know how I am generating my ID's anyway?  The
correct solution in my case was to use the one-line statement from
Apache:Session for creating the ID in my own sub and be done with it.
I don't feel I was stupid or wrong to ask why to use one method over
the other and I feel that I stated that question appropriately by
placing both methods side by side in a simple piece of self-contained,
runnable code.  Joe Smith provided a very nice rigorous explanation for
why my simple minded solution was wrong.  There is probably more to it
than that, but why go any further at this point?  It's like me going to
the store to buy a steel, fire-proof safe and then deciding to build my
own version out of wood.  Rather than arguing with the salesman over
the benefits of his tested and proven safe over my home-made solution,
I should just buy the real thing and move on with my life without too
much further probing.  The wood project may be a fun, useful diversion
in my own free time, but if I need a strong, secure fireproof safe, I
should check with consumer reports, buy the best one, and use my free
time to figure out what to put in it.

Thanks for all help!

wana



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

Date: Thu, 23 Dec 2004 13:45:34 +0000 (UTC)
From: KKramsch <karlUNDERSCOREkramsch@yahooPERIODcom.invalid>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <cqei5u$ds9$1@reader1.panix.com>

In <eDqyd.27938$GK5.1356247@news20.bellglobal.com> "Matt Garrish" <matthew.garrish@sympatico.ca> writes:


>"kj" <socyl@987jk.com.invalid> wrote in message 
>news:cqdc0l$4dd$1@reader1.panix.com...
>>
>> How can script find the hostname (or at least the IP address) of
>> the host it is running on?
>>

>The same way you'd do it in any other language: read the environment 
>variables.

What makes you think there is an environment variable that has the
domainname info?  When I run a script on my Linux box that prints
all of %ENV, not a single %ENV value shows the machine's domain
name.

	Karl

-- 
Sent from a spam-bucket account; I check it once in a blue moon.  If
you still want to e-mail me, cut out the extension from my address,
and make the obvious substitutions on what's left.


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

Date: 23 Dec 2004 06:13:54 -0800
From: "Greg Beeker" <gbeeker@gmail.com>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <1103811234.929879.277900@z14g2000cwz.googlegroups.com>

I'm not sure how to get this into perl, but you may use the shell
script line below:
nslookup `hostname` | grep Name | awk '{print $2}'
I tested this on AIX51 and Solaris 8, and it gives the fully qualified
hostname.domainname.



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

Date: Thu, 23 Dec 2004 10:41:12 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: How can script find its host's name/IP address?
Message-Id: <6aKdnYoFb8WFelfcRVn-1Q@comcast.com>

kj wrote:

> 
> 
> 
> 
> How can script find the hostname (or at least the IP address) of
> the host it is running on?
> 
> TIA,
> 
> kj

One thing to remember is that your host doesn't have an IP address--
network interfaces have IP addresses.  One solution that comes to
me is simply invoking the external ifconfig (or whatever the 
equivalent might be on your system) command, which will
tell you all about all the addresses the various network interfaces
on your host may have.  Which one you want to pick out is then,
of course, up to you.
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 23 Dec 2004 13:31:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to navigate the docs?
Message-Id: <cqehb2$npq$1@mamenchi.zrz.TU-Berlin.DE>

Bill Smith <wksmith@optonline.net> wrote in comp.lang.perl.misc:
> 
> "Mike" <please@send.replies.to.ng> wrote in message
> news:cq9g28$8tt$1@reader2.panix.com...
> >
> >
> >
> > What do you do when you want to find something in the Perl
> > documentation, and you have *no idea* in which of the many perlxxxx
> > it is?  I've tried perltoc in the past with little success.
> >
> > At this point someone would reply "But WHAT are you looking for???",
> > which would miss the point of my question, which is finding general
> > strategies for using the Perl docs.
> 
> 
> Many of us "senior citizens" are good at finding info in books, but have
> not developed the analogous skills for using electronic documentation.
> I start with my well worn copy of "Perl in a Nutshell".  It usually
> provides the key to find full documentation with perldoc.  My copy of
> the book improves with age as I add margin notes and cross-references.

A senior citizen myself, I like to do that too.  But I find that software,
including Perl, moves too fast, so books age too fast.  I don't come
across the pearls of wisdom I once penciled into the 1991 Camel anymore. :)

There ought to be a method to attach notes to pods that re-appear
in the next version as long a the surrounding text is still there.
A diff/patch combo could do a decent job...

> When this fails, I also grep the .pod files.  I wish that someone would
> write a program that uses the algorithm in perldloc to find the .pod
> files of interest, and then searches through each of them with a regular
> expression the way that grep does.

Yes, that is a request that comes up now and again.  Years ago I took
a look at perldoc with an intent of adding that, but the code was a mess
and I gave up.  Instead I have used a stand-alone script (shown below)that
searches the standard .../pod directory, like what Tad suggests to do
manually.  It does a good job, but it doesn't give you the comfort of
searching everything that perldoc can find.  Only integration into
perldoc would give that.  These days, the perldoc code looks much more
inviting, it shouldn't be too hard.

Anno

#!/usr/local/bin/perl
use strict; use warnings; $| = 1;
use Config;
use Getopt::Std;

getopts( 'l', \ my %opt);
my $re = shift || '';
if ( $re =~ m{^(/?)(.*)\1$} ) {
    $re = $2;
} else {
    $re = quotemeta $re;
}
die "regex must be given\n" unless $re;
$re = qr/$re/;

my %pod_files = get_pod_files() or die "Can't find pod files";
while ( my ( $name, $file) = each %pod_files ) {
    if ( $opt{ l} ) {
        print "$name\n" if grep_pod( $re, $file);
    } else {
        print "$name: $_" for grep_pod( $re, $file);
    }
}

########################################################################

sub get_pod_files {
    my $privlib = $ENV{ PERL_PRIVLIB} || $Config{ privlib};
    return unless $privlib;
    my ( $pod_dir, $d);
    for ( qw( pod pods) ) {
        $pod_dir = "$privlib/$_";
        last if opendir $d, $pod_dir;
    }
    return unless $d;

    my %pod_files;
    while ( my $pod = readdir $d ) {
        ( my $name = $pod ) =~ s/\.pod$// or next;
        $pod_files{ $name} = "$pod_dir/$pod";
    }
    %pod_files;
}

sub grep_pod {
    my ( $re, $file) = @_;
    open my( $f), $file or return;
    my @coll;
    while ( <$f> ) {
        next unless $_ =~ $re;
        push @coll, $_;
        last unless wantarray;
    }
    @coll;
}
__END__


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

Date: Thu, 23 Dec 04 11:29:32 GMT
From: jmfbahciv@aol.com
Subject: Re: Is zero even or odd?
Message-Id: <VtSdnaIqYsvwKFfcRVn-tQ@rcn.net>

In article <LSjyd.9199$yK.1676@newsread3.news.atl.earthlink.net>,
   "Nicholas O. Lindan" <see@sig.com> wrote:
>"Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com> wrote
>
>> Am I missing something here?

>No, not really - nobody has said anything profound yet.

You are kidding.  Didn't you think the stuff that Mati Meron
wrote was profound?  What he talked about is one of the
building blocks of making a mathematics.  Did you miss the
difference between non-existence and undefined?

<snip>

/BAH

Subtract a hundred and four for e-mail.


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

Date: Thu, 23 Dec 2004 12:47:50 GMT
From: "Kevin Aylward" <salesEXTRACT@anasoft.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <W7zyd.4736$0W6.284@fe2.news.blueyonder.co.uk>

Michael Mendelsohn wrote:
> Kevin Aylward schrieb:
>> Nicholas O. Lindan wrote:
>>> j [sqrt(-1)] isn't a number but we still mix it up with numbers.
>>
>> Of course it is a number, thats why we treat it as such.
>>
>>> For infinity I can look in the sky.  For 0 I can examine my
>>> bank balance.  But for j I can't look anywhere,
>>
>> Not really relevant. Numbers only "exist" in the mind.
>
> Weak answer.

Ahmm...

> Points on a plane are often modelled as complex numbers, so you need
> only look as far as graph paper to "see" them.

Numbers are concepts. Graph paper drawings are only representaions of 
numbers, not numbers themselves.

How would you go about representing a complex vector "space number"? Now 
we need 9 dimensions for our graph paper.

Kevin Aylward
salesEXTRACT@anasoft.co.uk
http://www.anasoft.co.uk
SuperSpice, a very affordable Mixed-Mode
Windows Simulator with Schematic Capture,
Waveform Display, FFT's and Filter Design. 




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

Date: Thu, 23 Dec 2004 09:03:01 -0500
From: Gordon Weast <gweast@mathworks.com>
Subject: Re: Is zero even or odd?
Message-Id: <cqej65$hq0$2@fred.mathworks.com>

Alfred Z. Newmane wrote:

> Nicholas O. Lindan wrote:
> 
>>"robert j. kolker" <nowhere@nowhere.net> wrote
>>
>>
>>>>Then why can you not perform 1/0 ? (or n/0)
>>>
>>>If n/0 for n not 0 had a value then it would be equal to 0 and not
>>>equal to 0 at the same time.
>>
>>???
>>
>>The common contrarian take is:
>>
>>1 / 0 = oo
>>n / 0 = n * oo
>>0 / 0 = 0 * oo = 1
> 
> 
> oo (infinity isn't a number) so you cannot use it this way.
> 
> 

Well, if you move out of pure math into something more applied,
like physics or signal processing, you find a nice little thing
called the Dirac delta function.  This seems to have confounded
mathemeticians for a while before they finally came around and
decided that it really does work.

This wonderful function has infinite height and zero width, yet
it has area 1.  Granted, you can work with a limit as the width
goes to 0, but you don't have to.

Think Fourier series and Fourier analysis.  These wouldn't work
without the Dirac delta function.

A wonderful example of 0 * oo = 1.

Another is renormalization theory in QED (Quantum Electrodynamics).
There are several infinities in the theory that appeared to make
the results nonsense.  However, if you keep track very carefully,
you can get the infinities to cancel and come up with predictions
that match measurements very accurately.

This is an example of (oo + n) - oo = n as well as oo/oo = 1.

So all the statements about how these combinations of 0 and oo are
undefined are only part of the story.  Sometimes they do make sense.

This has been a very entertaining topic.  I'll hate to eventually see
it die...  8-)



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

Date: Thu, 23 Dec 2004 10:55:51 -0800
From: Jamie <jamie_5_not_valid_after_5_Please@charter.net>
Subject: Re: Is zero even or odd?
Message-Id: <HAByd.24162$Bs7.12457@fe06.lga>

Tim Wescott wrote:

> John Larkin wrote:
> 
>> On Thu, 23 Dec 2004 05:48:17 GMT, jsavard@excxn.aNOSPAMb.cdn.invalid
>> (John Savard) wrote:
>>
>>
>>
>>> Because the rules break down so badly for dividing by zero, including
>>> the fact that multiplication now stops being associative, mathematicians
>>> have chosen to concentrate on studying only the "real numbers", which
>>> are all finite quantities. This way, they can deduce new theorems from
>>> the properties that multiplication and division have on those numbers;
>>> generalizing to division by zero is not normally done because it appears
>>> that it would just create awkward exceptions in every mathematical
>>> proof, without being fruitful, without producing new, useful results.
>>>
>>
>>
>> Except that in electronic design, especially in realtime embedded
>> systems, the issues can't be avoided. If you digitize zero volts, and
>> that's the denominator in some process equation, you can't just say
>> "oh well, that's not defined/fruitful". Doubly so in a deep embedded
>> system where you have no audience to complain to.
>>
>> John
>>
> 
> I have found, however, that if one has a model that leads one to a 
> divide by zero problem one is suffering from one of two problems:  one, 
> an insufficient model, or two, an inaccurate measurement (which one can 
> sophomoricaly lump into one, if one is so inclined).
> 
> It is always necessary to ask yourself "why am I allowing a division by 
> something that may go to zero?"  "What does it mean if my 'x' is zero 
> here?", etc., and code accordingly.
> 
if your dealing with microprocessor code a simple Bit test of bit 0 
(first bit) will tell you if the value is Odd/even..
  if its on its Odd value otherwise its Even. and that covers the
zero problem.



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

Date: Thu, 23 Dec 2004 15:38:12 +0000
From: Dirk Bruere at Neopax <dirk@neopax.com>
Subject: Re: Is zero even or odd?
Message-Id: <330735F3p918qU1@individual.net>

Gordon Weast wrote:

> 
> Another is renormalization theory in QED (Quantum Electrodynamics).
> There are several infinities in the theory that appeared to make
> the results nonsense.  However, if you keep track very carefully,
> you can get the infinities to cancel and come up with predictions
> that match measurements very accurately.

And physicists think it an ugly bodge. Clearly the infinities are failures of 
the theory, but the failures cancel out.

-- 
Dirk

The Consensus:-
The political party for the new millenium
http://www.theconsensus.org


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

Date: Thu, 23 Dec 2004 15:50:22 GMT
From: vonroach <hadrainc@earthlink.net>
Subject: Re: Is zero even or odd?
Message-Id: <uupls0hour7vnml8fmjmv89vda8d13i0po@4ax.com>

On Wed, 22 Dec 2004 12:07:32 -0500, Shawn Corey
<shawn.corey@sympatico.ca> wrote:

>vonroach wrote:
>>  Then infinity is undefined?  

I did not write this. Please be more careful.
Infinity is a mathematical concept like all mathematics. Cantor has
most complete exploration to date in my opinion. 
Mathematics in general are human inventions that serve two purposes to
count and to concisely illustrate scientific concepts.


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

Date: Thu, 23 Dec 2004 15:55:00 GMT
From: "Kevin Aylward" <salesEXTRACT@anasoft.co.uk>
Subject: Re: Is zero even or odd?
Message-Id: <oTByd.5312$0W6.299@fe2.news.blueyonder.co.uk>

Gordon Weast wrote:
> Alfred Z. Newmane wrote:
>
>> Nicholas O. Lindan wrote:
>>
>>> "robert j. kolker" <nowhere@nowhere.net> wrote
>>>
>>>
>>>>> Then why can you not perform 1/0 ? (or n/0)
>>>>
>>>> If n/0 for n not 0 had a value then it would be equal to 0 and not
>>>> equal to 0 at the same time.
>>>
>>> ???
>>>
>>> The common contrarian take is:
>>>
>>> 1 / 0 = oo
>>> n / 0 = n * oo
>>> 0 / 0 = 0 * oo = 1
>>
>>
>> oo (infinity isn't a number) so you cannot use it this way.
>>
>>
>
> Well, if you move out of pure math into something more applied,
> like physics or signal processing, you find a nice little thing
> called the Dirac delta function.  This seems to have confounded
> mathemeticians for a while before they finally came around and
> decided that it really does work.
>
> This wonderful function has infinite height and zero width, yet
> it has area 1.

Not really technically accurate. The Dirac function is defined by 
limits, not by "infinite height" and "zero width"

>Granted, you can work with a limit as the width
> goes to 0, but you don't have to.

Yes you do.

>
> Think Fourier series and Fourier analysis.  These wouldn't work
> without the Dirac delta function.

This is not really true. Sure, *one* method of proving the Fourier 
transform pair is to use the Dirac function, but this approach is not 
required, most treatments actually use a more direct approach, e.g. 
integral sin(Lx)/x as L->oo.


Kevin Aylward
salesEXTRACT@anasoft.co.uk
http://www.anasoft.co.uk
SuperSpice, a very affordable Mixed-Mode
Windows Simulator with Schematic Capture,
Waveform Display, FFT's and Filter Design. 




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

Date: Thu, 23 Dec 2004 09:03:46 -0500
From: "lee_h_shannon" <lee_h_shannon@hotmail.com>
Subject: monitor for sleeping processes
Message-Id: <fdbbb3c6ff40597acf79a561b23bc8db@localhost.talkaboutprogramming.com>

Hi, 

I'm a complete perl newbie... Can anyone assist with a little bit of perl
to monitor for a process that is constantly sleeping. Once it's decided
that the process is sleeping, it sends a wee mail! :o)

Any help/pointers would be much appreciated.

Thanks,

Lee



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

Date: Thu, 23 Dec 2004 14:24:40 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: Perl interface to Unix ps?
Message-Id: <cqekf8$eie$1@reader1.panix.com>





I'm writing a Perl script that is supposed to find the PIDs of all
the running versions of a program and send them a SIGUSR1.  As this
description suggests, the script is meant for a Unix platform, but
it could be Linux, BSD, Solaris, etc.

The only way I can think of to get the PIDs for all the desired
processes is to scan the output of a suitable 'system "ps -blah"'
call, but there are many versions of ps around, each with its own
syntax and output format.  Does anyone know of a Perl interface
for ps? (I searched perldoc -q ps, man POSIX, and CPAN for ps but
didn't find anything; I'm hoping that what I'm looking for exists
in some less obvious place.)

TIA,

jill


-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: 23 Dec 2004 14:55:31 GMT
From: Douglas Hunter <dug@plusthree.com>
Subject: Re: Perl interface to Unix ps?
Message-Id: <cqem93$h7i$0@pita.alt.net>

J Krugman wrote:
> I'm writing a Perl script that is supposed to find the PIDs of all
> the running versions of a program and send them a SIGUSR1.  As this
> description suggests, the script is meant for a Unix platform, but
> it could be Linux, BSD, Solaris, etc.
> 
> The only way I can think of to get the PIDs for all the desired
> processes is to scan the output of a suitable 'system "ps -blah"'
> call, but there are many versions of ps around, each with its own
> syntax and output format.  Does anyone know of a Perl interface
> for ps? (I searched perldoc -q ps, man POSIX, and CPAN for ps but
> didn't find anything; I'm hoping that what I'm looking for exists
> in some less obvious place.)

I've had success with Proc::ProcessTable 
(http://search.cpan.org/~durist/Proc-ProcessTable-0.39/).  By its 
reviews it seems that others have as well.  If the Unix that you run 
isn't supported (darwin, nonstop-ux windows, linux, solaris, aix,
hpux, freebsd, irix, dec_osf, bsdi, netbsd, unixware 7.x and
SunOS are the currently supported platforms) there is a PORTING document 
that you might find useful.

One of the reviews says, "Never need to parse 'ps' commands again".
Joy!  ;-)

-- Douglas


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

Date: 23 Dec 2004 03:35:23 -0800
From: tconti@hotmail.com
Subject: Re: Perl vs. .Net regular expressions
Message-Id: <1103801723.299675.28060@c13g2000cwb.googlegroups.com>


Bob Walton wrote:
> tconti@hotmail.com wrote:
> ...
> > I am looking for a little input on an issue we are grappling with.
We
> > are updating our site to be Unicode compliant.  We have some
> > applications running under Perl 5.6.1 which has "sketchy" support
for
> > Unicode.  So there is a push to re-write these applications in .Net
> > (C#) because we are largely a Windows shop.  Most of our Perl code
is
> > regex heavy.  .Net does have a fairly robust regex engine, but I
have
> > never perfmance tested it against Perl.  Has anyone done such
testing
> > and what are your thoughts/results?  Also, if we choose to stick
with
> > Perl we would need to move to 5.8 for Unicode support.  Would this
just
> > be a simple recompile or would there be any other issues that would
> > need to be addressed?
>
> On Windoze, you won't have to compile Perl -- just install it
> from ActiveState or maybe Indigo.  Just one word of caution:
> Assuming you're using ActiveState's Perl, don't simply install
> Perl 5.8.4 over top of Perl 5.6.1, as you'll find that ppm
> (ActiveState's Perl Package Manager) won't work.  Uninstall and
> completely delete Perl 5.6.1, then install Perl 5.8.4.  You'll
> have to reinstall all your nonstandard packages as well.
>
> You probably won't have to change your code at all, except maybe
> to add or modify binmode() calls to properly handle your Unicode
> stuff.
>
> ...
> > Tom
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
>
> -----------== Posted via Newsfeed.Com - Uncensored Usenet News
==----------
>    http://www.newsfeed.com       The #1 Newsgroup Service in the
World!
> -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19
Servers =-----

Thanks for all of the replies!!!

I should have been more explicit when I meant re-compile (my bad...).
Our code is compiled into executables using ActiveState's PerlApp (v
5.0.3).  If we upgrade to Perl 5.8 will we need to upgrade the PerlApp
license or does it include the packages of the locally installed
version of Perl (i.e. if I have 5.8 installed it will include these
packages in the executable).   

Thanks and Happy Festivus,
Tom



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

Date: 23 Dec 2004 05:39:16 -0800
From: "cbr" <chris_breemer@nl.compuware.com>
Subject: Problem with Open Perl IDE
Message-Id: <1103809156.042348.115010@f14g2000cwb.googlegroups.com>

Hi all,
I'm using the Open Perl IDE to play around with Perl.
The IDE seems to work pretty well but there's one thing
driving me crazy. While stepping thru the code, output
appears in the Output window as expected. But when the
last statement is done, that output disappears from the
output window ! Or rather, it becomes invisible. It's
still there, because when I open the 'Preferences' window
I can see it again. When I close that window, the output
once more becomes invisible.
Would this be intended behaviour ? Thanks for any ideas.

Chris



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

Date: Thu, 23 Dec 2004 12:38:43 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: reg expression with input line
Message-Id: <cqedv3$kpu$1@sun3.bham.ac.uk>



sam wrote:

> I ended up some perl code as shown below:
> 
> ($prodcode,$custname,$qty,$cost,$date,$prodname) =
>         /^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9]) 
> +([0-9]+\.[0-9][0-9])([0-9]+)(.*)/,
>         "12031361          ABC3    567.00 
> 5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\ 
> 
> xbch)\xa4\xe9\xa5\xce12x20's";

What are you expecting the comma operator in the above code to do? 
Where did you get this expectation?  Compare your expectation to what 
comma actually does (RTFM).  Compare it also to the =~ operator which 
does do what I'm guessing you think the comma does, but it's operands 
are the other way around.

You should always compile Perl with strictures and warnings enabled. 
Perl would then have told you something was wrong.

You should always delare all variables as lexically scoped in the 
smallest applicable scope.  This means there's a 95% chance that you 
should have had a my() in there.

> print "Result: 
> ".$prodcode.",".$custname.",".$qty.",".$cost.",".$date.",".$prodname . 
> "\n";

Why have you obfucated this?

  print "Result: $prodcode,$custname,$qty,$cost,$date,$prodname\n";

> 
> if ($prodcode eq "" or $custname eq "" or $qty eq "" or $cost eq "" or 
> $date eq ""  or $prodname eq "") {
>    print "Failed to parse input file.\n";
>    exit;
> }

There is no way any of those variables except $prodname can be an empty 
string.  If the match succedes then all the others must all be non-empty 
as none of the other captures could match the empty string.  If the 
match failed then all the variables will be undefined.  Although (undef 
eq '') is true it makes your code clearer if you test definedness with 
defined().  (Also it avoids a warning).  It is also only necessary to 
check the definedness of one of the variables.  Better still just use 
the return value of the list assignment statement that will be true if 
the match succeded.

> But the parser failed to parse the input text, it returns empty string.

This is nonsense there is no return value from your code.

> What is wrong with the above code, especially the parser I created for 
> parsing the $date.

The parser you created for parsing $date was not included in the code 
you posted so we can't possbily comment.

[ Please excuse the line-wrap damage in the following ]

#!/usr/bin/perl
use strict;
use warnings;

$_= "12031361          ABC3    567.00 
5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\xbch)\xa4\xe9\xa5\xce12x20's";

if ( my($prodcode,$custname,$qty,$cost,$date,$prodname) =
      /^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9]) 
+([0-9]+\.[0-9][0-9])([0-9]+)(.*)/ ) {

     print "Result: $prodcode,$custname,$qty,$cost,$date,$prodname\n";
} else {
     print "Failed to parse input file.\n";
     exit;
}




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

Date: Thu, 23 Dec 2004 22:59:05 +0800
From: sam <sam.wun@authtec.com>
Subject: Re: reg expression with input line
Message-Id: <cqeo1g$ch8$1@news.hgc.com.hk>

Anno Siegel wrote:

> sam  <sam.wun@authtec.com> wrote in comp.lang.perl.misc:
> 
>>Hi,
>>
>>I would like to write a perl script to parse each line read from a text 
>>file.
>>I ended up some perl code as shown below:
>>
>>($prodcode,$custname,$qty,$cost,$date,$prodname) =
>>         /^([0-9\-]+) +([A-Za-z0-9\-]+) +([0-9]+\.[0-9][0-9]) 
>>+([0-9]+\.[0-9][0-9])([0-9]+)(.*)/,
> 
> 
> Up to here, it looks like a regex of sorts, but what is this:
> 
> 
>>         "12031361          ABC3    567.00 
>>5177.6620041127\xbd\xba\xa6w\xc5@\xb9\xea\xb4f\xc5\xd6\xa5\xa9(\xacX\xb2n\xb4\xd6\
>>xbch)\xa4\xe9\xa5\xce12x20's";
> 
> 
>>print "Result: 
>>".$prodcode.",".$custname.",".$qty.",".$cost.",".$date.",".$prodname . "\n";
> 
> 
> Use string interpolation, not concatenation if there are lots of
> variables.  Better yet, collect the result in an array @data, then
> say
> 
>     print "Result: ", join( ',', @data), "\n";
> 
> 
>>if ($prodcode eq "" or $custname eq "" or $qty eq "" or $cost eq "" or 
>>$date eq ""  or $prodname eq "") {
>>    print "Failed to parse input file.\n";
>>    exit;
>>}
> 
> 
> ...and this could be written
> 
>     print "Failed to parse input file.\n" if grep length() == 0, @data;
> 
Thanks very much. This is very helpful indeed.

Thanks
Sam

> 
> 
> Anno


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

Date: Thu, 23 Dec 2004 23:04:07 +0800
From: sam <sam.wun@authtec.com>
Subject: return truely random number?
Message-Id: <cqeoau$cq0$1@news.hgc.com.hk>

Hi,

I tried Math::Random and Math::Random::MT, but none of them can generate 
turely random number when I executed the following code in a short time 
frame (twice in a second):

#!/usr/bin/perl

#use Math::Random;
use Math::Random::MT;

$gen = Math::Random::MT->new($seed); # OR... $gen = 
Math::Random::MT->new(@seed);

print $gen->rand(3)."\n";

#$random = random_uniform();
#$gmt = gmtime();

#print "Random: " . $random . "-" . $gmt . "\n";

I m trying to generate a transaction code for a data base table using 
the format of random-GMT

Another question is how can I generate a gmt time in the format 92783456 
instead of "Thu Dec 23 15:02:08 2004"?

Thanks
Sam


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

Date: Thu, 23 Dec 2004 10:53:54 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: return truely random number?
Message-Id: <LuSdnXOcc7iJd1fcRVn-hg@comcast.com>

sam wrote:

> Hi,
> 
> I tried Math::Random and Math::Random::MT, but none of them can generate
> turely random number when I executed the following code in a short time
> frame (twice in a second):

I might note that *no* random number generator generates "truly random"
numbers, because you can't get true random numbers from a deterministic 
procedure.  However, I assume your actual complaint is that you're not
getting back a suitable variety of pseudo-random numbers.
> 
> #!/usr/bin/perl

use warnings;
use strict;
> 
> #use Math::Random;
> use Math::Random::MT;
> 
> $gen = Math::Random::MT->new($seed); # OR... $gen =
> Math::Random::MT->new(@seed);

You never define a seed.  So you always create a 
random generator with a seed of "0", so you always get
the same sequence of psuedo-random numbers back.
Warnings and strict would've told you of this problem.
> 
> print $gen->rand(3)."\n";
> 
> #$random = random_uniform();
> #$gmt = gmtime();
> 
> #print "Random: " . $random . "-" . $gmt . "\n";
> 
> I m trying to generate a transaction code for a data base table using
> the format of random-GMT
> 
> Another question is how can I generate a gmt time in the format 92783456
> instead of "Thu Dec 23 15:02:08 2004"?

perldoc -f time

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 7560
***************************************


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