[18788] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 956 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 06:06:53 2001

Date: Tue, 22 May 2001 03:05:09 -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: <990525909-v10-i956@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 22 May 2001     Volume: 10 Number: 956

Today's topics:
        ANNOUNCE:  DDL::Oracle v1.10 <rvsutherland@yahoo.com>
    Re: Array slice: how about the remainder? <mischief@velma.motion.net>
    Re: Array slice: how about the remainder? nobull@mail.com
    Re: checking installed modules (Rafael Garcia-Suarez)
        converting characters in email <troyr@vicnet.net.au>
    Re: FAQ 5.1:   How do I flush/unbuffer an output fileha <goldbb2@earthlink.net>
    Re: file names into an array <pne-news-20010522@newton.digitalspace.net>
    Re: Handling JPEGs without modules <bart.lateur@skynet.be>
    Re: Help Please! <dtek@btinternet.com>
        How to store data in the session with perl? (Yannick)
    Re: image_button and onClick??? <flavell@mail.cern.ch>
    Re: Installing module not as root <pne-news-20010522@newton.digitalspace.net>
    Re: Multiple errors running newspro.cgi <goldbb2@earthlink.net>
        Newbie without a web server. <blaqwolf01@msn.com>
    Re: Newbie without a web server. <mischief@velma.motion.net>
    Re: Newbie without a web server. (Craig Berry)
    Re: oh c'mon please, one of you perl/unix gurus!!! (Steve)
    Re: ok problem solved, thx! Here's my SOLUTION in a sub <pne-news-20010522@newton.digitalspace.net>
        out of memory errors <dougdewalt@hotmail.com>
    Re: out of memory errors <benhopkins@Mindspring.com>
    Re: out of memory errors <dougdewalt@hotmail.com>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <goldbb2@earthlink.net>
    Re: Posting Guidelines for comp.lang.perl.misc ($Revisi <goldbb2@earthlink.net>
    Re: RegEx Problem, Please?! <peb@bms.umist.ac.uk>
    Re: Regexp to match IP Address <bart.lateur@skynet.be>
        Solaris help <Per-fredrik.Pollnow@epk.ericsson.se>
        Stringformation <Rene.Scheibe@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 22 May 2001 04:37:28 -0400
From: "Richard Sutherland" <rvsutherland@yahoo.com>
Subject: ANNOUNCE:  DDL::Oracle v1.10
Message-Id: <tgk9fjrjg0si4e@corp.supernews.com>

===========================================================================
                   Release of DDL::Oracle, Version 1.10
===========================================================================

CHANGES

Fixed bug #422926 regarding column aliases on CREATE VIEW.
The fix was supplied by ghelleks. THANKS, ghelleks!

Fixed bug #423336 regarding CREATE INDEX for partitioned
indexes on Oracle8.0.x.

Fixed a bug reported nearly concurrently by Sandor Toth and
Sano, regarding the DROP SYNONYM for non-public
synonyms.

Fixed another bug reported by Sandor Toth regarding CREATE
PROCEDURE [and other PL/SQL objects] wherein the
parameters might have followed the procedure name without a
space, as in:
   CREATE PROCEDURE foo(var1 IN VARCHAR2)...
Sandor also supplied the fix.  THANKS, Sandor!

And fixed yet another bug reported by Sandor Toth regarding
column DEFAULT values, which were missing in CREATE TABLE
statements.

And fixed one last bug reported by Sandor Toth regarding
CREATE TRIGGER statements on Oracle7 which included a
column list in an UPDATE trigger.  The technique being used
did not work on Oracle7.

Fixed a bug in type 'schema' wherein repeated calls had
messed with the period between schema and object name
[myschema.myobject].  The bug was reported and fixed
by Phillippe Daigremont.

THANKS to all for reporting these bugs and a special
thanks to ghelleks, Sandor and Phillippe for fixes.

SYNOPSIS

 use DBI;
 use DDL::Oracle;

 my $dbh = DBI->connect(
                         "dbi:Oracle:dbname",
                         "username",
                         "password",
                         {
                           PrintError => 0,
                           RaiseError => 1,
                         }
                       );

 # Use default resize and schema options.
 # query default DBA_xxx tables (could use USER_xxx for non-DBA types)

::Oracle->configure( 
                         dbh    => $dbh,
                  
     );

 # Create a list of one or more objects
 my $sth = $dbh->prepare(
        "SELECT
                owner
              , table_name
         FROM
                dba_tables
         WHERE
                tablespace_name = 'MY_TBLSP'    -- your mileage may vary
        "
     );

 $sth->execute;
 my $list = $sth->fetchall_arrayref;

 my $obj = DDL::Oracle->new(
                             type  => 'table',
                             list  => $list,                          );
                           );

 my $ddl = $obj->create;      # or $obj->resize;  or $obj->drop;  etc.

 print $ddl;    # Use STDOUT so user can redirect to desired file.

 # Here's another example, this time for type 'components'.  This type
 # differs from the norm, because it has no owner and no name.

 my $obj = DDL::Oracle->new(
                             type => 'components',
                             list => [[ 'no owner','no name' ]]
                           );

 my $ddl = $obj->create;

 print $ddl;


