[6900] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 525 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 27 07:17:17 1997

Date: Tue, 27 May 97 04:00:23 -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           Tue, 27 May 1997     Volume: 8 Number: 525

Today's topics:
     Re: (1+2)**3 == 3! (Mark Mills)
     Re: 2-way communication with unix command (Iain Chalmers)
     Re: [Q:] Comma use in Unix Review Col 09 <merlyn@stonehenge.com>
     adduser.pl script I wrote <hagus@goulburn.net.au>
     ANNOUNCE: Perl 5 Pattern Matching for Java (Daniel F. Savarese)
     Re: ATTENTION -- NEED A SCRIPT (Mike Heins)
     Re: ATTENTION -- NEED A SCRIPT <cerlpvk@cestar.technion.ac.il>
     Re: AWK vs Perl For Misc Data Processing Tasks <cerlpvk@cestar.technion.ac.il>
     Re: Catching errors from packages <minaret@sprynet.com>
     CGI in Perl for WinNT <gbrewer@impala.ir.miami.edu>
     Re: comp.lang.perl.web (Mark Mills)
     Re: comp.lang.perl.web (Tung-chiang Yang)
     Re: comp.lang.perl.web (Tung-chiang Yang)
     Re: Grep weather info. (Michel Dalle)
     Re: Help in Removing lines with duplicate Field Ones (Abigail)
     How to ignore euid and egid when i start a perl script. <francois@sequent.com>
     Re: Mass emailing <news@alf.impaq.com.pl>
     Perl online manuals/tutorials <ighon@infostrada.it>
     problem with perl, ODBC.pm  and CGI.pm delgreco@its.it
     Read Excel Files (Densin Roy.)
     searching for two or more strings that match in a singl (David Dougal)
     Re: searching for two or more strings that match in a s <chaimf@cris.com>
     Re: split'\|'; except when preceded by '/' (Charles DeRykus)
     telnet job (Marc de Kamps)
     Re: Trouble with Perl Data file (Tung-chiang Yang)
     Tutorial Needed <andrew.birkett@jotun.co.uk>
     Re: types (Tung-chiang Yang)
     Re: What is an "EMT Trap"? (Dominic Dunlop)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 27 May 1997 05:00:07 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: (1+2)**3 == 3!
Message-Id: <338b678c.26747382@news.ntr.net>

On Mon, 26 May 1997 10:36:45 -0400, Robert Rich
<bob.rich@enterprise.globalec.com> wrote:

>> print (1+2)**3;
>
>print is a function, right?  Wouldn't only the stuff in the parens get
>passed to the function, and eval'd from there?  I'm not seeing the
>parens in the mathematical context, just the programming context.
>
>try 
>
>print "",(1+2)**3;

as others pointed out:
	print +(1+2)**3; 
also works...

>This is kind of cool, though.  What would the official terms for
>the two different contexts the parens have?

wrong and right?  :>  *sarcasm_mode_off*

Precedence and argument( list)? contexts might work...
--
Mark <mark@ntr.net>

Arthur Dent: Ford! there's an infinite number of monkeys outside who want
to talk to us about the script for Hamlet they just worked out.


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

Date: Tue, 27 May 1997 17:15:00 +1000
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: 2-way communication with unix command
Message-Id: <bigiain-ya02408000R2705971715000001@news.ozemail.com.au>

In article <8cyb972n1h.fsf@gadget.cscaper.com>, Randal Schwartz
<merlyn@stonehenge.com> wrote:

> >>>>> "Andrew" == Andrew M Langmead <aml@world.std.com> writes:
> 
> Andrew> Unfortunately, it assumes you are using perl5. Two or so years ago,
> Andrew> when everyone was using perl version 4, [...]
> 
> My, how time flies.  Perl5.000 was released 2.7 years ago, and was in
> usable alpha/beta releases since at least mid 1993.  "Everyone was
> using perl version 4" hasn't been true for roughly 4 years.
> 
> Perl4 is dead, long dead.  Long live Perl5 (until Perl6 comes along :-).

hmmm, its only been dead a month now on my isp...

iain

