[17074] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4486 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 2 00:13:04 2000

Date: Sun, 1 Oct 2000 21:10:14 -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: <970459814-v9-i4486@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 1 Oct 2000     Volume: 9 Number: 4486

Today's topics:
        prblem with compiling sources under NT <schrader@cs.tu-berlin.de>
        Regex comparing street addresses <peter.sundstrom@eds.com>
    Re: Regex comparing street addresses <godzilla@stomp.stomp.tokyo>
    Re: Regex comparing street addresses <bwalton@rochester.rr.com>
    Re: starting with perl. <bwalton@rochester.rr.com>
    Re: starting with perl. <varat@ix.netcom.com>
    Re: starting with perl. <bwalton@rochester.rr.com>
        string indexing (Joshua Haberman)
    Re: string indexing ebohlman@omsdev.com
    Re: string indexing <bmb@ginger.libs.uga.edu>
        UPgrade to 5.6.0 and mod_perl_problems (Konstantinos Agouros)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 2 Oct 2000 01:14:18 GMT
From: Gunnar Schrader <schrader@cs.tu-berlin.de>
Subject: prblem with compiling sources under NT
Message-Id: <8r8nha$6gf$1@news.cs.tu-berlin.de>

Hi,

I was trying to compile the sources for Perl 5.6.0 available via www.cpan.org. Unfortunately it ended with a try to run Configure:
  F:\PROGRA~1\perl\PERL-5~1.0>./Configure 2>&1 | tee log.configure
  Program too big to fit in memory
Any other suggestion then bying new memory or downloading the binaries? I'm using 80 MB with Windows NT. Is that not enough?

Thanks for help

Gunnar


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

Date: Mon, 2 Oct 2000 14:30:15 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Regex comparing street addresses
Message-Id: <8r8omv$lm6$1@hermes.nz.eds.com>

I'm having problems trying to get the correct regex to perform an address
comparison.

The comparison involves:

Reversing the order of any two adjacent address identifiers (where
identifier is a group of alphanumeric characters preceded and followed by a
space and containing at least one numeric character) in the first address
and then comparing it against the second to see if they match.

My current attempt is:

#!/usr/local/bin/perl -w
use strict;

Compare('4 123A SMITH ST','123A 4 SMITH ST');
Compare('APARTMENT 4 123A SMITH ST', 'APARTMENT 123A 4 SMITH ST');
Compare('TOP APARTMENT 4 123A SMITH ST', 'TOP APARTMENT 123A 4 SMITH ST');
Compare('APARTMENT 4 123A SMITH ST', 'FLAT 123A 4 SMITH ST');
Compare('10 SMITH ST', '12 SMITH ST');

sub Compare {
        my ($add1,$add2)=@_;

        print "$add1,$add2\n";
        $add1 =~ s/([A-Z]+ )*([A-Z]*\d+[A-Z]*) ([A-Z]*\d+[A-Z]*)(.*)/$1$3
$2$4/;

        if ($add1 eq $add2) {
                print "SAME\n\n";
        }
        else {
                print "DIFFERENT\n\n";
        }
}

Which gives the results:

4 123A SMITH ST,123A 4 SMITH ST
Use of uninitialized value at ./addcomp line 14.
SAME

APARTMENT 4 123A SMITH ST,APARTMENT 123A 4 SMITH ST
SAME

TOP APARTMENT 4 123A SMITH ST,TOP APARTMENT 123A 4 SMITH ST
DIFFERENT

APARTMENT 4 123A SMITH ST,FLAT 123A 4 SMITH ST
DIFFERENT

10 SMITH ST,12 SMITH ST
DIFFERENT

If I had my regex correct, the 1st, 2nd and 3rd compares should have come
back as the same with the 4th and 5th being different.

The main problem I'm having is catering for the fact that there may or may
not be address information before the numbers that are reversed (which is
where the 'uninitialized value' warning comes from when the first parameter
is not matched).

Am I going about this in the correct way?  If so, how do I fix my regex?







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

Date: Sun, 01 Oct 2000 20:09:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Regex comparing street addresses
Message-Id: <39D7FC82.1053C8B@stomp.stomp.tokyo>

Peter Sundstrom wrote:
 
> I'm having problems trying to get the correct regex to 
> perform an address comparison.

Boy Howdy!

 
> My current attempt is:

(snip)

> Which gives the results:

(snip)


Nope. Your script does not produce these data
you have posted.

Godzilla!

--


TEST SCRIPT:
____________


#!/usr/local/bin/perl

print "Content-Type: text/plain\n\n";


