[9640] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3234 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 23 13:07:28 1998

Date: Thu, 23 Jul 98 10:01:37 -0700
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 Jul 1998     Volume: 8 Number: 3234

Today's topics:
    Re: Perl array name (Larry Rosler)
    Re: Perl array name (Kevin Reid)
        perl setup problems (A. Nelson)
        Reading Landmark Data in Perl <slpalmer@flex.net>
        Regexp Help/Perl Help chrisabraham@my-dejanews.com
    Re: Regular expressions for Perl 5 (Patrick Timmins)
    Re: sendmail code <markstang@ncgroup.com>
        sort email list ken@co.greenwood.sc.us
    Re: specific character/position in string (Josh Kortbein)
    Re: Subroutine Mystery (Andrew M. Langmead)
    Re: Subroutine Mystery (Andrew M. Langmead)
    Re: system() return values voonh@my-dejanews.com
    Re: To STRICT for me ! <Tony.Curtis+usenet@vcpc.univie.ac.at>
        UID, passwd <dlachuer@araxe.fr>
        re: Using 2 d Arrays in Perl 4 <paul_bashforth@ml.com>
    Re: What's wrong? (Greg Bacon)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Thu, 23 Jul 1998 08:39:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl array name
Message-Id: <MPG.1020f9205e97674198977d@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc; copy mailed to john_dawson@my-
dejanews.com.]

In article <6p7hk0$p74$1@nnrp1.dejanews.com> on Thu, 23 Jul 1998 14:33:36 
GMT, john_dawson@my-dejanews.com says...
 ...
>  Looking at your example and reading a perl book on the 'my'
> statement, doesn't this limit the hash variables to the subroutine?
> I'm wanting to build these arrays as to match the elements to a
> record read from a file later into the program and outside the
> subroutine. Again thanks to everyone for thier reply.
 ...
> > It would look like this:
> >
> > my %arrays;
> > $arrays{$variable} = [ $variable2, $variable3, $variable4 ];

my %arrays;

foo();  # Set up %arrays.

# and use %arrays here.

sub foo {
    # Set up %arrays here
}

It doesn't really matter where the subroutine is located in the file, as 
long as it is in the same scope as the 'my' variable.  A (better) way of 
doing this is to call the subroutine with a *reference* to the hash as an 
argument, then set it up using the reference instead of the name of the 
global variable:

my %arrays;

foo(\%arrays);

 ...