AUTHOR

Richard V. Sutherland
rvsutherland@yahoo.com

COPYRIGHT

Copyright (c) 2000, 2001 Richard V. Sutherland.  All rights reserved.
This module is free software.  It may be used, redistributed, and/or
modified under the same terms as Perl itself.  See:

    http://www.perl.com/perl/misc/Artistic.html

===========================================================================
                       AVAILABILITY
===========================================================================

DDL::Oracle is available from the CPAN, and from:

    http://sourceforge.net/projects/ddl-oracle/







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

Date: Tue, 22 May 2001 04:09:35 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Array slice: how about the remainder?
Message-Id: <tgjpjv9ac9lg2a@corp.supernews.com>

Mark Jason Dominus <mjd@plover.com> wrote:
> In article <9eaq4b$pej@netnews.hinet.net>,
> John Lin <johnlin@chttl.com.tw> wrote:
>>Dear all,
>>
>>I've been asked a quite interesting question.
>>
>>my @array = <NAMELIST>;
>>my @chosen = (0,3,5,7,21,35,63,66,68);
>>my @go_picnic = @array[@chosen];  # those who are chosen go picnic
>>my @stay_home = @array[???????];  # those who are not chosen stay home

This appears to be picnic invitation by lottery... We know
which elements are selected before we know which names fill
the elements.

> I don't know if this is worth doing:

I think it is.

>         my @stay_home = @array;
>         for (reverse @chosen) {
>           splice @stay_home, $_, 1 
>         }

> It's quadratic time in principle, but it's quite different from the
> other proposed solutions, and might nevertheless be faster than they
> are for practical cases.

I benchmarked against many versions of mine which used a marking loop
then a loop to push unmarked values onto the final array. As odd as it
may sound, the optimized Perl internal functions in yours beat out the
O(m+n) of my method every time.

I decided to test with rather large data sets, just to be sure. With
total items at 100_000 and chosen items at 150 (in a range of 100 and
a range of 50, although that shouldn't matter), yours beat mine even
more handily (factor of five instead of a factor of two).

Alternatively, one could choose to use a hash to mark what is used.
Using a hash, I came up at half the speed of yours at 100_000 items
total with 5.6.1 but only 25% slower with 5.5.3. Similar results
came at 10_000 items total. This is assuming that the @chosen array
is still an array and need sto be turned into a hash.

    my @stay_home = ();
    my %chosen = ();
    keys(%chosen) = @chosen;
    for( @array ) {
        unless( exists( $chosen{$_} ) ) {
            push @stay_home, $_;
        }
    }

I'd imagine it would be more efficient to write the thing as a hash
initially. ;-)

BTW, I _crashed_ Benchmark.pm at 1_000_000 data items.

    $ /usr/local/bin/perl try
    Benchmark: running hash, reverse_it, two_loops,
        each for at least 10 CPU seconds...
    Illegal division by zero at
        /usr/local/lib/perl5/5.6.0/Benchmark.pm line 584.

> However, I did not benchmark.