(and only then 'cause of the cert advisory)

Iain Chalmers
bigiain@mightymedia.com.au


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

Date: 26 May 1997 21:39:21 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: brian@brie.com (Brian Lavender)
Subject: Re: [Q:] Comma use in Unix Review Col 09
Message-Id: <8cvi454jgm.fsf@gadget.cscaper.com>

>>>>> "Brian" == Brian Lavender <brian@brie.com> writes:

Brian> I am looking at Randal Schwartz's Unix Review column 9 located at
Brian> http://www.stonehenge.com/merlyn/UnixReview/col09.html

Cool.  At least one person looks at them. :-)

Brian> brie.com$ textgrep.pl -l print *
Brian> textgrep.pl[2]: ++:  not found
Brian> textgrep.pl[3]: =:  not found
Brian> textgrep.pl[4]: =:  not found
Brian> textgrep.pl[5]: @ARGV:  not found
Brian> textgrep.pl[6]: @ARGV:  not found

These are *not* Perl errors.  Most likely, /bin/sh is trying to execute
your Perl script.  This is not a good thing.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 462 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 27 May 1997 08:36:27 GMT
From: "Luke Burton" <hagus@goulburn.net.au>
Subject: adduser.pl script I wrote
Message-Id: <01bc6a79$061bbf00$1a0b1ccb@euler.goulburn.net.au>

#!/usr/bin/perl
#
# Cool adduser.pl script. Good for those who want to tweak their system's
adduser
# but don't want to walk knee deep through C code :) Hardly a hard script
to write,
# but it should be easy to cut up for your own purposes. I *think* I got
the crypt routine
# correct (I basically tried to copy the C one ... I dunno if it worked ;)
I am a C dummy)
#
# If this is posted to a site or distributed, let me know :) Note that this
is *totally*
# customised for my ISP. Everyone is in group users, everyone has a quota
copied from quota_usr,
# everyone is restricted to their own account for FTP (hence the bin/ls in
their directory),
# no-one has a login shell (hence the fictitional /bin/mosh :). And the new
user is sent a welcome
# mail with their username and password at the top of it.


# we'll start looking for a new UID from this number onwards
$trial = 700;

while ((@pw = getpwuid($trial)) != NULL) {
	$trial++;
}

# group id is fixed to users ...
$group_id = 100;
$user_id = $trial;

print "Adduser.pl\n\n";
print "Tablelands Internet, Luke Burton\n\n";

print "First Unused UID: $trial\n";
print "Group ID: 100 (users)\n";

while (!$ok) {

	print "Please enter in a username: ";
	$username = <STDIN>;
	chop $username;

	if (getpwnam($username) != NULL) {
		print "That username is in use. Try again\n";
		exit(0);
	}

	if (length($username) > 8) {
		print "That username was too long. Try again\n";
		exit(0);
	}

	print "Please enter in a password: ";
	$password = <STDIN>;
	chop $password;

	if ($password = NULL) {
		print "A null password?! Okay, I'll set it to $username\n";
		$password = $username;
	}

	print "Please enter in a real name: ";
	$realname = <STDIN>;
	chop $realname;

	print "\nYou entered in the following details ... \n";
	print "Username: $username\n";
	print "Password: $password\n";
	print "Realname: $realname\n";

	print "\nIs this correct? [y/n]: ";
	$response = <STDIN>;

	$ok = ($response =~ /^Y/i);

}

# the mysterious crypt function ...
$tm = time;
$salt1 = ($tm & 0x0f) + 'A';
$salt2 = (($tm & 0xf0) >> 4) + 'a';
$enc_passwd = crypt($password, $salt1.$salt2);

# let's add that to the password file ...
system("cp /etc/passwd /etc/passwd.OLD");
print "Adding line to password file ...";
open(PASSWD, ">>/etc/passwd");
print PASSWD
"$username:$enc_passwd:$user_id:$group_id:$realname:/home/$username:/bin/mos
h\n";
close(PASSWD);
print " done\n";

# routine system tasks to round us up ...
print "Making home directory and copying /bin/ls ...";
system("mkdir /home/$username");
chown $user_id, $group_id, "/home/$username";
system("mkdir /home/$username/bin");
system("cp /bin/ls /home/$username/bin/ls");
print " done\nSending a welcome mail to user ...";
@welcome = `cat /etc/welcome.mail`;
open(MAIL, "|/usr/lib/sendmail -t");
print MAIL "To:$username\n";
print MAIL "Subject: Welcome to Tablelands Internet!\n\n";
print MAIL "Your username is: $username\nYour password is: $password\n\n";
print MAIL @welcome;
close(MAIL);
print " done\nSetting user quota ...";
system("/usr/sbin/edquota -p quota_usr $username");
print " done\n";
print "Another new user added!\n";