Compare('4 123A SMITH ST','123A 4 SMITH ST');
Compare('APARTMENT 4 123A SMITH ST', 'APARTMENT 123A 4 SMITH ST');
Compare('TOP APARTMENT 4 123A SMITH ST', 'TOP APARTMENT 123A 4 SMITH ST');
Compare('APARTMENT 4 123A SMITH ST', 'FLAT 123A 4 SMITH ST');
Compare('10 SMITH ST', '12 SMITH ST');

sub Compare 
 {
  my ($add1,$add2)=@_;

  print "$add1,$add2\n";
  $add1 =~ s/([A-Z]+ )*([A-Z]*\d+[A-Z]*) ([A-Z]*\d+[A-Z]*)(.*)/$1$3$2$4/;

  if ($add1 eq $add2)
   {
    print "SAME\n\n";
   }
  else 
   {
    print "DIFFERENT\n\n";
   }
 }

exit;



PRINTED RESULTS:
________________


4 123A SMITH ST,123A 4 SMITH ST
DIFFERENT

APARTMENT 4 123A SMITH ST,APARTMENT 123A 4 SMITH ST
DIFFERENT

TOP APARTMENT 4 123A SMITH ST,TOP APARTMENT 123A 4 SMITH ST
DIFFERENT

APARTMENT 4 123A SMITH ST,FLAT 123A 4 SMITH ST
DIFFERENT

10 SMITH ST,12 SMITH ST
DIFFERENT


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

Date: Mon, 02 Oct 2000 03:27:07 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Regex comparing street addresses
Message-Id: <39D80092.9ABE21B7@rochester.rr.com>

Peter Sundstrom wrote:
> 
> I'm having problems trying to get the correct regex to perform an address
> comparison.
> 
> The comparison involves:
> 
> Reversing the order of any two adjacent address identifiers (where
> identifier is a group of alphanumeric characters preceded and followed by a
> space and containing at least one numeric character) in the first address
> and then comparing it against the second to see if they match.
> 
 ...
> Am I going about this in the correct way?  If so, how do I fix my regex?

A regex isn't always the best way to do everything.  In this case, try:

use strict;
Compare('4 123A SMITH ST','123A 4 SMITH ST');
Compare('APARTMENT 4 123A SMITH ST', 'APARTMENT 123A 4 SMITH ST');
Compare('TOP APARTMENT 4 123A SMITH ST', 'TOP APARTMENT 123A 4 SMITH
ST');
Compare('APARTMENT 4 123A SMITH ST', 'FLAT 123A 4 SMITH ST');
Compare('10 SMITH ST', '12 SMITH ST');

sub Compare{
  my($one,$two)=@_;
  my(%one,%two);
  print "address 1:  $one\n";
  print "address 2:  $two\n";
  for(split / /,$one){$one{$_}++}
  for(split / /,$two){$two{$_}++}
  my $diff=0;
  for(keys %one){
    {local $^W=0;
    if($two{$_}!=$one{$_}){$diff++}
    }
  }
  for(keys %two){
    {local $^W=0;
    if($two{$_}!=$one{$_}){$diff++}
    }
  }
  if($diff){
    print "DIFFERENT\n";
  }
  else{
    print "SAME\n";
  }
}

This prints:

C:\Bob\junk>perl junk218.pl
address 1:  4 123A SMITH ST
address 2:  123A 4 SMITH ST
SAME
address 1:  APARTMENT 4 123A SMITH ST
address 2:  APARTMENT 123A 4 SMITH ST
SAME
address 1:  TOP APARTMENT 4 123A SMITH ST
address 2:  TOP APARTMENT 123A 4 SMITH ST
SAME
address 1:  APARTMENT 4 123A SMITH ST
address 2:  FLAT 123A 4 SMITH ST
DIFFERENT
address 1:  10 SMITH ST
address 2:  12 SMITH ST
DIFFERENT

C:\Bob\junk>

which I think is what you want.


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

Date: Sun, 01 Oct 2000 22:28:22 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: starting with perl.
Message-Id: <39D7BA8F.67A18AEE@rochester.rr.com>

Joe Creaney wrote:
> 
> I am pretty new to perl and I am using earthlink(netcom) and I am having

The correct name of the language is Perl.

> a problem
> trying to get my scrips to save a data file.  Are there any perl

If you want help here, you will have to be much much more specific. 
Exactly what problem?  Did you get an error message?  If so, what did it
say?  And what was the code (not all of it, but a concise minimal piece
[copy-pasted into your posting, not re-typed] which will run all by
itself to demonstrate the error or problem you are complaining about). 
Finally, is the problem a Perl problem or a problem with whatever
OS/platform Earthlink is using (and, BTW, what platform/OS is that,
etc).  We deal with Perl problems here.

> programsers with
> the same server to give a few tips or secrets.  I checked out their
> example but
> it seemed convoluted and I didn't understand it.

Again, what example?  What did it say (again, concise etc)?  What
specifically did you not understand?

> 
> Also I am trying to print out my guest book.  I know there scripts out
> there
> but I want to write my own so I can learn.  i have a new book on perl or

Good for you.  If you get stuck, follow the guidelines above, and you'll
get help from this newsgroup with Perl problems.  If your problems are
CGI-related, you might find the folks on
comp.infosystem.www.authoring.cgi to be more helpful, as they are a CGI
newsgroup, and we are a Perl newsgroup.  Ask your Perl questions here,
and your CGI questions there.

> 
> CGI I hope it is helpful.
> 
> One final question, what are the job opertunities if I can accuire
> a decent skill in perl and html and other web programing.
> 
> Joe Creaney
> joec@annuna.com
 ...
-- 
Bob Walton


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

Date: Mon, 02 Oct 2000 00:14:04 GMT
From: Joe Creaney <varat@ix.netcom.com>
Subject: Re: starting with perl.
Message-Id: <39D77F95.788A0E2@ix.netcom.com>



Bob Walton wrote:

> Joe Creaney wrote:
> >
> > I am pretty new to perl and I am using earthlink(netcom) and I am having
>
> The correct name of the language is Perl.
>
> > a problem
> > trying to get my scrips to save a data file.  Are there any perl
>
> If you want help here, you will have to be much much more specific.
> Exactly what problem?  Did you get an error message?  If so, what did it
> say?  And what was the code (not all of it, but a concise minimal piece
> [copy-pasted into your posting, not re-typed] which will run all by
> itself to demonstrate the error or problem you are complaining about).
> Finally, is the problem a Perl problem or a problem with whatever
> OS/platform Earthlink is using (and, BTW, what platform/OS is that,
> etc).  We deal with Perl problems here.
>
> > programsers with
> > the same server to give a few tips or secrets.  I checked out their
> > example but
> > it seemed convoluted and I didn't understand it.
>
> Again, what example?  What did it say (again, concise etc)?  What
> specifically did you not understand?
>
> >
> > Also I am trying to print out my guest book.  I know there scripts out
> > there
> > but I want to write my own so I can learn.  i have a new book on perl or
>
> Good for you.  If you get stuck, follow the guidelines above, and you'll
> get help from this newsgroup with Perl problems.  If your problems are
> CGI-related, you might find the folks on
> comp.infosystem.www.authoring.cgi to be more helpful, as they are a CGI
> newsgroup, and we are a Perl newsgroup.  Ask your Perl questions here,
> and your CGI questions there.
>
> >
> > CGI I hope it is helpful.
> >
> > One final question, what are the job opertunities if I can accuire
> > a decent skill in perl and html and other web programing.
> >
> > Joe Creaney
> > joec@annuna.com
> ...
> --
> Bob Walton

My problem is with this line:
open (log,"dir");

My question is with the dir part.  I tried to use
www.annuna.com/cgi-bin/logs/logfile.txt.  It
didn't work, I got the error message put in after the ||.  In the eexaply
they had some code that looked
like a usernumber/www/ or somthing.  It seemed confusing.  To write a file
normally can I use
an address like a link ordo I need to do it some other way.



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

Date: Mon, 02 Oct 2000 03:03:14 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: starting with perl.
Message-Id: <39D7FAEA.6A4FCDAF@rochester.rr.com>

Joe Creaney wrote:
 ...
> My problem is with this line:
> open (log,"dir");

That line is perfectly valid Perl and should execute with no problem if
the directory and file specified exist (since you're appending -- but
that is OS specific [and even specific to the user settings of some
OS's, like many Unix variants]) and you have the proper write
permissions to the directory and file (again, OS dependent, and not
knowing you OS, well, ???).  In case something goes wrong, you **must**
test the result of the open and not attempt to use the filehandle if it
fails.  Something like:

    open LOG,"dir" or die "Oops, couldn't open 'dir', $!\n";

If you don't do that, very weird things may happen and you'll be looking
all over trying to figure out what is wrong, when it was simply a matter
that an open failed.

> 
> My question is with the dir part.  I tried to use
> www.annuna.com/cgi-bin/logs/logfile.txt.  It
> didn't work, I got the error message put in after the ||.  In the eexaply

Joe, again, you aren't being specific enough (for example:  "doesn't
work" covers *a lot* of territory -- I really can't begin to guess what
it means in your specific case), but I'll try to comment as best I can. 
What *exactly* "doesn't work"?  What does it do it shouldn't have done;
what didn't it do that it should have done?  Usenet folks can't read
your mind.

Again, *what* error message?  The one you specified?  Then you *know*
the open failed.  So you know where you have to begin fixing things. 
Did you put $! in the text of the error message?  If so, then you know
if it was a problem of not finding the file, a permission problem, file
system full, etc etc.  You could start by figuring out what directory
your CGI script is running in.  If you can't figure it out from the docs
provided by your web host provider, maybe something like 

    print `pwd`;

in your CGI script would tell you.  Then you can figure out the path you
should be specifying to get to the location of the file you want to
write.  (Or you could just give it the absolute path, and you wouldn't
have to worry about all that.)

What you specify (www.annuna.com/cgi-bin/logs/logfile.txt) is a valid
path/filename for many OS's, but is unlikely.  It looks like you are
confusing URL's and pathnames.

> they had some code that looked
> like a usernumber/www/ or somthing.  It seemed confusing.  To write a file

Yes, it's probably ~username/www/whatever.  You will really have to get
that from the documentation provided by your web host provider.  No one
else knows.

> normally can I use
> an address like a link ordo I need to do it some other way.

When you open a file in a computer programming language, you typically
cannot specify an address "like a link".  You can only write to
filesystems that exist or are mounted on the computer on which your
program is running (well...there is stuff like sockets...).  So if you
do successfully write your file, you will need to look for it on
EarthLink's computer, not your own computer.
-- 
Bob Walton


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

Date: 1 Oct 2000 22:51:38 GMT
From: joshua@haberman.com (Joshua Haberman)
Subject: string indexing
Message-Id: <8r8f5q$8hc$1@eskinews.eskimo.com>

Is there really no way access single characters of strings with convenient
syntax? This has been a persistant thorn in my side since I've been learning
Perl. I figure that I'm not the first person ever in the history of the
universe to have this frustration, so what am I missing? How is one intended
to manipulate strings character by character??

The two solutions I see are:

	substr($string, $index, 1);

Yes, this works, but it's bulky and non-intuitive to read. The other is:

	@string = split(//, $string);
	$string[$index];
	string join("", @string);

Even worse, though sometimes more readable if you're doing several accesses
in a row, because you at least get the intuitive [] notation.

Is there a better way? Do I just need to be approaching my problems in
different ways?

Joshua Haberman


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

Date: 1 Oct 2000 23:19:38 GMT
From: ebohlman@omsdev.com
Subject: Re: string indexing
Message-Id: <8r8gqa$18ce$1@news.enteract.com>

Joshua Haberman <joshua@haberman.com> wrote:
> Is there really no way access single characters of strings with convenient
> syntax? This has been a persistant thorn in my side since I've been learning
> Perl. I figure that I'm not the first person ever in the history of the
> universe to have this frustration, so what am I missing? How is one intended
> to manipulate strings character by character??

[snip]

> Is there a better way? Do I just need to be approaching my problems in
> different ways?

Quite probably the latter.  If you come from, say, a C background, you're
going to be used to solving certain problems in terms of
character-by-character processing because that's the only way you can do
it in C.  In many cases, Perl will provide higher-level operations that
will allow you to solve those problems without getting directly down to
the character-by-character level.  Remember that strings are
first-class data types in Perl; they're not implemented as arrays of
characters, and you don't need to think in terms of arrays of characters.



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

Date: Sun, 1 Oct 2000 23:23:56 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: string indexing
Message-Id: <Pine.A41.4.21.0010012315010.16950-100000@ginger.libs.uga.edu>

On 1 Oct 2000, Joshua Haberman wrote:

> Is there really no way access single characters of strings with convenient
> syntax? This has been a persistant thorn in my side since I've been learning
> Perl. I figure that I'm not the first person ever in the history of the
> universe to have this frustration, so what am I missing? How is one intended
> to manipulate strings character by character??

I think you will find that operations using 'substr' will outperform most
if not all of the alternatives.  I'm seldom particularly thrilled using
substr either, but it certainly does the job.

Brad




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

Date: 1 Oct 2000 21:25:12 +0200
From: elwood@news.agouros.de (Konstantinos Agouros)
Subject: UPgrade to 5.6.0 and mod_perl_problems
Message-Id: <elwood.970428199@news.agouros.de>

Hi,

I just upgraded to 5.6.0 build a new mod_perl, did a make install (
of just the mod_perl not the httpd) and tried a few scripts I have
running. Must went fine, but one script fails (I get an errormessage
in the browser) and error_log of apache tells me:
/export/elwood/httpd/bin/httpd: can't resolve symbol 'newCONSTSUB'
Somebody has an idea what this might be?
Apache is 1.3.12 and mod_perl is 1.24.

Konstantin
-- 
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4486
**************************************


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