Sometimes your intuition speaks volumes to you that a benchmark
would only confirm. ;-)

I guess the moral is, if you're programming in a high-level
language, program at a high level. (Or help make the compiler
optimize your low-level apporach just as well ;-)

Chris

-- 
Get real!  This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental. -- nobull, clp.misc



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

Date: 22 May 2001 06:49:47 +0100
From: nobull@mail.com
Subject: Re: Array slice: how about the remainder?
Message-Id: <u9heye9blw.fsf@wcl-l.bham.ac.uk>

Joe Schaefer <joe+usenet@sunstarsys.com> writes:

> nobull@mail.com writes:
> 
> > "Godzilla!" <godzilla@stomp.stomp.tokyo> writes:
> > 
> > > my (@stay_home);
> > > my (@array) = (1 .. 20);
> > > my (@chosen) = (0, 2, 4, 6, 8, 10, 12, 14, 16, 18);
> > > foreach $chosen (@chosen)
> > >  {undef ($array[$chosen]); }
> > 
> > This can be more simply written using a slice:
> > 
> > undef @array[@chosen];
> 
> Actually, that's not the same as Godzilla's foreach loop.  undef() 
> will treat the slice as if it were in a scalar context,

Oops, that'll teach me to test even simple code before posting.

s/undef/delete/

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


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

Date: 22 May 2001 06:53:56 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: checking installed modules
Message-Id: <slrn9gk0bi.up.rgarciasuarez@rafael.kazibao.net>

yungp wrote in comp.lang.perl.misc:
} Hi,
} 
} I was wondering is there any command that I can type in Perl to check what
} modules (ie LWP, HTML parser, etc..) which I have installed already.

1. To check whether a particular module is installed, you can try to
load it :

  perl -MSome::Module -le 'print $Some::Module::VERSION'

2. The modules packaged with the MakeMaker tool (as the ones that you
can find on CPAN) write to a file 'perllocal.pod' during the
installation process. You can access this list by :

  perldoc perllocal

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 22 May 2001 15:58:19 +1000
From: "Troy Boy" <troyr@vicnet.net.au>
Subject: converting characters in email
Message-Id: <AhnO6.2181$Ld4.97212@ozemail.com.au>

Hi there,
            I have a form in html which passes the value of a textarea to a
perl script which emails out the value.

All works fine. However...users of the script copy and paste text from
Microsoft Word which has smart quotes in it. It displays fine on the
web..but when the user receives an email the smart quotes get converted to

&#8220;&#8221;

Is there some sort of encoding i can use or a work around that anyone knows
of?

Thanks in advance
--
----------------------------------------------------------------
Troy Rasiah
Melbourne, Aus




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

Date: Tue, 22 May 2001 02:44:32 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: FAQ 5.1:   How do I flush/unbuffer an output filehandle?  Why must I do this?
Message-Id: <3B0A0AD0.CD7E440D@earthlink.net>

PerlFAQ Server wrote:

>     Or using the traditional idiom:
> 
>         select((select(OUTPUT_HANDLE), $| = 1)[0]);
> 
>     Or if don't mind slowly loading several thousand lines of module
>     code just because you're afraid of the `$|' variable:
> 
>         use FileHandle;
>         open(DEV, "+</dev/tty");      # ceci n'est pas une pipe
>         DEV->autoflush(1);

Isn't DEV still a typeglob?  How does simply saying "use FileHandle"
magically make it into an object?  Am I missing something here?

Surely the FAQ should read:

	use FileHandle;
	$dev = new FileHandle "+</dev/tty";
	$dev->autoflush(1);

Or, if we want to at least *look* sort of like a typeglob:

	use FileHandle;
	{ my $fh = new FileHandle; sub DEV() { $fh } }

	open(DEV, "+</dev/tty");
	DEV->autoflush(1);

>     or the newer IO::* modules:
> 
>         use IO::Handle;
>         open(DEV, ">/dev/printer");   # but is this?
>         DEV->autoflush(1);

Again, DEV is used both as typeglob and as an object.  Unless some magic
which I don't know about is occuring, this is wrong.