-- 

/******************************************************
                     Luke Burton
      Systems Administrator, Tablelands Internet
          http://www.goulburn.net.au/~hagus

                 Tablelands Internet
                   (0419) 698 112
                   +61 48 722 400
              http://www.goulburn.net.au
*******************************************************/
"Being disintegrated makes me ve-ry an-gry!"  <huff, huff>


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

Date: 27 May 1997 00:42:17 -0400
From: dfs@oroinc.com (Daniel F. Savarese)
Subject: ANNOUNCE: Perl 5 Pattern Matching for Java
Message-Id: <5mdon9$4la@obiwan.oroinc.com>

I didn't post this to comp.lang.perl.announce because I think that's
actually only for stuff written in Perl.  I decided to go ahead and
post to comp.lang.perl.misc because I keep on running into Perl
programmers like myself who have to write Java code and sorely miss
reliable/robust/fully compatible/and FREE Perl 5 regular expressions.

There is now a FREE Java package that is reliable/robust/and fully
compatible with Perl 5 regular expressions (including zero-width
lookahead assertions, etc.).  It's called OROMatcher, from ORO, Inc.  If
your Java projects have been driving you nuts because Java lacks Perl's
powerful regular expressions, you may find OROMatcher will solve a
lot of your problems.  Although it still takes several lines of Java to
accomplish what one line of Perl can do.

You can find more details about OROMatcher and download the software
from:
	http://www.oroinc.com/


orororororororororororororororororororororororororororororororororororororororo
Daniel F. Savarese         voice: (410) 309-9640          email: dfs@oroinc.com
ORO, Inc.    "Component Software for the Internet."tm    http://www.oroinc.com/
orororororororororororororororororororororororororororororororororororororororo


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

Date: 27 May 1997 04:01:12 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: ATTENTION -- NEED A SCRIPT
Message-Id: <5mdma8$2gq@vixen.cso.uiuc.edu>

N1Graphics (n1graphics@aol.com) wrote:
: Hi There!
: 
: I need a Perl script for Perl 5.003 that is able to take some submitted 
: data and repost it as a confirmation. I would also like if you would 
: leave a place for me to add in some HTML that will be displayed on the the
: 
: confirmation page. Then the submit button should activate mail.pl. E-mail
: me
: at ABergs@juno.com if you need more info. I need this fast.
: 
: E-mail me at ABergs@juno.com

This one definitely takes the cake.

-- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.


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

Date: 27 May 1997 08:26:56 GMT
From: cerlpvk <cerlpvk@cestar.technion.ac.il>
Subject: Re: ATTENTION -- NEED A SCRIPT
Message-Id: <5me5sg$fg6@news.huji.ac.il>

I guess our company can do this rather advanced project.


Please email me if interested to

bill@microsoft.com



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

Date: 27 May 1997 08:18:15 GMT
From: cerlpvk <cerlpvk@cestar.technion.ac.il>
Subject: Re: AWK vs Perl For Misc Data Processing Tasks
Message-Id: <5me5c8$fg6@news.huji.ac.il>

Happy you if you got such thing as AWK compiler.
Stay with it.



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

Date: 27 May 1997 09:51:40 GMT
From: "Geoff Mottram" <minaret@sprynet.com>
Subject: Re: Catching errors from packages
Message-Id: <01bc6a83$51c8b7a0$9fc1aec7@cactus>

> If anyone has any ideas on how to prevent the process from dying, so I
> can hanlde the error I would certainly appreciate it. I don't care if it
> involves DBlib or CTlib as long as I can catch the error.

I don't use the package you are referring to but I have some thoughts:

It sounds like you are already using "eval" blocks.  If so, you should be
able to do some playing around with catching signals.  SIGCHILD is send to
the parent process when a child dies.  It may be causing the parent to die
if it is not being caught.  A good place to start would be by including the
"sigtrap" package.  It catches all signals and prints a message when one
comes in.  It's great for seeing what signals you are getting.  Hopefully,
you can catch the appropriate signal and have your script act accordingly.

Hope this helps.

-- 
Geoff Mottram
minaret@sprynet.com


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

Date: Tue, 27 May 1997 00:16:42 -0400
From: Jed Brewer <gbrewer@impala.ir.miami.edu>
Subject: CGI in Perl for WinNT
Message-Id: <Pine.ULT.3.92.970527001504.10575A-100000@impala.ir.miami.edu>