sub foo {
    my $href = shift;
    $href->{$variable} = [ ...

And now foo() can be anywhere at all.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 23 Jul 1998 12:07:46 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Perl array name
Message-Id: <1dcma2m.1r79uo73indmoN@slip166-72-108-199.ny.us.ibm.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> This can be useful.  For example,
> 
>     $path = "/etc/motd";
>     open($path, $path) || die "$path: $!";
>     while (<$path>) {
>       warn "surprise";
>     } 

For opening files, I prefer:

$FILE = '/etc/motd';
open FILE or die "open of $FILE failed: $!";
while (<FILE>) {

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 23 Jul 1998 16:44:28 GMT
From: mbane@s-crim1.dl.ac.uk (A. Nelson)
Subject: perl setup problems
Message-Id: <6p7p9c$ku1@mserv1.dl.ac.uk>

Hello,
I need help successfully compiling the source code for 
perl5.
I have run 
sh Configure
when i run make depend I get the following errors

/usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
make: Warning: Both `makefile' and `Makefile' exist
Current working directory /opt/perl5.004
make: Warning: Both `makefile' and `Makefile' exist
Current working directory /opt/perl5.004/x2p
make: Warning: Both `makefile' and `Makefile' exist
Current working directory /opt/perl5.004/x2p
In file included from ../perl.h:223,
                 from malloc.c:6:
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/include/sys/param.h:187: warnind
/usr/include/sys/select.h:45: warning: this is the location of the previous defn
In file included from /usr/include/sys/stream.h:26,
                 from /usr/include/netinet/in.h:38,
                 from ../perl.h:361,
                 from malloc.c:6:
/usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
make: Warning: Both `makefile' and `Makefile' exist
Current working directory /opt/perl5.004/x2p

What is this No DATAMODEL_NATIVE specified anyway, am 
baffled.

When I run make by itself I get
make: Warning: Both `makefile' and `Makefile' exist
`sh  cflags libperl.a miniperlmain.o`  miniperlmain.c
          CCCMD =  gcc -DPERL_CORE -c
In file included from perl.h:223,
                 from miniperlmain.c:10:
/opt/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/include/sys/param.h:187: warnind
/usr/include/sys/select.h:45: warning: this is the location of the previous defn
In file included from /usr/include/sys/stream.h:26,
                 from /usr/include/netinet/in.h:38,
                 from perl.h:361,
                 from miniperlmain.c:10:
/usr/include/sys/model.h:32: #error "No DATAMODEL_NATIVE specified"
*** Error code 1
make: Fatal error: Command failed for target `miniperlmain.o'

Can you help.
Thanks
Abi
a.nelson@icr.ac.uk



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

Date: Thu, 23 Jul 1998 10:45:30 -0500
From: Stephen Palmer <slpalmer@flex.net>
Subject: Reading Landmark Data in Perl
Message-Id: <35B75A99.B380B4D5@flex.net>

I'm writing a script to create a database of 2d seismic base lines.  The
files were created with Landmark.  Does anyone know the data structure
used in these (binary) files?  I'm trying to extract the xy coords from
these files...

I've looked for, but can't find a landmark newsgroup,.

Thanks!
---
Stephen L. Palmer

Email aistslp@sugarland.se76.com

Email slpalmer@sprintparanet.com

Pager (800)724-3329   or   slpalmer@pager.sprintparanet.com
       PIN 382-1266             (Short msgs please)





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

Date: Thu, 23 Jul 1998 16:01:16 GMT
From: chrisabraham@my-dejanews.com
To: michelle@tmn.com
Subject: Regexp Help/Perl Help
Message-Id: <6p7moc$v4c$1@nnrp1.dejanews.com>

Gurus:

I have a grep/regexp question:

I have 300 pages of this kind of thing:

 . . .

51-1, 1951
Eliot Elgart
Lester Schwartz
Arthur Levine

51-3 Eleven Dutch Printmakers, 1951
Escher, M.C.
De Gelder, D.

 . . .

And it is all in WP 6.1 Windows
and the first line is always an
exhibit number and there is always
a list of artists below.

Sometimes there is alphanumeric
in the exhibit number such as the
second set, sometimes, there
are commas and so forth.

Below the double hard return
is the Exhibit ID, and right below
that is the list of names --
some with Last Name First
and some First Name First.

What I need to do is thus:

De Gelder, D. [tab] 51-3 Eleven Dutch Printmakers, 1951
Elgart, Eliot [tab] 51-1, 1951
Escher, M.C. [tab] 51-3 Eleven Dutch Printmakers, 1951
Levine, Arthur [tab] 51-1, 1951
Schwartz, Lester [tab] 51-1, 1951

Three hundred pages of this thing:

[LAST NAME][COMMA][FIRST NAME][TAB][EXHIBIT ID][CR]

Sorted ultimately, by alpha, last name.

Any idea on how to do this?
It all seems like there is not
enough stuff to figure it out...
even for GREP, regular
expression, and PERL!

Any help would be pennies from heaven!

Cheers,

Chris Abraham

--
chris.abraham<cja@SPAMdds.nl><http://urban.net/chris>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 15:16:50 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Regular expressions for Perl 5
Message-Id: <6p7k52$s8h$1@nnrp1.dejanews.com>

I rarely type in the middle of someone's post, but this one required from me a
response.


In article <35B6BA2E.F8E15661@blueskyweb.com>,
  qwerty <avatar4@blueskyweb.com> wrote:
> I rarely post here, but this one required from me a response.

How often is rarely? Is this a troll?


> BJKim, for the first part, ignore that previous response, which

That's bad advice, since there are many improvements and bug fixes in Perl 5,
plus you'll have a tough time finding anyone reputable to maintain your Perl 4
code for you.


> completely reveresed your question.  For the second part, please

How did I reverse his question? His biggest problem is using Perl 4 instead of
Perl 5, not a little piece of code he's trying to fix.


> demonstrate what you are trying to match for, One might assume to just
> the next </TD>, but this might not be the case.

When you assume, you make an "ass" out of "u" and "me". So what's your point?
All we have to work with is what's posted, which won't work on Perl 4 or Perl
5. Perl won't know where the regex starts and stops because he is delimiting
it with slashes, which he also has unescaped in his regex. Either use m! ...
! (or some other delimiter) or backwack your whacks. And as Kimball pointed
out, the {1}? is another unsolved mystery.

Again, the answer to the poster's questions are:

1. Yes, there are aspects of regular expressions that are supported in Perl 5
but not in Perl 4.

2. You should get Perl 5, then read perldoc perlre, and then work on your
regular expression.


Patrick Timmins
U. Nebraska Medical Center


>
> -qwerty
>
> ptimmins@my-dejanews.com wrote:
> >
> > In article <35B631ED.DC3BBCC4@netscape.com>,
> >   BJKim <shado@uclink4.berkeley.edu> wrote:
> > > Does Perl 4 not support certain aspects of regular expressions that Perl
> > > 5 does.
> > >
> > > This is the error I get in Perl 4 but not in Perl 5
> > >
> > > /(<TD>(.*?)</TD><TD>(.*?)</TD>){1}?/: nested *?+ in regexp at change.cgi
> > > line 70.
> > >
> > > Any suggestions on what I should do?
> > >
> > >
> >
> > It hurts when I bang my head against the wall doc. What should I do?
> >
> > Seriously though, you're using '*' in a non-greedy way, which you can't do
in
> > Perl 4. Don't do that. The Perl 4, that is. Not the non-greedy.
> >
> > Patrick Timmins
> > U. Nebraska Medical Center
> >
> > -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> > http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Thu, 23 Jul 1998 10:24:44 -0400
From: "Mark Stang" <markstang@ncgroup.com>
Subject: Re: sendmail code
Message-Id: <6p7h49$cui$1@usenet1.interramp.com>

$sender =~ s/Matthew Flinchbaugh/Useless Jerk/


Matthew Flinchbaugh wrote in message <6p74dq$j93$2@butterfly.hjsoft.com>...
>does anyone know what i can use in a code to make sendmail run the mail
>bomber with a oerl script




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

Date: Thu, 23 Jul 1998 16:15:44 GMT
From: ken@co.greenwood.sc.us
Subject: sort email list
Message-Id: <6p7njg$da$1@nnrp1.dejanews.com>

I have a script to read my email file, sort by last name and display an html
page.  It works fine except that if I have more than one person with the same
last name, then only one of the names is printed (presumably the one at the
top of the alphabetically order).  Below is my script if someone could give
me a tip.  Thanks.

Ken

Script:


#!/usr/bin/perl

$filename="/public/email2.txt";
$bgimage = "/backgrnd.jpg";

print "Content-type: text/html\n\n"; print <<HTMLHead;	<html><body
background=\"$bgimage\"><center><h2>E-Mail Listing</h2></center> HTMLHead ; 
print "<center><h3>Includes County, City and Solicitor
Offices</h3></center>";  print "<center>Alphabetical by last name</center>"; 
print "<i>Last revised: June 23, 1998</i>";  print "<hr>";  print "<ul>";

  open(EMAIL,$filename) or die "Could not open the email file : $!";
	while (<EMAIL>) { ($id,$first,$last) = split(/\s+/);
	#print "$last, $first\n e-mail:$id\@co.greenwood.sc.us\n";

	# ** Build the hash of arrays. Key is the last name.
	$email_list{$last} = [($id, $first)];

  }

  #  Sort the hash on last name.
  foreach $key (sort keys %email_list){

	# Access the array associated with the key.
	($id, $first) = @{$email_list{$key}};
	#print "$key, $first"
	print "<a href=mailto:";
	print "$id";
	print "@";
	print "co.greenwood.sc.us>";
	print "$key, $first<br>";
	#print "The last name is : $key\t";
	#print "The first name is : $first\t";
	#print "The email id is : $id\n";
  }
  close(EMAIL) or die "Could not close the email file : $!";
  print "</ul>";
  print "<hr>";

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 23 Jul 1998 14:53:20 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: specific character/position in string
Message-Id: <6p7ip0$k19$1@news.iastate.edu>

Charles DeRykus (ced@bcstec.ca.boeing.com) wrote:
: The smoking gun is in variable $string's hands but
: I'm not sure how it got there :). 

Why was $string undef'ed inside my benchmark code? perldoc -m Benchmark
says that timethese() calls timethis() for each key/val pair, and
the timethis() documentation says:

	Time COUNT iterations of CODE. CODE may be a string to eval or a
	code reference; either way the CODE will run in the caller's package.

If it runs in my package why would a my() variable be clobbered? my()
vars are supposed to be local to the thingy (block, eval, sub, etc.)
in which they're defined, and entering a sub-block, etc., doesn't seem
to clobber my() vars normally.




Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Thu, 23 Jul 1998 15:54:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Subroutine Mystery
Message-Id: <EwK1IM.DB6@world.std.com>

montyh@umich.edu (monty hindman) writes:

># Doesn't work.
>sub Go ;
>Go ;
>print "$x @y \n" ;
>sub Go {
>    $x = 1 ;
>    @y = (1, 2, 3) ;
>}

The documentation that is supplied with perl documents every
diagnostic message in the perldiag man page. It explains the
historical reasons why perl requires arrays to be declared or used
before it allows then to be interpolated in double quoted strings. A
well placed "use vars qw(@y)" will fix things.

But I think it might be helpful to point out that if you have large
amounts of data that you are passing between subroutines (or between
the main flow of your code and a subroutine) it suggests poor program
design. Is there a reason why "Go" can't return $x and @y?

sub Go ;
my ($x, @y) = Go;
print "$x @y \n" ;
sub Go {
    my $x = 1 ;
    my @y = (1, 2, 3) ;
    return $x, @y;
}

-- 
Andrew Langmead


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

Date: Thu, 23 Jul 1998 16:00:39 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Subroutine Mystery
Message-Id: <EwK1t4.Hw7@world.std.com>

John Porter <jdporter@min.net> writes:

>Works for me (perl 5.004_04).
>What does your perl -v say?

I'm guessing that either you put both the working and non-working
versions in the same source file, or that you somehow didn't reproduce
the test case exactly as written. Every version of perl 5 from some
5.000 betas to the current version all produce a fatal error if an
unbackslashed "@" sign appears in a double quoted string unless it is
declared or used somewhere lexically preceding the string.

Of course, it would have helped if Monty had told us the error message
that he received.

-- 
Andrew Langmead


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

Date: Thu, 23 Jul 1998 14:37:48 GMT
From: voonh@my-dejanews.com
Subject: Re: system() return values
Message-Id: <6p7hrs$pfh$1@nnrp1.dejanews.com>

In article <35B352DC.D24CC4C3@gpu.srv.ualberta.ca>,
  gcoulomb@gpu.srv.ualberta.ca wrote:
> Okay, perhaps I need to be more literal: I was looking for advice that
> was NOT in the manpages because the procedure recommended in the manpage
> gives me the same result whether the external program succeeded or
> failed. I was wondering whether anyone had ever seen this kind of
> behavior before and could recommend a course of action. In case it
> matters to anyone, the scripts are running on an AIX/RS6000 as CGI
> scripts.
>
> Mishra Aditya wrote:
> >
> > perdoc -f system
> >
> > Adi
>
> --
> Greg Coulombe
> Programmer, Orlando Project
> Faculty of Arts
> coulombe@cs.ualberta.ca
>
> "It is easier to port a shell than a shell script."
> 			-- Larry Wall
>

Greg,

I think I may have found a solution. I was getting the -1 return code in my
script and it was due to child signals. I would fork the program, but before
that I used a $SIG{CHLD}=sub {wait }.

Apparently, this causes problems on some systems. A better solution (worked
for me) was

sub REAPER {
	my $waitedpid=wait;
	$SIG{CHLD}='DEFAULT';
}
$SIG{CHLD}=\&REAPER;
# forking bit

This resets the CHLD signal to DEFAULT after the child has died. I set the
signal again next time I fork, but if you want the signal to continue, change
the line $SIG{CHLD}='DEFAULT' to $SIG{CHLD}=\&REAPER, which is probably what
you want for a CGI script.

For more info, see the Camel book, 2nd edition::Social
Engineering::Cooperating with Other Processes::Signals.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 23 Jul 1998 16:51:13 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: To STRICT for me !
Message-Id: <7xhg08d3j2.fsf@fidelio.vcpc.univie.ac.at>

Re: To STRICT for me !, Joerg <jwagner@digilog.de> said:

Joerg> When using the "use strict;" pragma I get lots of

You mean: when using the `strict' pragma :-)

>> You've said ``use strict vars'', which indicates that all
>> variables must either be lexically scoped (using ``my''),
>> or explicitly qualified to say which package the global
>> variable is in (using ``::'').

Joerg> But this is exactly what I have done (using "my")

1. show us code which demonstrates the problem
   and the exact output you get
2. what version of perl? (perl -V)
3. what platform is it (WinNT, linux, ...)?

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,      | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, AT | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!    | personal email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.  |     tony_curtis32@hotmail.com


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

Date: Thu, 23 Jul 1998 17:02:35 +0200
From: Damien Lachuer <dlachuer@araxe.fr>
Subject: UID, passwd
Message-Id: <35B7508A.34E494E6@araxe.fr>

Hello.

I'd like to make a web utility to create unix user. I know that it could

be very dangerous, but it's only for a little intranet.

How can I modify passwd files, crypt passwd (what is SALT in
'crypt PLAINTEXT,SALT'), create user, with root permissions ?

Thanks.



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

Date: Wed, 22 Jul 1998 12:23:54 +0100
From: Paul Bashforth <paul_bashforth@ml.com>
Subject: re: Using 2 d Arrays in Perl 4
Message-Id: <35B5CBCA.659A0F79@ml.com>

I've written a script in Perl 5 which uses 2 dimensional arrays..

eg $Column[$row][$k] = $item;

However, I need to be able to run this as Perl 4 but when I do I'm
getting the following error...

syntax error in file ./convert123.pl at line 71, next 2 tokens "]["

Can you tell me if such arrays are allowed in Perl 4 or indeed if there
is a way I should declare them in Perl 4?

thanks

Paul Bashforth





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

Date: 23 Jul 1998 16:26:52 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: What's wrong?
Message-Id: <6p7o8c$bar$1@info.uah.edu>

In article <35B74B45.2B19@min.net>,
	John Porter <jdporter@min.net> writes:
: Greg Bacon wrote:
: > ...or just use ./ex
: 
: Sure; or put . is before /usr/bin in your path.

Ahh!!  I can't even begin to go into how bad an idea that is.  If you
have . in your path at all, make it the last element.  Please!

Followups set.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3234
**************************************

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