>     or even this:
> 
>         use IO::Socket;               # this one is kinda a pipe?
>         $sock = IO::Socket::INET->new(PeerAddr => 'www.perl.com',
>                                       PeerPort => 'http(80)',
>                                       Proto    => 'tcp');
>         die "$!" unless $sock;
> 
>         $sock->autoflush();

This one at least properly treats the object as an object.

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Tue, 22 May 2001 07:06:16 +0200
From: Philip Newton <pne-news-20010522@newton.digitalspace.net>
Subject: Re: file names into an array
Message-Id: <ofsjgtofri37s75dvg8mcg613tg45j6qbn@4ax.com>

On Tue, 22 May 2001 00:30:08 +0000 (UTC), inwap@best.com (Joe Smith)
wrote:

> [<*.txt>] is the same as
>   @files = split /\0/,`csh -c "glob *.txt"`;

Not in current Perls, AFAIK (which do globbing internally).

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 22 May 2001 08:49:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Handling JPEGs without modules
Message-Id: <7v9kgtst3kd1qqnarkeednjckhv8hqm9n4@4ax.com>

Michael A. Krehan wrote:

>So... once again. Is there a pure-perl JPEG processor available somewhere?!
>I have not been able to find anything.

I wouldn't even begin to think of writing it.

The IJG source code for JPEG processing is a compressed archive of 600k
of C source code. You may want to rewrite it in perl, but I do not in
the least feel like doing it.

-- 
	Bart.


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

Date: Tue, 22 May 2001 07:41:03 +0100
From: "Darren Williams" <dtek@btinternet.com>
Subject: Re: Help Please!
Message-Id: <9ed1g9$nbq$1@uranium.btinternet.com>

I appreciate I missed the line out but they're providing me the code.  Its
just I can't used cgi, its asp on 2000 servers. I'm not going to amend their
code in any way, just rewrite it.

"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3u22etgjz.fsf@mumonkan.sunstarsys.com...
> "Darren Williams" <dtek@btinternet.com> writes:
>
> > Hi all,
> >
> > I hope someone can help please.
> >
> > I'm trying to interface my personal e-commerce attempt to a co that
accepts
> > credit cards. At an earlier date, I supply them a private key.
> > When I send them a transaction I pass a variable which is a random seed.
> > Once the transaction is processed I get a query string with a variable
> > called cbpop passed back to me.  Calling the sub below validates the
> > transaction, returning a value of 1 if its good.  I'd like to turn this
> > below into VB, could someone please explain whats happening here as I
know
> > no CGI or Perl.
> >
> > sub valid
> >  {
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
> I think you "forgot" to include something...
>
>      ### Copyright Keynetics Inc. Patents pending.
>
> Be sure you aren't first violating someone else's rights before you
> ask others to act in collusion.
>
> --
> Joe Schaefer    "Whenever you find you are on the side of the majority, it
is
>                                  time to pause and reflect."
>                                                --Mark Twain




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

Date: 22 May 2001 01:57:45 -0700
From: yburtin@freesurf.fr (Yannick)
Subject: How to store data in the session with perl?
Message-Id: <b245486b.0105220057.1bf27206@posting.google.com>

Hi,

In an html page with a perl script inside, I'd like to store a
variable in the session in order to access it later in another page.
How can I do that?

Thank you.

Yannick


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

Date: Tue, 22 May 2001 11:32:54 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: image_button and onClick???
Message-Id: <Pine.LNX.4.30.0105221104150.7298-100000@lxplus003.cern.ch>

On Tue, 22 May 2001, Scratchie wrote:

> Obviously, but the OP's question had nothing to do with CGI (the
> interface). He was trying to get CGI (the perl module) to do what he
> wanted it to.

But he failed to say what he wanted it to do, nor what trouble he was
having with it.  I don't know why I bother, but here's an action
replay:

| For some reason, I cannot get the onclick javascript action to work
| with CGI.pm's image_button.  Here is a sample of code:

(followed by some code without "use strict".  Arguably, as it's a CGI,
it should also have used -T, but let's put that aside for a moment).

If the hon. Usenaut does not realise that "onClick" is executed at the
client side, rather than the server side, then he's got some
non-Perl-related learning to do yet.  As such, it should be obvious
that anyone seriously interested in debugging the problem would review
the generated HTML, see how it stacked-up against what they expected,
and take it from there.

However, he failed to make any mention of what HTML he was aiming to
produce - what HTML he appeared to be getting from his script - and
any hint of what he thought might be wrong with it.  None of these
things have any direct relevance to Perl.

> OK, gotcha. But his question wasn't about any of those things. He was
> having problems getting the CGI module to do what he wanted.

| "cannot get the onclick javascript action to work".

But the WWW's interworking specification relates to the document
that's sent from the server to the client.  That is pivotal to the
whole endeavour, and as such, the hon. Usenaut's failure to say
anthing about it, leaving us to guess it from his code, gave a very
clear impression that he was looking in the wrong place.

> Given that
> it's a commonly-used standard module, that doesn't seem signficantly more
> off-topic that if he were having trouble getting "map" to do what he
> wanted, or if he were having trouble with a complicated regex.

Well maybe it will turn out that his problem was nothing more than
faulty Perl.  Who knows?  IMO he's done plenty to convince the group
that he's not interested in following normal trouble-shooting
procedures, and much more in stubbornly establishing his personal
presence; maybe he'll have the good fortune that someone can be
bothered to look behind the superficial impression.

The first Perl-relevant step, after sketching out what he's trying to
send from the server to the client, would be to apply the level of
checking that's considered de rigeur in this group, also to review
what's actually being emitted by the script, and take it from there.

But on the basis of what he's already posted, he gives the impression
that he hasn't done the relevant non-Perl-related groundwork yet, and
isn't willing to do so, so it'll be pure chance if he stumbles on the
answer (and what's more, it's unlikely to position him for successful
progress with the next problem, which in the long term is far more
important than this one single bug).

ttfn



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

Date: Tue, 22 May 2001 08:13:09 +0200
From: Philip Newton <pne-news-20010522@newton.digitalspace.net>
Subject: Re: Installing module not as root
Message-Id: <ndvjgt8av0jds5uve7u22m70d7bm72th5p@4ax.com>

On Mon, 21 May 2001 17:34:02 -0400, "Sparky" <tdyboc@insight.rr.com>
wrote:

> Is it possible to install a series of modules in a temporary
> directory to "test" with

Yes. See `perldoc -q "keep my own"`, for example, and also `perldoc
perlmodinstall`.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 22 May 2001 02:54:08 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multiple errors running newspro.cgi
Message-Id: <3B0A0D10.332851CF@earthlink.net>

RonB wrote:
> 
> I get these errors when I try to run this perl script. It's a wll
> known news management program that I use on Hypermart. I cant get it
> to work on my own server (apache) this is the output I get when I run
> it from console:
>    linux:/usr/local/httpd/cgi-bin/newspro # perl -w newspro.cgi
[snip]
> 
> Can anybody tell me what is going on here?

Lots and lots of warnings, probably due to it not having been written to
work with -w.  I would suggest two things: (1) pipe the warnings to a
file, and then run splain.  This will help you fix up newspro.cgi to
work with the warnings enabled.  (2) Try it without the -w flag!

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Tue, 22 May 2001 04:30:03 -0000
From: blaqwolf <blaqwolf01@msn.com>
Subject: Newbie without a web server.
Message-Id: <tgjqqbsl818e10@corp.supernews.com>

Is there any way that I can test my cgi scripts on my windows 98 system?

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Tue, 22 May 2001 05:05:01 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Newbie without a web server.
Message-Id: <tgjsrtkidpg40f@corp.supernews.com>

blaqwolf <blaqwolf01@msn.com> wrote:
> Is there any way that I can test my cgi scripts on my windows 98 system?

Your question basically equates to "Is there a web server that
runs on windows 98?"

There is:   www.xitami.com

There are a few other ways to test a CGI script, but using
a server that uynderstands CGI is still the best. Xitami
works pretty well. I still prefer Apache, but Xitami can
be up and running quickly for simple testing.

Now, what was your Perl question?

Chris

-- 



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

Date: Tue, 22 May 2001 05:05:16 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie without a web server.
Message-Id: <tgjsscev1jts1a@corp.supernews.com>

blaqwolf (blaqwolf01@msn.com) wrote:
: Is there any way that I can test my cgi scripts on my windows 98 system?

A couple of ways:

1) Install a web server to play with.  Apache is free and well-supported,
and Microsoft offers a free Personal Web Server which is a subset of IIS,
among other options. 