Hello,

I am having trouble porting cgi scripts I had written in perl to handle
forms (get method) from unix to the latest version of Windows NT.  If
anyone has any pointers, suggestions, comments, or anything at all that
could help, please send them my way.  Please reply to

gbrewer@impala.ir.miami.edu

Thank you very much, sincerely, Jed Brewer

                                                          =B1=B1
                                                        =B1=B1=B1=B1=B1=B1
Jed - <gbrewer@impala.ir.miami.edu>                       =B1=B1
The longer I live, the more I'm aware that we can be      11
blasted into glory anytime.111111111111111111111111111111111



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

Date: Tue, 27 May 1997 07:08:26 GMT
From: mark@ntr.net (Mark Mills)
Subject: Re: comp.lang.perl.web
Message-Id: <338c875b.34890861@news.ntr.net>

ooooh.  I just had an *IDEA*  If we created a *.spam group for every
current group (there can't be more than 30,000 or so) then the
spammers would all go post there and we could ignore them.


On Tue, 27 May 1997 04:55:53 GMT, tcyang@netcom.com (Tung-chiang Yang)
wrote:

>Sounds a good idea :P  I suggest adding the following groups:
>
>   comp.lang.sh.web
>   comp.lang.c++.web
>   comp.lang.c.web
>   comp.lang.tcl.web
>   comp.lang.perl.system-admin
>   comp.lang.perl.anything-you-can-think-of
>   comp.lang.perl.mail
>   comp.lang.perl.poetry
>
>==========================
>Aaron M. Scarisbrick (aaron@xmission.xmission.com) wrote:
>
>: I've been following this newsgroup loosely for the past few years, and I
>: can't help but think I'm not the only one that's thought of this:
>
>: comp.lang.perl.web
>
>: I'd say half the threads here have to do with the web, html, cgi and would
>: probably do better in a group of their own. Comments would be appreciated.

--
Mark <mark@ntr.net>
Zaphod Beeblebrox: It's the weird color-scheme that freaks me. Every time
you try to operate one of these weird black controls, which are labeled
in black on a black background, a small black light lights up black to
let you know you've done it!


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

Date: Tue, 27 May 1997 07:39:54 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: comp.lang.perl.web
Message-Id: <tcyangEAtxAI.J60@netcom.com>

I had a better idea ..... Since Netscape Navigator and MSIE have joined
the news reading business, maybe we should create

   comp.lang.perl.msie
   comp.lang.perl.netscape
   comp.lang.perl.tin
   comp.lang.perl.forte-agent
   comp.lang.perl.all-you-can-list

Creating comp.lang.perl.web because most posts are about WWW is not a good
idea.  We should also create

   comp.lang.perl.english
   comp.lang.perl.deutsch
   comp.lang.perl.espanol
   comp.lang.perl.all-you-can-speak

:)

Actually, more posts in this group are about questions, so we should
create

   comp.lang.perl.questions

Sigh.  I can never catch up with Emily's sarcasm :(

============================================
Mark Mills (mark@ntr.net) wrote:
: ooooh.  I just had an *IDEA*  If we created a *.spam group for every
: current group (there can't be more than 30,000 or so) then the
: spammers would all go post there and we could ignore them.

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Tue, 27 May 1997 04:55:53 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: comp.lang.perl.web
Message-Id: <tcyangEAtpp5.J8x@netcom.com>

Sounds a good idea :P  I suggest adding the following groups:

   comp.lang.sh.web
   comp.lang.c++.web
   comp.lang.c.web
   comp.lang.tcl.web
   comp.lang.perl.system-admin
   comp.lang.perl.anything-you-can-think-of
   comp.lang.perl.mail
   comp.lang.perl.poetry

==========================
Aaron M. Scarisbrick (aaron@xmission.xmission.com) wrote:

: I've been following this newsgroup loosely for the past few years, and I
: can't help but think I'm not the only one that's thought of this:

: comp.lang.perl.web

: I'd say half the threads here have to do with the web, html, cgi and would
: probably do better in a group of their own. Comments would be appreciated.

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 27 May 1997 09:54:50 GMT
From: Michel.Dalle@sni.be (Michel Dalle)
Subject: Re: Grep weather info.
Message-Id: <5meb1a$env$1@horus.mch.sni.de>

In article <Pine.GSO.3.96.970512083635.2793G-100000@kelly.teleport.com>, rootbeer@teleport.com 
says...
>
>On Sun, 11 May 1997, Matthew Ho wrote:
>> I have an assignment which requires me to grep weather information from
>> the net and shows it on my web page.  How can I do that in Perl?  Is
>> there any modules that I can download to make the task simpler? 
>
>Yes, they're on CPAN. (I'd start with LWP.) Hope this helps!
>
>    http://www.perl.com/CPAN/
>    http://www.perl.org/CPAN/
>

