[18775] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 943 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 20 06:06:00 2001

Date: Sun, 20 May 2001 03:05:08 -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: <990353107-v10-i943@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 20 May 2001     Volume: 10 Number: 943

Today's topics:
    Re: Closure: which variable does it refer to? <johnlin@chttl.com.tw>
        File listing on NT <reevehotNOSPAM@hotmail.com>
    Re: Handling JPEGs without modules (Honza Pazdziora)
        How does -t work? <goldbb2@earthlink.net>
    Re: HTTP Response suppression <pne-news-20010520@newton.digitalspace.net>
    Re: Hyphenated File Names <ewcoate@nighthawk.dyndns.org>
    Re: Hyphenated File Names (Abigail)
        I only want 2 digts behind the dot of a currency value (Lars)
    Re: I only want 2 digts behind the dot of a currency va (Clinton A. Pierce)
    Re: I only want 2 digts behind the dot of a currency va <ron@savage.net.au>
    Re: I only want 2 digts behind the dot of a currency va <krahnj@acm.org>
    Re: I only want 2 digts behind the dot of a currency va (Lars)
    Re: Image representation of a binary string <goldbb2@earthlink.net>
    Re: installing libwww-perl on Win 95 (Clinton A. Pierce)
    Re: Levels of perl programming <goldbb2@earthlink.net>
    Re: Levels of perl programming <pne-news-20010520@newton.digitalspace.net>
    Re: Levels of perl programming <goldbb2@earthlink.net>
    Re: match a range of number <aqumsieh@hyperchip.com>
    Re: nested pattern (Robert Vazan)
        ok problem solved, thx! Here's my SOLUTION in a sub rou (Lars)
    Re: Perl and Java Native Interface (Mick Barry)
        Perl CGI - Get and Post = Redirected ! Help? (hopeless programmer)
    Re: regexp: delete everything between <?  ... ?> (fe)
    Re: Searching for Postal Code (J. Cooper)
    Re: Searching for Postal Code <pne-news-20010520@newton.digitalspace.net>
        XMLout() produces non-well-formed XML <dn131@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 20 May 2001 12:33:08 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Closure: which variable does it refer to?
Message-Id: <9e7glv$djn@netnews.hinet.net>