2) Simulate the environment in which you want your scripts to run (ENV
variables, stdin stream).  If you use CGI.pm to do your CGI-specific
coding, this is especially easy to do, as it automatically detects when it
is being used outside of a CGI context and allows you to enter parameters
on the command line or through stdin.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: 22 May 2001 06:16:09 GMT
From: steve@zeropps.uklinux.net (Steve)
Subject: Re: oh c'mon please, one of you perl/unix gurus!!!
Message-Id: <slrn9gji9e.607.steve@zero-pps.localdomain>

On Mon, 21 May 2001 02:39:55 GMT, Franco Luissi wrote:

>now i'm back to my original problem, where are the config files/ (how) can i get
>it to recognize the new perl...?

I thought you said you didn't have root access?

>you said it needs a rebuild/recompile, i was just asking (if/why?) a restart
>wouldn't do it ...

When you build apache it looks for perl, but if you have that kind of access
then why not just upgrade perl and rebuild apache?

I tried to mail you about this as it's a bit off topic, more about apache 
than perl, but the messages kept bouncing back. 

-- 
Cheers
Steve              email mailto:steve@zeropps.uklinux.net

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

  2:55am  up 109 days,  3:43,  2 users,  load average: 1.45, 1.28, 1.12


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

Date: Tue, 22 May 2001 07:06:11 +0200
From: Philip Newton <pne-news-20010522@newton.digitalspace.net>
Subject: Re: ok problem solved, thx! Here's my SOLUTION in a sub routine :-)
Message-Id: <cksjgtsrvev74ntqr5944dohtkhjfekabs@4ax.com>

On Sun, 20 May 2001 17:46:34 -0500, "Charles K. Clarkson"
<c_clarkson@hotmail.com> wrote:

> Lars <Lars.Plessmann@gmx.de> wrote:
> 
> :  1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
> 
>     Since the pattern includes the ^ anchor there is never
> more than 1 match, right?

Not more than one at a time, yes.

> So why the 1 while?

So that you keep reexamining the string for more places to put commas.

Here's an example: you want to commify 12345678 (12_345_678). The first
time through the substitution, you turn 12345678 into 12345,678 (the
greedy match \d+ goes all the way to the end, then backs off three
places so that \d{3} can match). But that's not complete, so you have to
do this again. This time, the greedy match consumes "12345" (and stops
there since the next character is not /\d/ but, rather, is a comma),
then gives up three characters so that \d{3} can match again. The result
is 12,345,678.

If you didn't have the "1 while", your "12345678" would turn into
"12345,678", which I wouldn't consider properly commified.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Tue, 22 May 2001 00:03:35 -0500
From: "Doug Dewalt" <dougdewalt@hotmail.com>
Subject: out of memory errors
Message-Id: <3b09f31c@news.csinet.net>

I have a simple script that parses through a log file and deletes a string.
And it works fine except that when I run it ageist a 60mb logfile it gives
an out of memory error. below is my code can some one help me out, and tell
me why, I am getting this error, and how I can fix it.

open (LOGFILE, $file);

foreach $line (<LOGFILE>) {
  while ($line =~ $string) {
     $line =~ s/$string//;
    }
  }
close (LOGFILE);




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

Date: Mon, 21 May 2001 22:21:00 -0700
From: Ben Hopkins <benhopkins@Mindspring.com>
Subject: Re: out of memory errors
Message-Id: <3B09F73C.156AB590@Mindspring.com>