I had a similar question once. In order to create the web page, I use a CGI script in PERL. This 
CGI script calls another PERL script that acts as a "WebScraper" (same principle as a "screen 
scraper"). The WebScraper gets a page from a meteo site on the internet (e.g. using GET from the 
LWP module), extracts the lines between a start-identifier and an end-identifier, and outputs the 
resulting lines back to the CGI script for inclusion in the web page.

The only problem is that I do this each time the CGI script is called, although the weather 
information on the web doesn't change that much, so this is rather SLOW. The web scraping itself 
can be optimised quite a lot depending on how big the page is you need to retrieve, where in the 
page your lines are located (beginning/end), whether the start-identifier / end-identifier are on 
a single line or not, whether you're interested in keeping the HTML tags or just the text, etc.

I've been thinking of adding some internal caching of the meteo info for faster processing, but 
haven't gotten around to it yet... (For now, I only rely on the caching done on our proxy 
server.)

If you get any further, I'd be interested to know...


Michel.



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

Date: Wed, 21 May 1997 15:34:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help in Removing lines with duplicate Field Ones
Message-Id: <EAJF8q.JvF@nonexistent.com>

On 20 May 1997 22:28:08 GMT, Guest Account (guest@blueline.east.sun.com)
wrote in comp.lang.perl.misc
<URL: news:5lt8ho$gq2@eastnews1.East.Sun.COM>:
++ Input file has fixed length, 132 byte records, each with 8 fields.
++ 
++ Purpose:   Keep only those records in the file which have a UNIQUE
++ 	   field #1.
++ 
++ 	   Duplicates may occur on more than two lines (i.e., field
++ 	   one of record 6 may match field one of record 21, 98, 2110,
++ 	   and 65535.  Regardless of the number of duplications, ALL
++ 	   duplicate lines must be cleaned from the file. 
++ 
++ Field 1:   Alternates between numeric only, alpha only, or alpha-numeric
++ 	   values.  
++ 
++ I have ended up doing this in C because I couldn't figure out if perl could
++ handle it.  Can someone tell me a Perl solution?  I sincerly appreciate it.

Assuming fields have fixed length as well, and the first field is
15 bytes long:

perl -wne 'print unless $h {substr $_, 0, 15} ++;' files

(Replace 15 by whatever value).

Or when it's whitespace separated:

perl -wne 'print unless $h {(split)[0]} ++;' files

Abigail


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

Date: Tue, 27 May 1997 11:20:49 +0200
From: francois Simonneau <francois@sequent.com>
Subject: How to ignore euid and egid when i start a perl script.
Message-Id: <338AA771.18E7@sequent.com>

Hi all,
I have a batch sceduler with set euid and eguid 
uid=12699(aebdev) gid=1(other) euid=7105(uniq) egid=503(uniqgrp)
groups=1(other) ...

Then i start a perl script with begins like that.
eval 'exec ${PERL:-perl} -S $0 ${1+"$@"}'
  if 0 ;

use Utilities;
 ....
I get the following error message

No -S allowed while running setuid.

How to let it run anyway


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

Date: Tue, 27 May 1997 10:45:50 +0200
From: Andrew Filip <news@alf.impaq.com.pl>
Subject: Re: Mass emailing
Message-Id: <338A9F3E.81BDF35B@alf.impaq.com.pl>

Lauri Laakso wrote:
> 
> I am working with mass mailing system (not spam, user have to register
> first), and I need to know what is best way to send same email to
> all of @emails ?
> open (MAIL, "|$mailprog $mail1 $mail2 $mail3") || die "Can't open
> $mailprog!\n";
> ...works fine, but there may will be hundreds or thousands of
> addresses...

I suggest open2 module with -bs switch of sendmail.
 
-- 
common sense is uncommon


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

Date: Sun, 25 May 1997 18:29:39 +0200
From: Ighon <ighon@infostrada.it>
Subject: Perl online manuals/tutorials
Message-Id: <338868F2.24B2@infostrada.it>

Where I can find Perl online manuals/tutorials ?

I would learn this language.

Thank at all


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

Date: Tue, 27 May 1997 04:51:08 -0600
From: delgreco@its.it
Subject: problem with perl, ODBC.pm  and CGI.pm
Message-Id: <864726360.3025@dejanews.com>

Hello to everyone
I am trying to access an MS-access database via a CGI form
I have a lot of problems when I try to use both CGI.pm and ODBC.pm.
My perl script works well and launching it via dos shell, it performs all
the operations
When I try to launch it via a system call in a .pl script i does nothing

can anyone help me?

thank you

francesco

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 28 May 1997 00:12:11 GMT
From: den@loxinfo.co.th (Densin Roy.)
Subject: Read Excel Files
Message-Id: <5mft8r$bl2@news.loxinfo.co.th>

	        How to use perl read Ms'excel file ? which module can help me

                                        thank for advance
                                           densin Roy.
					(densin@loxinfo.co.th)


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

Date: 26 May 1997 23:21:04 GMT
From: ddougal@concentric.net (David Dougal)
Subject: searching for two or more strings that match in a single array
Message-Id: <5md5t0$8u8$1@news8.gte.net>

I have the following array:

@array = ("w0123456789","l0123456787","w0134265879", "t0123456789", 
"w0123456789", "w0123456789"); 

I want to compare each element and find the ones that match and count the 
number of matches and print out the results. I need to find the most matches.

I would need to compare element 0 with all the elements in the array and count 
the number of matches for element 0 and print results and so on....



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

Date: 26 May 1997 19:37:56 -0400
From: Chaim Frenkel <chaimf@cris.com>
To: David Dougal <ddougal@cris.com>
Subject: Re: searching for two or more strings that match in a single array
Message-Id: <m3pvudkdnv.fsf@nlk.nlk.com>

>>>>> "DD" == David Dougal <ddougal@concentric.net> writes:

DD> I have the following array: @array =
DD> ("w0123456789","l0123456787","w0134265879", "t0123456789",
DD> "w0123456789", "w0123456789");

DD> I want to compare each element and find the ones that match and
DD> count the number of matches and print out the results. I need to
DD> find the most matches.

DD> I would need to compare element 0 with all the elements in the
DD> array and count the number of matches for element 0 and print
DD> results and so on....

If I understand you, this is a FAQ.

	for (@array) { $counts{$_}++; }
	for (@array) { print "$_ : $counts{$_}\n"}

<chaim>
-- 
Chaim Frenkel					Nonlinear Knowledge, Inc.
chaimf@cris.com						 +1-718-236-0183


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

Date: Fri, 23 May 1997 20:16:26 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: split'\|'; except when preceded by '/'
Message-Id: <EAnHnE.E7v@bcstec.ca.boeing.com>

In article <3384986C.4A19A768@ixl.com > , Dan Boorstein  <danboo@ixl.com> wrote:
 > Hello All,
 > 
 > Here is the problem.
 > 
 >   A string with: no linefeeds
 >                  fields separated by |
 >                  nested |'s are escaped with \ (i.e., \|)
 > 
 > I want to split this string on unescaped |'s, removing
 > the \'s preceding the escaped |'s. I thought this would
 > be a 2 line split-regex block, but has turned into
 > something much less elegant which I pieced together
 > from various FAQ's and Dejanews articles. Behold:
 > 
 > $_ = '\||split|me|\|<no split|1\|=\|1|3|' . 'EOQ';
 > @temp = split'\|';
 > for ($i = 0; $i <= $#temp; $i++){
 >   $field = $temp[$i];
 >   while ($field =~ s/\\$/|/) { $field .= $temp[++$i]; }
 >   push(@fields, $field);
 > }
 > $fields[$#fields] =~ s,EOQ$,,;
 > 
 > for(@fields) { print $_, "\n"; }
 > 
 > After execution @fields contains (as expected):
 > ('|','split','me','|<no split','1|=|1','3','')
 > 
 > It does everything I wanted it to do, but not as cleanly as I'd
 > hoped. Any ideas on how to clean up this process (not necessarily
 > my coding style)?
 > 

One technique to simplify the split is to substitute a 
character not found in the string for the escaped "|" and 
then replace later:

s/\\\|/\0/g; s/EOQ$//;
@fields = map { s/\0/\|/g; $_ } split(/\|/);
print join " , ", @fields, "\n";


HTH,

--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: 27 May 97 09:26:43 GMT
From: h50@nikhef.nl (Marc de Kamps)
Subject: telnet job
Message-Id: <4313@nikhefh.nikhef.nl>

Greetings,
I am having trouble with the folowing construction:

open( FTPJOB , "telnet $ftpsite 80 << EOP
                GET bla.html
                EOP | ")
  while( <FTPJOB> ){
#    Do something with the contents of bla.html
  }
close( FTPJOB );

On IRIX6.0 this works fine, on SunOs5.5.1 it doesn't.
My guess is that the GET statement doesn't come through (remote server closes
before the GET gets through ) , but I don't know
how to check this in the debugger.

Some pointers towards what I am doing wrong ?

Thanks,
    Marc de Kamps



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

Date: Tue, 27 May 1997 03:40:59 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Trouble with Perl Data file
Message-Id: <tcyangEAtM8B.Bx8@netcom.com>

This is 99.9999999% not a Perl question and very likely 99% not a CGI
question.  Ask it in comp.unix.questions (I assume you are using Unix),
and I would bet you don't have write permission for the directory where
your data file stays, so you cannot create a new one.

Besides, I am never a Unix guru, but you do not seem to "own" this file
either based on the "httpd" and "clients" entries shown.

=====================================
Dave Mains (dbsales@pobox.com) wrote:
: I have a script that writes a data file.  It writes it (by default)
: with the attributes set as follows:

: -rw-r-----   1 httpd    clients

: The problem is I (the owner) cannot access this file
: for editing.  If I delete this file, I can't create a new one
: that the script likes.

: This is on a Unix platform with an Apache server.

: (deleted)

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Tue, 27 May 1997 10:55:09 +0100
From: Andy Birkett <andrew.birkett@jotun.co.uk>
Subject: Tutorial Needed
Message-Id: <BRXlVAA99qizEwl2@jotun.demon.co.uk>

Are there any good Perl tutorials on the net.  If so could someone
please point me in the right directions.

Thanks
-- 
Andy Birkett


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

Date: Tue, 27 May 1997 05:03:34 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: types
Message-Id: <tcyangEAtq1y.Jot@netcom.com>

This does not work ......

(code:)
#!/usr/local/bin/perl -w

$a = '';
print "Trial 1: It is an integer\n" if ($a == int($a));
print "Trial 2: It is an integer\n" if ($a eq int($a));
print "Trial 3: It is an integer\n" if (($a <=> int($a)) == 0);

(output:)
Trial 1: It is an integer
Trial 3: It is an integer

==================================================
Tom Phoenix (rootbeer@teleport.com) wrote:

: > How to know if what's returned from a from is an integer
: > or not ?

: Mostly, this will do it.

:     print "it's an integer" if $foo == int($foo);

: Hope this helps!

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Tue, 27 May 1997 10:49:12 +0200
From: domo@tcp.ip.lu (Dominic Dunlop)
Subject: Re: What is an "EMT Trap"?
Message-Id: <19970527104912360897@dialup24.ip.lu>

Mark Little <markl@dove.net.au> wrote:

> I'm trying to run Perl5.003 on an Amiga 3000 but I keep getting "EMT Trap"
> failures. This occurs when I try to use it from the web server (Apache)
> or from the command line. I can't find an explanation of what this is in
> the docs in the Amiga version or my Windows version.

Traditionally, an emulator trap was a software interrupt raised when a
processor encountered an instruction code which it knew was not
implemented in hardware.  The system function servicing the interrupt
was supposed to emulate the instruction in software -- or, if it
couldn't, to issue the sort of complaint you're seeing.  This facility
could be used, for example, to implement software floating point,
allowing processors without floating point hardware (slowly) to run
binary code containing floating point instructions.  In my experience
(not on Amigas, but on ancient 68000-based systems running various sorts
of UNIX without proper memory protection), getting an EMT usually
indicated that a process had stomped on its own code, that some other
process had decided to do some stomping, or that a wild PC had resulted
in an attempt to execute data from some random location.  I can't make
any guess as to why any of these bad things should be happening to you.
-- 
Dominic Dunlop

PS: Please persuade your mailer to stop putting HTML into news postings.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 525
*************************************

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