"Logan Shaw" wrote:
> As a test for that theory, I wrote this code:
> my $x;
> @x = 1 .. 3;
> foreach $x (@x) { $print = sub { print $x } }
> $x[$#x] = 42;
> $print->();
> And sure enough, it prints "42".

According to the "aliasing" theory, we will predict the following program

# exactly the same as yours, except that the first line "my $x" is removed
@x = 1 .. 3;
foreach $x (@x) { $print = sub { print $x } }
$x[$#x] = 42;
$print->();

prints "42", right?  But it doesn't.
Use of uninitialized value in print at line 2.

So, only lexical $x does "aliasing" but local $x doesn't
(it does local "value copy"), right?  Not so consistent.

Thank you.

John Lin





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

Date: Sun, 20 May 2001 15:56:39 +1000
From: "James R" <reevehotNOSPAM@hotmail.com>
Subject: File listing on NT
Message-Id: <c%IN6.1236$Ld4.52094@ozemail.com.au>

I have a site search script which says (in part):

$ls = `ls $file`; # Where $file is something like "*.htm"

I believe ls is the directory listing function on a Unix system, however I
run on an NT server and this command seems not to work.

Is there an equivalent to ls on Windows systems?




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

Date: Sun, 20 May 2001 09:38:21 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Handling JPEGs without modules
Message-Id: <slrn9gf459.2j39.adelton@nemesis.fi.muni.cz>

On Fri, 18 May 2001 23:01:48 +0200, Michael A. Krehan <ebo_mike-antispam-remove-t@hottmail.com> wrote:
> 
> PROBLEM is that my hoster won't allow me to install modules. The only
> available module is GD 1.19 which is incapable of handling JPEGs - the only
> format I really need.

How would the hoster know, if you install a Perl script (*.pl) or Perl
module (*.pm)? Shouldn't your question better be rephrased as "how to
install all those great standard modules from CPAN to nonstandard
place, if my hoster won't do the installation for me and I obviously
don't have permissions to write to system-wide library directories"?

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
 .project: Perl, mod_perl, DBI, Oracle, auth. WWW servers, XML/XSL, ...
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------


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

Date: Sun, 20 May 2001 05:05:05 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: How does -t work?
Message-Id: <3B0788C1.CCEFC397@earthlink.net>

How does the -t operator determine that the passed filehandle is a
terminal as opposed to a file or socket?  Does perl ever make a mistake
with this?

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


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

Date: Sun, 20 May 2001 08:21:00 +0200
From: Philip Newton <pne-news-20010520@newton.digitalspace.net>
Subject: Re: HTTP Response suppression
Message-Id: <a8oegtsim8dbrnl5ru283vd4htbmfasiad@4ax.com>

On Sat, 19 May 2001 15:40:50 -0700, "Elmer Fudd" <elmer_fudd@yahoo.com>
wrote:

> I am using 2 things, HTML...and Perl. HTML doesn't generate extreneous
> headers...so it's a Perl issue *shrug*.

Here's an example:

    $pi = 22 / 7;
    print "pi is $pi\n";

This prints:

    pi is 3.14285714285714

Now, as you know, that's not accurate; it's wrong starting at the third
decimal place. I output this value with Perl. Is it a Perl problem?

> My script is not printing 'any' headers and therefore I can't 'just
> remove what I don't want'.

[snip]

> print "Content-type: text/html\n\n";

And this is what? A footer?

> I also get the following returned:
> 
> HTTP/1.1 200 OK Date: Sat, 19 May 2001 22:25:14 GMT Server:
> Microsoft-IIS/5.0 Content-type: text/html
> Currently 1 connections
> 
> The response of 200 tells me it's a HTTP Reponse *shrug*.

Here's a hint. Write a C program something like the following:

    #include <stdio.h>
    int main(void) {
        printf("Content-type: text/html\n\n");
        printf("Currently %d connections\n", 1);
        return 0;
    }

Then call that with "exec cgi" from the SSI page.

If you get the HTTP/1.1 200 OK etc. headers, looks like the switch from
Perl to C didn't change anything. So it must be something besides the
language you chose to write your CGI script in.

> Any help is appreciated, this could be a server admin setup issue for all I
> know.

I suspect your problem is with an understanding of (a) CGI, (b) SSI,
and/or (c) the web server you chose to use. I suggest asking again in a
group appropriate to one of the above.

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: Sun, 20 May 2001 03:15:24 GMT
From: Ed Coates <ewcoate@nighthawk.dyndns.org>
Subject: Re: Hyphenated File Names
Message-Id: <8dbegt8rjt0q2h3dshr06s87o4u73qn4dc@4ax.com>

On Sat, 19 May 2001 09:47:13 +0000 (UTC), abigail@foad.org (Abigail)
wrote:

Here's the snippet of code and here's the error.  I'm runing perl
5.6.0 and the problem is that when I pass the hyphenated machinename
into the variable, perl subtracts the two halves, comes up with 0 and
I get the following errors:

Unquoted string "ers" may clash with future reserved word at
 ./test2.pl line 5.
Argument "prod" isn't numeric in subtraction (-) at ./test2.pl line 5.
Argument "ers" isn't numeric in subtraction (-) at ./test2.pl line 5.
Can't open 0.latest.status:  No such file or directory at ./test2.pl
line 7.

When I quote the machine name, it's now working as it should.

@test=(ers-prod);    <--Quoting this like  @test=("ers-prod");   works
foreach $line (sort @test) {

open(STATUS,"/usr/local/httpd/htdocs/reports/$line.latest.status") ||
die "Can't open $line.latest.status:  $!";
        chomp(@status=<STATUS>);
        close (STATUS);

        foreach $entry (@status) {
                ($hostname,$date,$stats)=split(/\;/,$entry);
                if ($stats !~ /\=/) {
                        $date = "<FONT COLOR=DARKRED>Please Re-Run
Check Scripts to Comply with Latest Updates</FONT>" ;
                }
        }
        print "<TR>";
        print "<TD WIDTH=100
BACKGROUND=/images/tile02.gif><CENTER><FONT SIZE=2 COLOR=DARKBLUE><A
HREF='http://standards.corp.
amrcorp.com/cgi-bin/eac_reports/report_gen.pl?mode=print_check&check=/usr/local/Web/eac_reports/$line.latest.check&machine=$li
ne'>$hostname</A></FONT></CENTER></TD>";
        print "<TD WIDTH=100
BACKGROUND=/images/tile02.gif><CENTER><FONT SIZE=2
COLOR=DARKBLUE>$date</FONT></CENTER></TD>";
}
>Ed Coates (ewcoate@nighthawk.dyndns.org) wrote on MMDCCCXVIII September
>MCMXCIII in <URL:news:8f7cgt0a0cujoalp35mejupkapfo1v0d7u@4ax.com>:
>\\  I'm using perl 5.00_02 work and was wondering if it has problems with
>\\  opening files using scalar variables containing hyphenated file names.
>
>Did you try? Do you have some lines of code showing the problem?  What's
>the value of $! ? Did you use -w? And strict? Wouldn't you think that if
>it turned out to be a problem, it was fixed in 5.005_03, 5.6.0 or 5.6.1,
>and you could read the Changes files of those releases to find out?
>
>
>
>Abigail



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

Date: Sun, 20 May 2001 09:48:11 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Hyphenated File Names
Message-Id: <slrn9gf4mr.m3c.abigail@tsathoggua.rlyeh.net>

Ed Coates (ewcoate@nighthawk.dyndns.org) wrote on MMDCCCXIX September
MCMXCIII in <URL:news:8dbegt8rjt0q2h3dshr06s87o4u73qn4dc@4ax.com>:
``  On Sat, 19 May 2001 09:47:13 +0000 (UTC), abigail@foad.org (Abigail)
``  wrote:
``  
``  Here's the snippet of code and here's the error.  I'm runing perl
``  5.6.0 and the problem is that when I pass the hyphenated machinename
``  into the variable, perl subtracts the two halves, comes up with 0 and
``  I get the following errors:
``  
``  Unquoted string "ers" may clash with future reserved word at
``  ./test2.pl line 5.
``  Argument "prod" isn't numeric in subtraction (-) at ./test2.pl line 5.
``  Argument "ers" isn't numeric in subtraction (-) at ./test2.pl line 5.
``  Can't open 0.latest.status:  No such file or directory at ./test2.pl
``  line 7.
``  
``  When I quote the machine name, it's now working as it should.


What made you think you didn't have to quote the filename in the
first place? -w and 'use strict' are your friends.



Abigail
-- 
perl -we '$| = 1; $_ = "Just another Perl Hacker\n";  print
          substr  $_ => 0, 1 => "" while $_ && sleep 1 => 1'


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

Date: Sun, 20 May 2001 01:13:47 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: I only want 2 digts behind the dot of a currency value
Message-Id: <3b0718d7.9216162@news.btx.dtag.de>

Ive got the value
25.2525
or
25 e.g.

these values should become to:
25.2525 -> 25,25
25 -> 25,00

here's my current ugly code. maybe someone can help me and improve it.
at the moment it merely adds the zero(s) at the end if neccesairy.
but how to remove the redundant digts?

 $idx=-1;
 $idx=rindex($_,".");
 if($idx==-1) { $_=$_.".-"; }
 else 
 { 
  if($idx==0) { $_=$_."-"; }
  if($idx==1) { $_=$_."0"; }
 }

 # The German form: dots to comma and comma to dots
 $_=~s/\./D/;
 $_=~s/,/\./;
 $_=~s/D/,/;



thx,
Lars


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

Date: Sun, 20 May 2001 02:01:09 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: I only want 2 digts behind the dot of a currency value
Message-Id: <FzFN6.52050$V5.9737513@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <3b0718d7.9216162@news.btx.dtag.de>,
	Lars.Plessmann@gmx.de (Lars) writes:
> these values should become to:
> 25.2525 -> 25,25
> 25 -> 25,00

You're hunting squirrels with an elephant gun.  Here, try sprintf:

	$_=sprintf("%.02f", $_);  # You get rounding for free!
	s/\./,/;   		  # Change decimal to comma.

[Question to others: does having locale in effect cause perl to use , 
instead of . in the correct way?  Don't have a functional European locale 
handy to test this..]

> here's my current ugly code. maybe someone can help me and improve it.
> at the moment it merely adds the zero(s) at the end if neccesairy.
> but how to remove the redundant digts?

Redundant?  Do you mean extra digts or something else?

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sun, 20 May 2001 18:34:27 +1000
From: "Ron Savage" <ron@savage.net.au>
Subject: Re: I only want 2 digts behind the dot of a currency value
Message-Id: <uuKN6.1273$Ld4.53309@ozemail.com.au>

See below

--
Cheers
Ron  Savage
ron@savage.net.au
http://savage.net.au/index.html

> $_=sprintf("%.02f", $_);  # You get rounding for free!
> s/\./,/;     # Change decimal to comma.
>
> [Question to others: does having locale in effect cause perl to use ,
> instead of . in the correct way?  Don't have a functional European locale
> handy to test this..]

Do you realize that sprinf can round both up and down, depending on the magnitude of the value, as per the C language specs?

Also, I believe sprintf will ignore locale.

Conclusion: Use the Perl module: Math::Currency





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

Date: Sun, 20 May 2001 08:47:23 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: I only want 2 digts behind the dot of a currency value
Message-Id: <3B0784AC.69C9B244@acm.org>

Lars wrote:
> 
> Ive got the value
> 25.2525
> or
> 25 e.g.
> 
> these values should become to:
> 25.2525 -> 25,25
> 25 -> 25,00
> 
> here's my current ugly code. maybe someone can help me and improve it.
> at the moment it merely adds the zero(s) at the end if neccesairy.
> but how to remove the redundant digts?
> 
>  $idx=-1;
>  $idx=rindex($_,".");
>  if($idx==-1) { $_=$_.".-"; }

if ( $idx == -1 ) { $_ .= ".-" }

>  else
>  {
>   if($idx==0) { $_=$_."-"; }
>   if($idx==1) { $_=$_."0"; }

if ( $idx == 0 ) { $_ .= "-" }
if ( $idx == 1 ) { $_ .= "0" }

>  }
> 
>  # The German form: dots to comma and comma to dots
>  $_=~s/\./D/;
>  $_=~s/,/\./;
>  $_=~s/D/,/;

You can replace those three lines with:
tr/,./.,/;
It will translate both ways.
$ perl -le '$_ = "2,036,168.65"; print; tr/,./.,/; print; tr/,./.,/;
print;'
2,036,168.65
2.036.168,65
2,036,168.65


John
-- 
use Perl;
program
fulfillment


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

Date: Sun, 20 May 2001 09:13:56 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: Re: I only want 2 digts behind the dot of a currency value
Message-Id: <3b078a84.563090@news.btx.dtag.de>

On Sun, 20 May 2001 02:01:09 GMT, clintp@geeksalad.org (Clinton A.
Pierce) wrote:

>[Posted and mailed]
>
>In article <3b0718d7.9216162@news.btx.dtag.de>,
>	Lars.Plessmann@gmx.de (Lars) writes:
>> these values should become to:
>> 25.2525 -> 25,25
>> 25 -> 25,00
>
>You're hunting squirrels with an elephant gun.  Here, try sprintf:
>
>	$_=sprintf("%.02f", $_);  # You get rounding for free!
>	s/\./,/;   		  # Change decimal to comma.
>
>[Question to others: does having locale in effect cause perl to use , 
>instead of . in the correct way?  Don't have a functional European locale 
>handy to test this..]
>
>> here's my current ugly code. maybe someone can help me and improve it.
>> at the moment it merely adds the zero(s) at the end if neccesairy.
>> but how to remove the redundant digts?
>
>Redundant?  Do you mean extra digts or something else?
>
>-- 
>    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
>  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
>"If you rush a Miracle Man,     for details, see http://geeksalad.org     
>	you get rotten Miracles." --Miracle Max, The Princess Bride

thx, i know i mad it really complicate ;-)

problem: now all dots will be translated to comma, but comma not to
dots! so at the end i merely have comma in my value.


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

Date: Sat, 19 May 2001 22:20:31 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Image representation of a binary string
Message-Id: <3B0729EF.30CE9FBD@earthlink.net>

Jonathan Stowe wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
[snip]
> > A smart version would even test if there's an if-modified-since
> > field in the http request header, and respond that the image is good
> > if it's more recent than the file modification date of the cgi
> > script (so caches will work right -- there are so many cgis which
> > stupidly always regenerate data no matter what, even if it's not
> > needed).
> 
> Er, right.  So how can we help you precisely ?  And you have looked at
> the steganography stuff in Image::Magick ?

Umm.  If it wasn't obvious... how do I get at the if-modified-since
header via CGI?  Is there anything in CGI.pm for this?

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


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

Date: Sun, 20 May 2001 02:02:42 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: installing libwww-perl on Win 95
Message-Id: <6BFN6.52052$V5.9738787@news1.rdc1.mi.home.com>

[Posted and mailed]

In article <e3663770.0105191554.2ae4cdb1@posting.google.com>,
	devs@usa.net (devs) writes:
> I don't have a clue.
> Could someone kindly help me?

Download the appropriate ZIP file bundle from Activestate, open it up 
and there's a README with instructions in it.  Try that.

-- 
    Clinton A. Pierce              Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org         Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Sat, 19 May 2001 21:56:47 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Levels of perl programming
Message-Id: <3B07245F.73E63DE8@earthlink.net>

Scott R. Godin wrote:
[snip]
> 10.a. knows why $var = Method->new; is preferred over $var = new
> Method;

This is one of the things which I don't get... somebody want to explain
it to me?  I *think* that it has to do with inheritance or dynamic vs
static binding or somesuch, but I might be mistaken.

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


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

Date: Sun, 20 May 2001 08:41:01 +0200
From: Philip Newton <pne-news-20010520@newton.digitalspace.net>
Subject: Re: Levels of perl programming
Message-Id: <chpegtsip1q7uiuok1lpt8nhgpuqe6aul7@4ax.com>

On Sat, 19 May 2001 21:56:47 -0400, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

> Scott R. Godin wrote:
> [snip]
> > 10.a. knows why $var = Method->new; is preferred over $var = new
> > Method;
> 
> This is one of the things which I don't get... somebody want to explain
> it to me?  I *think* that it has to do with inheritance or dynamic vs
> static binding or somesuch, but I might be mistaken.

It definitely has something to do with problems if you have a sub new in
scope, or a sub Method.

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: Sun, 20 May 2001 05:58:05 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Levels of perl programming
Message-Id: <3B07952D.1B8D2E3A@earthlink.net>

Philip Newton wrote:
> 
> On Sat, 19 May 2001 21:56:47 -0400, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
> 
> > Scott R. Godin wrote:
> > [snip]
> > > 10.a. knows why $var = Method->new; is preferred over $var = new
> > > Method;
> >
> > This is one of the things which I don't get... somebody want to
> > explain it to me?  I *think* that it has to do with inheritance or
> > dynamic vs static binding or somesuch, but I might be mistaken.
> 
> It definitely has something to do with problems if you have a sub new
> in scope, or a sub Method.

So if you're inside of package Foo, which happens to have a sub new, and
you want to create a new instance of a Bar, you have to call "Bar->new",
because trying to do "new Bar" will call your own "new", rather than
Bar's "new".

That makes sense, I guess.

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


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

Date: 20 May 2001 03:19:03 -0400
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: match a range of number
Message-Id: <m3ofsolc7s.fsf@alquds.qumsieh.homeip.net>


> According to Rudolf Polzer <eins@durchnull.de>:
> > Rudolf Polzer <eins@durchnull.de> wrote:
> > > Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > > > According to DT <same@make-it-online.com>:
> > > > > Hi,
> > > > > 
> > > > > Can I use a single matching to do:
> > > > > 
> > > > > (($i > 123) && ($i < 456))
> > > > 
> > > > If by "single matching" you mean "123 < $i < 456", no.   Few
> > > > programming languages support this construct.  It's just too
> > > > handy to implement comparison as an infix operator.
> > > 
> > > Pascal supports
> > > 
> > > if i in [3..8] then begin ... end;
> > > 
> > > while 3..8 is a set. But not really because i has to be a small 
> > > ordinal type (no float).
> > 
> > I wanted to say: There are languages that support this.
> 
> Support what?  The "123 < $i < 456" syntax?  No.

Actually, I believe that Python does support this syntax. It's one of
the few cool features of Python that I'd like to see make its way into
Perl 6.

--Ala


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

Date: Sun, 20 May 2001 19:00:49 GMT
From: robova@nextra.sk (Robert Vazan)
Subject: Re: nested pattern
Message-Id: <3b08080e.597394@news.nextra.sk>

James freeman <jfreeman@tassie.net.au> wrote:
>Robert Vazan wrote:
>> What do you do with nested patterns? I mean something like:
<like snipped>

>1 Specify what you are trying to do and in what context.

I have pascal source full of procedures. I want it divided
into scalars containing individual procedures. These can be
later divided this way or tested with regexps.

>2 Supply some REAL sample data demonstrating  the problem data set. Real data is
>vital as pattern matching is tailored around it.

procedure init_db;
begin
   { snipped 150 lines }
   with t[cassidy_s_toy_store_bt] do begin
      name:='Cassidy''s Toy Store';
      { >>> note funny pascal backslashing, '' becomes ' }
      price:=10000;
      { ... }
   end;
   with t[restaurant_at_end_of_galaxy_bt] do begin
      name:='Restaurant at End of Galaxy';
      price:=200000;
      { ... }
   end;
   { snipped 500 lines }
end;

If I replace 'at End' with 'at Begin', then quoting unaware
code fails.

>3 Show us what you have tried, or if you do not know where to start, indicate
>exactly what you want to achieve from your pattern.

FAQ advices writing specialized parser, but I don't want to
write complete parser nor manipulate complex parse tree. To
this point I used regexps on suitable procedures and
filtering others by hand.

>If by some chance I have correctly interpretted that you want to find the
>closing bracket in a nested bracket case such as:
>
>'foo( () \( () ((\))))bar'
>
>where the nesting is complicated by backslashed brackets then this sub will
>return a regex that matches any complex bracket pattern.

Well, you missed quotes (like 'hello' or perlian m@boo@).
Backslashing happens inside quotes.

>$matching_regex = &bracket_finder($opening_bracket, $search_string);
>$search_string =~ s/($matching_regex)//;

Hmm, if I can afford to call counting sub, then I can let it
do string manipulation also. No need for regexp then.

>sub bracket_finder {
<snip>
>}

Actually, I was going to write such counter. But I hoped,
there is something simpler like tricky regexp or module or
something.

Anyway, thanks.

/Robert



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

Date: Sun, 20 May 2001 09:22:31 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: ok problem solved, thx! Here's my SOLUTION in a sub routine :-)
Message-Id: <3b078ca5.1107801@news.btx.dtag.de>

sub MoneyFormat
{
 # currency format adding commas for easy read
 my $buf=0;
 local $_ = shift;
 1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
 
 # rounding the currency
 $_=sprintf("%.02f", $_); 

 # Change dots to comma and comma to dots (German form)
 tr/,./.,/;  

 return $_;
}

thx a lot,
Lars


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

Date: Sun, 20 May 2001 01:22:26 GMT
From: mick@objects.com.au (Mick Barry)
Subject: Re: Perl and Java Native Interface
Message-Id: <3b072a37$0$25475$7f31c96c@news01.syd.optusnet.com.au>

Here are some links:

http://www.oreilly.com/catalog/prkunix/excerpt/UGch03.html
http://www.ddj.com/articles/1999/9902/9902f/9902f.htm?topic=perl
http://theoryx5.uwinnipeg.ca/CPAN/data/JPL/README.html

Hope they help.

Mick Barry
Brainbench MVP for Java 1
http://www.brainbench.com

http://www.objects.com.au


In article <aiCN6.31604$i56.8927429@typhoon.southeast.rr.com>, "Kevin B" 
<kbass1@nc-rr.com> wrote:
>Does anyone have some sample code showing Perl and Java Native Interface
>(JNI) interacting with each other?
>
>Kevin
>
>


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

Date: Sun, 20 May 2001 08:15:25 GMT
From: n-a@rocketmail.com (hopeless programmer)
Subject: Perl CGI - Get and Post = Redirected ! Help?
Message-Id: <3b07739e_1@news3.nntpserver.com>

I am trying to use Net::SSLeay to post and get remote scripts and parse the 
results.
Apparently, the target script replies with a redirection of some sort.

HTTP/1.1 302 Object moved

When I print the results to the browser, I get "object moved. the object may 
be located here." with a link to another script, with new query string data.
I click the link, but the next page comes up with it's own custom generated 
error.
I just need someone to tell me in plain english how to get this to work! I 
have read the http standards and other docs, but just don't get it. What am I 
supposed to be "reposting" or "regetting" and from where, and do I set/read 
some cookie, pass headers, create new ones? I'm stuck.
The header fields that I get back in my %headers are:
(values not included here)

Location
Content-Type
pragma
Date
Set-Cookie
Server
Cache-control

Here is the simple example:
##################

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";

use Net::SSLeay;

($page, $reply, %headers) = Net::SSLeay::get_https('secure.server.com', 443, 
'/folder/script.asp?querydata&data&data');

print $page;

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

I would appreciate any help that anyone can give.
Thanks,
Mike


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

Date: Sun, 20 May 2001 02:28:11 +0000 (UTC)
From: f.galassi@e-mind.it (fe)
Subject: Re: regexp: delete everything between <?  ... ?>
Message-Id: <066ab0428021451MAIL4@galactica.it>

$line   =~ s/<\?.*?\?>/ /sg;


-- 
Posted from mail4.galactica.it [212.41.208.21] 
via Mailgate.ORG Server - http://www.Mailgate.ORG


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

Date: Sun, 20 May 2001 04:20:56 GMT
From: jean.coopernyetspam@sympatico.ca (J. Cooper)
Subject: Re: Searching for Postal Code
Message-Id: <3b07456c.45506555@news1.on.sympatico.ca>

Thanks Andras, it worked like a charm.  I can't recall where I got the
idea for ARGV[0], I'm just learning Perl, so everything's still a bit
muddled, but I learned a lot from your reply.

Jean


On Fri, 18 May 2001 17:05:04 -0400, Andras Malatinszky
<andras@mortgagestats.com> wrote:

>
>
>Jean Cooper wrote:
>> 
>> Hi,
>> 
>> I'm trying to search through some text and find the Postal Code
>> (Canadian).  The form of the PC is M4M 2B2.  So I wrote a little Perl
>> script, which isn't working too well.  If anyone can let me know where
>> I've gone wrong, I'd appreciate it.
>> 
>> open (PC, "PCFile.txt") or die "Can't find file\n";
>> 
>> if ($ARGV[0] =~ s/[a-z][0-9][a-z]\s[0-9][a-z][0-9]/i   {
>> 
>>         print "Found something that resembles a Postal Code\n"
>> 
>> }
>> 
>> Jean
>
>Couple of things:
>
>1) Presumably your postal codes are hidden somewhere in PCFile.txt and
>not on the command line, so you should not be looking for them i
>$ARGV[0].
>
>2) You want the m// operator, not s/// in the pattern match, right?
>
>3) The left parenthesis after the if is unmatched.
>
>How about something like this:
>
>while (<DATA>){
>
>	if (m/[a-z][0-9][a-z]\s[0-9][a-z][0-9]/i)   {
>		print "Found something that resembles a Postal Code in this line:\n
>$_\n"
>	};
>};
>__DATA__
>This is almost like a Postal Code: M3Q8U9 are you sure you want to
>exclude it?
>This is a good one: I9U 7U7.
>Oops, here's a false match (has a tab instead of a space in the middle):
>R4T	7Q1
>Another kosher one: U6Y 8H9.
>
>When I run it, I get:
>
>C:\WINDOWS\Desktop>perl -w match.pl
>Found something that resembles a Postal Code in this line:
> This is a good one: I9U 7U7.
>
>Found something that resembles a Postal Code in this line:
> Oops, here's a false match (has a tab instead of a space in the
>middle): R4T
>7Q1
>
>Found something that resembles a Postal Code in this line:
> Another kosher one: U6Y 8H9.
>
>
>Minor details:
>
>It's good practice to check the results of a file open, but it's even
>better to include $! in the error message. "Can't find file" may not be
>the real reason why your file open failed. (Maybe you don't have the
>right privileges?)
>
>You may also want to think about what kind and what amount of white
>space you will allow between the two blocks of three characters.



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