Doug Dewalt wrote:
> 
> I have a simple script that parses through a log file and deletes a string.
> And it works fine except that when I run it ageist a 60mb logfile it gives
> an out of memory error. below is my code can some one help me out, and tell
> me why, I am getting this error, and how I can fix it.
> 
> open (LOGFILE, $file);
> 
> foreach $line (<LOGFILE>) {

Will this try to make an array out of the whole file 
at once?

Much better to say

while ($line = <LOGFILE>) {

That brings only one line at a time into memory.

>   while ($line =~ $string) {
>      $line =~ s/$string//;

Why don't you say 

$line =~ s/$string//g

instead of the while (did you forget the slashes?), 
followed by a substitute?


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

Date: Tue, 22 May 2001 01:19:54 -0500
From: "Doug Dewalt" <dougdewalt@hotmail.com>
Subject: Re: out of memory errors
Message-Id: <3b0a04fa$1@news.csinet.net>

That worked thanks a lot man.

"Ben Hopkins" <benhopkins@Mindspring.com> wrote in message
news:3B09F73C.156AB590@Mindspring.com...
> Doug Dewalt wrote:
> >
> > I have a simple script that parses through a log file and deletes a
string.
> > And it works fine except that when I run it ageist a 60mb logfile it
gives
> > an out of memory error. below is my code can some one help me out, and
tell
> > me why, I am getting this error, and how I can fix it.
> >
> > open (LOGFILE, $file);
> >
> > foreach $line (<LOGFILE>) {
>
> Will this try to make an array out of the whole file
> at once?
>
> Much better to say
>
> while ($line = <LOGFILE>) {
>
> That brings only one line at a time into memory.
>
> >   while ($line =~ $string) {
> >      $line =~ s/$string//;
>
> Why don't you say
>
> $line =~ s/$string//g
>
> instead of the while (did you forget the slashes?),
> followed by a substitute?




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

Date: Tue, 22 May 2001 02:07:14 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B0A0211.CFBE0F1C@earthlink.net>

Logan Shaw wrote:
> 
> In article <3afdbd7f@news.microsoft.com>,
> Jürgen Exner <juex@my-deja.com> wrote:
> >Please also consider that this is a world-wide NG.
> >People from outside the USA are likely to misunderstand "soft" advise
> >as mere suggestions. Don't use weak words like "may" or "should" or
> >"shall" unless you really mean the action/item is optional.
> >E.g. "You may not walk on the lawn" is nothing but a friendly
> >suggestion for many non-native English speakers. You may do so or you
> >may not do so. It's up to you.

If they misinterpret it as meaning that, it's their fault for not
understanding English.  When the word "may" is used in in an imperative
sentence, it generally means to have permission, either in the positive
sense (you may xxx == you have permission to xxx), or the negative (you
may not xxx == you do not have permission to xxx).  You may even choose
to use the word "may" to mean a strong suggestion, but that is not it's
primary meaning.

> >If you want people not to walk on the lawn then say so: "You must not
> >walk on the lawn".

How does "must not" differ from "do not have permission to" ?

It the same meaning but is slightly less polite.

> >Live American English has many subtleties and can be quite misleading
> >if you didn't grow up in this culture. In a world-wide NG if you want
> >to say something, then say it, but don't try to hide the real meaning
> >in politeness.

Only when used in the positive is the word "may" polite advice to do
something.  Look at the Mirriam-Webster online dictionary's definition,
1b: "to have permission to"

> >This politeness will be taken literally by many people outside
> >of the USA.
> 
> While I understand it might not be clear, it's not really politeness.
> It's an idiom.  I had to read "you may not walk on the lawn" several
> times before I could understand what alternate meaning you were
> talking about.

No, it's not really an idiom, because an idiom is a phrase whose meaning
cannot be derived from the meanings of the separate words.  The phrase
"may not" has a clear meaning from the meanings of the individual words
-- "to not have permission to."

> I think you are saying that native English speakers mean "you may
> choose not to walk on the lawn" when they say "you may not walk on the
> lawn".  This would be a way to say that, while one has the freedom to
> make either choice, a certain choice is suggested.
> 
> However, I have said "may not" thousands of times in my life, and I
> have never intended that meaning.  In fact, as I said, I wasn't even
> aware of that possible interpretation until I read your post.

Because the interpretation doesn't exist...  In situations for which the
word "may" means strongly suggest, giving permission is also a strong
suggestion.  E.g. "you may leave now" or "you have permission to leave
now"  (If your boss said either of these things after he'd had a chat
with you in his office, would you stay?).  The phrase "may not" has
never been merely a strong suggestion not to, any more than "you do not
have permission" might be merely a strong suggestion not to.

> Thanks for this example, by the way -- it is a very good example of a
> phrase that is subtlely idiomatic.  (Other phrases, like "hit the
> trail" are obviously idiomatic, but some, like this example, are much
> tougher to spot.)

I think I would call it ignoranmously idiomatic -- it's only an idiom if
you make up a meaning for the word "may" based on how you've heard it;
i.e. if you're an ignoramus.  (I would say it's ignorantly idiomatic,
except that it's not the phrase which is ignorant, but the person who
assigned such a bizarre meaning to it).

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Tue, 22 May 2001 02:18:29 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.1 $)
Message-Id: <3B0A04B5.F2960C20@earthlink.net>

Andras Malatinszky wrote:
[snip]
> >         One such searchable archive is
> >         <URL:http://www.deja.com/home_ps.shtml>.
> 
> How 'bout
> 
> http://groups.google.com/groups?hl=en&lr=&safe=off&group=comp.lang.perl.misc
> 
> instead?

I would shorten that to:

	http://groups.google.com/groups?group=comp.lang.perl.misc

Since the flags hl=en and safe=off aren't really required to do what you
want.  This is one of the things which I really hate about so many
search engines... the url often includes many things which simply aren't
necessary to get the particular search results for showing to other
people, making it necessary to carefully edit down the url for it to fit
in one line.

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Tue, 22 May 2001 09:31:34 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: RegEx Problem, Please?!
Message-Id: <3B0A23E6.AF1DAAD2@bms.umist.ac.uk>

Ren Maddox wrote:

<snip helpful explanation of bad code>

> > Why doesn't it work? Am I missing something?
> 
> In what way does it not work?  You haven't said what you expect.  You
> haven't said what the input data looks like.  You haven't said what
> the output data looks like.
> 
> Based on what you've given, all we can do is look for syntax errors or
> obvious logical errors.  We're going to need more than that to go on.

We do get a hint as to what the OP wants out of the code

>I want to get specific part out of a document.
<snip code>

we can then assume that the OP is reading a file and wants to parse out
a small part of it.  Hopefully that part is marked up in some unique
way.

I may be way off the mark but that's my interpretation of the situation.

Paul


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

Date: Tue, 22 May 2001 08:56:16 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Regexp to match IP Address
Message-Id: <v7akgtg2q92u7h3k3rqbm4n0lu3q4i1k2m@4ax.com>

Brandon Thornburg wrote:

>Can anyone help me with why this:
>
>(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})
>
>isn't matching an IP address?

First of all, it's not anchored.

But it can also match stuff like

	123.456.789.101

so the numbers needn't be in range for it to match.

That i s OK for me, as I consider this to be a semantic check, not a
syntactic one. So I'd do the checking of the numeric ranges in a second
step.

	my @ip;
	if(@ip = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/
	  and not grep { $_ > 255 } @ip) {
	    print "It's a match!";
	}


-- 
	Bart.


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

Date: Tue, 22 May 2001 11:24:09 +0200
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: Solaris help
Message-Id: <9edabj$ef$1@newstoo.ericsson.se>

Hi,

I need help from a SUN Solaris guru..

I have done a perl login script for my Solaris computer, and I want to exec
it before the real login prompt comes up (I don't won't to replace the real
login). I have tried /etc/default/telnetd with banner:

BANNER=" `perl script` "

This don't work

But this work

BANNER=" `echo hello` "

?????????????????????

Can someone  please help me ..





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

Date: Tue, 22 May 2001 10:51:24 +0200
From: "Rene Scheibe" <Rene.Scheibe@gmx.net>
Subject: Stringformation
Message-Id: <9ed987$29jhv$1@ID-65612.news.dfncis.de>

I have large numbers and for better reading
want to print a dot every third digit.
Anybody any suggestions?





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

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


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