Date: Sun, 20 May 2001 08:08:49 +0200
From: Philip Newton <pne-news-20010520@newton.digitalspace.net>
Subject: Re: Searching for Postal Code
Message-Id: <ppnegtkci45dh576q2uqpb18v48khv147r@4ax.com>

On Sat, 19 May 2001 16:05:18 GMT, mjd@plover.com (Mark Jason Dominus)
wrote:

>   my %l2p

Can't use global %12 in "my" at -e line 1, near "my %12"
Bareword found where operator expected at -e line 1, near "%12p"
        (Missing operator before p?)
syntax error at -e line 1, near "%12p "
Bareword found where operator expected at -e line 1, near "$12p"
        (Missing operator before p?)
Execution of -e aborted due to compilation errors.


Don't you test your code before posting? :) :) :)

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: 20 May 2001 01:35:58 -0700
From: David Wake <dn131@yahoo.com>
Subject: XMLout() produces non-well-formed XML
Message-Id: <9nbsool8nl.fsf@Turing.Stanford.EDU>

I am using XML::Simple to write XML to a file using XMLout().  When I
try to read the file in again using XMLin(), I get the error message

not well-formed (invalid token) at line 2, column 16, byte 22 at
/usr/lib/perl5/site_perl/5.6.0/i386-linux/XML/Parser.pm line 185

I am sure this is because the values in the database I am writing
using XMLout() are strings taken from webpages, and I assume that they
contain non-permissible characters.  Is there any way to get around
this problem?  Perhaps a method which wraps the offending text in
CDATA?

Thanks,

David





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

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


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