[9324] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2919 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 20 03:07:23 1998

Date: Sat, 20 Jun 98 00:00:47 -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           Sat, 20 Jun 1998     Volume: 8 Number: 2919

Today's topics:
        ?$basurl $basedirectory ?? (Steve MacLellan)
    Re: ?$basurl $basedirectory ?? <rootbeer@teleport.com>
    Re: A Script for checking emails valid? <rootbeer@teleport.com>
    Re: Array Elements <rootbeer@teleport.com>
    Re: Array Elements (Ronald J Kimball)
        Doing the work (was Re: Foreach Efficiency) (Ronald J Kimball)
    Re: Erasing password <rootbeer@teleport.com>
    Re: first language <cyrand@juno.com>
    Re: Flames.... <bowlin@sirius.com>
    Re: Flames.... <mike.schleif@aquila.com>
    Re: Have we got a good free Perl manual? <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
    Re: How do you pre-append using "open" (Tad McClellan)
    Re: How do you pre-append using "open" <ebohlman@netcom.com>
    Re: mail script w/ attachments <rootbeer@teleport.com>
    Re: mail script w/ attachments <bowlin@sirius.com>
    Re: Pod::Text -- Unix only? <mike.schleif@aquila.com>
    Re: Pod::Text -- Unix only? <ljz@asfast.com>
        Printing E-Mail to a file <jesse@savalas.com>
    Re: Printing E-Mail to a file <rootbeer@teleport.com>
    Re: redirecting stdout in WinNT <bowlin@sirius.com>
    Re: removing multiples from an array <mpersico@erols.com>
    Re: removing multiples from an array (Larry Rosler)
    Re: Subtracting Number of seconds from a date <rootbeer@teleport.com>
    Re: the ?PATTERN? match syntax (Larry Rosler)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 20 Jun 1998 05:22:13 GMT
From: maclell@col.ca (Steve MacLellan)
Subject: ?$basurl $basedirectory ??
Message-Id: <6mfd5q$pgi$2@f02s02.tac.net>

I had this same script set-up on a very similar host, but it wasn't with a
domain name, so perhaps this is confusing me some.

It's a perl cgi search script.

The domain is http://www.stevensgroup.ca/

What would appear to be the default directory when I do a PWD
I put here:
   @dirs = ('/stevens/*');

then:

# Define the variable $cgiurl as the URL of the WebSearch script itself.

$cgiurl = 'http://www.stevensgroup.ca/cgi-bin/websearch.pl';

 then:

# Define the variables $basepath and $baseurl with the absolute path
# and corresponding URL for a "base" directory under which the various
# directories to be searched all lie.  These variables are used to
# convert the UNIX paths to URLs for the results page.

$basepath = '/stevens/';
$baseurl = 'http://www.stevensgroup.ca/stevens/';

I am uploading the script in ascii mode and right now I have been chmoding
it to 777 until I can get it working.

Any help would be appreciated.

Thank-you,
Steve MacLellan



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

Date: Sat, 20 Jun 1998 04:32:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: ?$basurl $basedirectory ??
Message-Id: <Pine.GSO.3.96.980619213025.2666Q-100000@user2.teleport.com>

On Sat, 20 Jun 1998, Steve MacLellan wrote:

> It's a perl cgi search script.

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

> I am uploading the script in ascii mode and right now I have been
> chmoding it to 777 until I can get it working. 

Concerning security, this is generally a Bad Idea. It's like saying that
you can't get your car to start so you're leaving the keys in the
ignition. :-) 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 20 Jun 1998 03:21:05 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: A Script for checking emails valid?
Message-Id: <Pine.GSO.3.96.980619202026.2666G-100000@user2.teleport.com>

On 20 Jun 1998, Mr. Guy Gershoni wrote:

> I am just wondering if anyone knows where I might be able to get a
> script that will go through a list of emails and check that they still
> exsist. 

Nowhere; see the FAQ. Please, see it right away before someone falsely
claims to have such a script. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 20 Jun 1998 04:20:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Array Elements
Message-Id: <Pine.GSO.3.96.980619211408.2666O-100000@user2.teleport.com>

On Sat, 20 Jun 1998, Sifu Hall wrote:

>     Is there a function or subroutine that I can implement that will
> tell me the number of columns in a multidimensional array?

Sure; if you don't already have such a subroutine, you can write one. :-)

Here's something that may (or may not :-) help you to get started. 

    sub col_counts {
	# Given a reference to an array of (references to) arrays,
	# this returns an array giving the sizes of the referenced
	# arrays. 
	map { scalar @$_ } @{ +shift };
    }

    my $ref = [
	[ qw/ here are a few elements/ ],
	[ qw/ and some more/ ],
	[ ],
	[ 0..10000 ],
	[ ],
    ];

    print "The counts are: ", join(" ", col_counts $ref), "\n";

 ... which prints this:

    The counts are: 5 3 0 10001 0

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 20 Jun 1998 01:27:19 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Array Elements
Message-Id: <1dawcd0.jb4quu1wdnx8oN@bay1-101.quincy.ziplink.net>

Sifu Hall <webmaster@dragonslist.com> wrote:

>     Is there a function or subroutine that I can implement that will
> tell me the number of columns in a multidimensional array?  Thank you
> for your help.

For clarification:

[
 [ 1, 2, 3 ],
 [ 1, 2, 3, 4 ],
 [ 1, 2 ],
]

The array itself has four columns.  Certain rows have fewer columns.  If
that isn't the definition you had in mind, you'll have to be more
specific.

sub multi_dim_cols {
  my($aref) = @_;

  my $cols = 0;
  foreach (@$aref) {
    $cols = @$_ if @$_ > $cols;
  }
  $cols;
}

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 20 Jun 1998 01:27:23 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Doing the work (was Re: Foreach Efficiency)
Message-Id: <1dawdnz.1792ogmotrszkN@bay1-101.quincy.ziplink.net>

Josh Kortbein <kortbein@iastate.edu> wrote:

> Ronald J Kimball (rjk@coos.dartmouth.edu) wrote:
>
> : In other words, you're foisting off all the work onto us.  Thank you so
> : much.
> 
> It's only work foisted if you bite the hook. If your time was that
> important, would you even be replying to questions at all? Or discussing
> your replies to them?

I thought this thread had died.  Oh well.  :-)

No, it's only work if I try to write the poster's program for him.  If I
just point out that he is asking us to do the work for him, that's not
actually doing any work on my part.

I wasn't saying my time was important (as you say, if it was, I'd be
doing something else), I was saying I didn't want to do the posters work
for him.

As it turned out, this poster wasn't actually asking us to do his work
for him, the thread just developed so that it seemed that way.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 20 Jun 1998 03:25:03 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Erasing password
Message-Id: <Pine.GSO.3.96.980619202121.2666H-100000@user2.teleport.com>

On Sat, 20 Jun 1998 womlake@zip.com.au wrote:

> Here is what I want to do: (I've seen it done at several sites)
> Step 1 ... Enter a password, submit it and proceed to next web page
> Step 2 ... Press the back button on browser to return to password page
> 	   BUT with the password having been erased.
> Can this be accomplished with Perl ?

It sounds as if you want to control your mouse and keyboard with Perl. Or
maybe you want to control your web browser with Perl. If it can be done at
all, you'll just need to find out what protocol or interface is used, then
implement that in Perl. The first step will be the harder one. :-) 

> Also is it possible using Perl to prevent someone from using the BACK
> button to retrace steps in cgi scripted pages, thus preventing other
> users from altering form settings ?

It sounds as if you want to control a remote browser. That's a simple
matter of sending it whatever requests you wish. Check the docs, FAQs, and
newsgroups about browsers and their protocols for more information on what
you can do and how you can do it. Good luck! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 19 Jun 1998 23:12:37 -0500
From: Cyrand <cyrand@juno.com>
Subject: Re: first language
Message-Id: <358B36B5.E783A6C7@juno.com>



Larry Weiss wrote:

> Mark-Jason Dominus wrote:
> > Pointers are an essential part of the solution to the data hiding
> > problem, which is an essential issue.  Therefore, they cannot be
> > avoided, and in fact should be addressed as soon as possible. The
> > idea of a pointer should be separated from issues of pointer
> > arithmetic, which is not necessary until later.
> >
>
> And also by delaying the teaching of the concept and basic practice
> of pointers it gives the subject an undeserved sense of mystery and
> complexity.

As a novice programmer, I would have to agree.  The learning C book I am
reading introduced pointers as tricky, but important(Around chapter 9 of
21).  They emphasized the tricky.  I was nervous about using pointers,
and so had trouble using them the first few times.  After a few uses, I
realized that they were more useful than they said, and less tricky.
But I'm still working on unlearing the pointer fearing mindset, which
does *much* more harm than good.

--
Email: cyrand@juno.com
"Strategy and appropriate use of the *available* resources does NOT
equate to godhood. --Barry Kearns"




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

Date: Fri, 19 Jun 1998 21:33:02 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Flames....
Message-Id: <358B3B7E.A6C582B1@sirius.com>

Matthew O. Persico wrote:
> 
> 1) Take it as a sign of respect that people would expect to get
> instantaneous answers to any question. They wouldn't ask if they thought
> the readers of the group were incompetent or unwilling to help.
> 
> 2) Telling someone to FAQ, with maybe a specific section, and a gentle
> admonition to go and sin no more is perfectly accepatble.
> 
> 3) Screaming, ranting and going postal is just rude. And even if you
> consider some nebie FAQ'able questions to be rude, why do you stoop to
> that level?
> 
>[wonderful faq-off form letter deleted]

> A little bit of courteousy goes a long way.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I agree with you Matthew.  I think that a polite response, such as you 
suggest, is the most effective way to change unwanted behavior.  This
is exactly the kind of tone publishers use in rejecting unsolicited
manuscripts.  They have learned from experience that a polite and
helpful sounding "no" is the most efficient way to give rejection.

-- Jim Bowlin


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

Date: Sat, 20 Jun 1998 04:47:49 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: Flames....
Message-Id: <358B3E46.BE87C761@aquila.com>

Agreed.

And I, too, have sinned, my lord . . .

Nevertheless, a specific reference to a specific section of said FAQ or
Camel or manpage, etc. will get us all thumbing through the pages.

With all of the documentation available, it is too easy too easy to
overlook some invaluable portion -- I have done it.

No, that is not excusable; but, most of us occasionally miss the forest
for the trees.  Focus is important.  What is already documented is also
surrounded by other gems.  Browsing the docuentation can be both tedious
and enlightening.  Finding the right spot is not as obvious to those of
us who did NOT write it -- and it is for us, the ignorant, isn't it?

Tom Christiansen wrote:
> 
> Because quite simply, when 95% of the group is buried under the same
> stupid question with repeated duplicate answers that are already in the
> docs, it dies the signal-to-noise death.  And ignoring them does nothing
> to educate them about the fact that they could have and should have helped
> themselves to the answer which we have all worked so hard to provide.
> Ignoring them is bad, but answering with simple solutions as you
> seem to advocate is even worse, because it creates a pattern of addiction.
> If we keep giving them hand-outs of free fish, they'll keep coming back
> for more instead of learning to fish on their own.  We shouldn't ignore
> them and leave them helpless, and we shouldn't give quick fixes that leave
> them dependent upon our continued care and feeding.  They should RTFM, or
> else they're just crack addicts.

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: 20 Jun 1998 08:42:32 +0200
From: David Kastrup <dak@mailhost.neuroinformatik.ruhr-uni-bochum.de>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <m2n2b8tvzb.fsf@mailhost.neuroinformatik.ruhr-uni-bochum.de>

"Matthew O. Persico" <mpersico@erols.com> writes:

> My $0.02
> 
> Larry gave us Perl. Free. So a few people (including Larry maybe?) want
> to make a few bucks describing it to the rest of us. More power to 'em.
> People have to eat.

That's not what the "free" "non-free" business is about.  What RMS
wants to avoid is that software gets basically unusable to people
without proper money and easy access to American bookstores.  There
are quite a few of programmers on this world for which an O'Reilly
book can easily mean a month's wages or more, and is a hassle to get.
"free" software should not be unusable for them by making the docs
unavailable.

RMS certainly is wiling to buy a good book by himself.  What he is not
willing to is to rely on software which requires that everybody else
do so before using it.

That's his quibble with essential docs for free software not being
available in free form.

Anyhow, the "freeness" in quesiton here was a bit of a different sort,
namely the freeness to modify and redistribute.  Might be important
for somebody distributing Perl in Russia, say.


-- 
David Kastrup                                     Phone: +49-234-700-5570
Email: dak@neuroinformatik.ruhr-uni-bochum.de       Fax: +49-234-709-4209
Institut f|r Neuroinformatik, Universitdtsstr. 150, 44780 Bochum, Germany


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

Date: Sat, 20 Jun 1998 00:36:49 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do you pre-append using "open"
Message-Id: <hphfm6.hv6.ln@localhost>

Nick Forte (webmaster@triologic.com) wrote:

: Looked through the FAQ - 
  ^^^^^^

   Doing a word search of the question lines for "append" (taken right
   from your Subject header) finds it right quick.

      grep '^=' *.pod | grep append


   That's why I got annoyed.

   I surely don't expect folks to actually *read* the several hundred
   "pages" of perl documentation.

   But grepping takes only seconds...



: and I'm not an expert like yourself. 

   I'm not a Perl expert. 

   Never claimed to be. 

   What makes you think that?

   I would not even characterize myself as "Advanced" in Perl.

   "Intermediate", at best.



   I know how to use grep though ;-)



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 20 Jun 1998 06:50:41 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How do you pre-append using "open"
Message-Id: <ebohlmanEuu8CI.88r@netcom.com>

Deva Seetharam <psdspss@execpc.com> wrote:
: Nick Forte wrote:

: > I'm trying to pre-append a record to a flat file. I want the record to
: > be inserted on the first line everytime instead of appending it to the
: > end. Can someone help me?
: >
: > Thanks!

: You need to seek the first position of the file, write your
: record and then write the original records of the file.
: As the following snippet does :

The problem with your method (a problem not shared by the methods in the 
FAQ) is that if anything goes seriously wrong while you're rewriting the 
file in place, you can lose an awful lot of its previous contents.



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

Date: Sat, 20 Jun 1998 03:16:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: mail script w/ attachments
Message-Id: <Pine.GSO.3.96.980619201623.2666E-100000@user2.teleport.com>

On Fri, 19 Jun 1998, rferr wrote:

> Does anyone know how to invoke sendmail with attachments ?

Probably the folks in comp.mail.sendmail do. :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 19 Jun 1998 21:45:32 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: rferr <rferr@voicenet.com>
Subject: Re: mail script w/ attachments
Message-Id: <358B3E6C.4DC76A23@sirius.com>

rferr wrote:
> 
> Does anyone know how to invoke sendmail with attachments ? I have the cc:,
> bcc:
> down but attachments is eluding me.
> Thanks.

I wrote a module that can send attachments.  It uses Net::SMTP which
bypasses sendmail.  You could modify it to use sendmail if you really
wanted to, but it might be better to use it as is if you have an
SMTP host to send the email to.  I can have it email itself to you.

-- Jim Bowlin


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

Date: Sat, 20 Jun 1998 04:10:46 GMT
From: "Michael D. Schleif" <mike.schleif@aquila.com>
Subject: Re: Pod::Text -- Unix only?
Message-Id: <358B3597.B23983BB@aquila.com>

Isn't the point more to do with the utter improbability that any one (1)
developer, no matter how godly, can program for all possible platforms
simultaneously?

The fact that Larry Wall no longer composes the Perl language all by his
lonesome addresses both the value of teamwork and the enormous magnitude
that is Perl running on all possible platforms.

Yes, I chose and continue to choose Perl, because it crosses almost all
of the platforms that I touch.

Yes, I get frustrated when I recognize cross-platform "inconsistencies"
-- I wish that they were NOT there.

Unfortunately, I am not yet skillful enough to write the appropriate
patches -- I aim to get there.

The fact that Perl is an evolving organism, growing everyday into
something more and better than it was yesterday, gives me hope that
these blemishes will one day be overcome.  And it reiterates ALL of the
reasons that I chose Perl in the first place!

No, you're right, TomC probably won't drop all else he is doing, which
by itself is a major achievement, to learn the Mac.  If he had one, what
would he do with it?  I guess, if Tom won't learn Mac, and change some
of these blemishes, then somebody else will have to take on that task .
 . .

Chris Nandor wrote:
> 
> That assumes Tom would want to use a Mac.  You can ship me a VAX, but that
> is no guarantee I will use it.  No one should begrudge Tom's dislike of
> Mac OS.  As long as he lets me use the Mac without significant flamage,
> which is probably dependent on my not trying to evangelize the Mac to him,
> then all is well in Happytown.

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: 20 Jun 1998 02:11:48 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Pod::Text -- Unix only?
Message-Id: <ltu35gwqjf.fsf@asfast.com>

Tom Phoenix <rootbeer@teleport.com> writes:

> On Fri, 19 Jun 1998, Michael D. Schleif wrote, referring to Tom
> Christiansen:
> 
> > I don't presume to speak for Tom -- we have had our share of words
> > between us -- but, anybody care to ship Tom a Mac?
> 
> Oddly enough, "Tom Christiansen" anagrams to "Insert Macintosh". 

Well, this one is even worse ...

  "Tom Christiansen hates sin."

Or perhaps ...

  "Anyhow, Tom Christiansen hit the dense Perl user -- no use!"

[ Hint, starts with: "Please insert ..." ]

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Fri, 19 Jun 1998 21:54:58 -0700
From: Jesse Rosenberger <jesse@savalas.com>
Subject: Printing E-Mail to a file
Message-Id: <358B40A2.F61C0D52@savalas.com>

does anyone know of a script that can read e-mail from a POP3 account
and if the subject *begins* with a certain word, such as "PERL - " (but
might have other words after it), it would read the message body, and
print it to a file?  If no one knows of a script...maybe a similiar
script that I can modify to suit my needs?  thanks in advance to anyone
who can help.  Oh, and I would prefer if the method of going about it
didn't require a module because I have no way of installing them at this
point because I only have FTP access...and not any telnet. thanks again.

Jesse Rosenberger



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

Date: Sat, 20 Jun 1998 05:14:38 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Printing E-Mail to a file
Message-Id: <Pine.GSO.3.96.980619221133.2666R-100000@user2.teleport.com>

On Fri, 19 Jun 1998, Jesse Rosenberger wrote:

> does anyone know of a script that can read e-mail from a POP3 account

Maybe you want the Mail::POP3Client module from CPAN?

> Oh, and I would prefer if the method of going about it didn't require a
> module because I have no way of installing them at this point because I
> only have FTP access...and not any telnet. 

If your system administrator won't install software, get a new one. (What
good is a sysadmin who won't install software?)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 19 Jun 1998 21:36:54 -0700
From: Jim Bowlin <bowlin@sirius.com>
To: Yary <yary@apicom.com>
Subject: Re: redirecting stdout in WinNT
Message-Id: <358B3C66.4B2EEB7B@sirius.com>

Yary wrote:
> 
> Here's an odd one, using G.S's precompiled Win32 distribution:
> 
> D:>echo print "Hello" > bat.pl
> 
> D:>bat.pl
> Hello
> D:>bat.pl > bat.txt
> 
> D:>type bat.txt
> 
> (bat.txt is empty)
> Why can I redirect the output of echo, but not bat.pl?

This is yet another Windows anomaly.  You need to precede the
">" with a low digit such as 1 or 2.  Try

bat.pl 1> bat.txt

or

bat.pl 2> bat.txt

HTH -- Jim Bowlin


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

Date: Sat, 20 Jun 1998 00:00:19 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: removing multiples from an array
Message-Id: <358B33D3.52BB2AFB@erols.com>

There will be many ways posted. Try this on:

## Assume my @a has the values in it:

## Define a hash
my %hash;

## For each array element
for (@a) {

	## make a hash entry for it, but only if it does
	## not already exist. That's a time saver, esp.
	## if @a is "large". Hmmm, I'm not at a perl prompt.
	## Not 100% sure on the "if not". Try without first.
	$hash{$_} = 1 if not $hash{$_};
}

## Now, since we stuffed the values into the keys of the hash, suck
## them out with the keys function.
@a = keys %hash;

So, that's three statements (for, hash assign, @a assign). Anyone wanna
try for two?
Eugene Sotirescu wrote:
> 
> How would I go about removing multiples from an array?
> For ex, if the array elements are 123.html 345.html 567.html 123.html
> 678.html 123.html 678.html
> then after removal it should be
> 123.html 345.html 567.html 678.html
> 
> Thanks.


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

Date: Fri, 19 Jun 1998 22:51:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: removing multiples from an array
Message-Id: <MPG.ff4edc3cfaebc069896d3@nntp.hpl.hp.com>

In article <358B33D3.52BB2AFB@erols.com>, Matthew O. Persico 
<mpersico@erols.com> says...
 ...
> So, that's three statements (for, hash assign, @a assign). Anyone wanna
> try for two?

Perlfaq4 "How can I extract just the unique elements of an array?" knows 
how to do it in just one line:

@out = grep(!$saw{$_}++, @in);

The parentheses are optional, and declaring the hash to ensure it is 
empty is also a good idea (but you didn't count that line in your 
solution either :-).

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


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

Date: Sat, 20 Jun 1998 04:23:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Subtracting Number of seconds from a date
Message-Id: <Pine.GSO.3.96.980619212040.2666P-100000@user2.teleport.com>

On Fri, 19 Jun 1998, Matthew O. Persico wrote:

> Subject: Re: Subtracting Number of seconds from a date
> 
> How 'bout posting the solution?

It's easy to work with dates in a variety of ways if you use the methods
documented in the FAQ and the various date modules. There's no real need
to post anything that's not better than those methods. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: Fri, 19 Jun 1998 23:37:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: the ?PATTERN? match syntax
Message-Id: <MPG.ff4f872f1741ea09896d4@nntp.hpl.hp.com>

In article <6mcrp1$g9d$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> 
says...
> 
> In article <6mce3p$96f$1@nnrp1.dejanews.com>,
>  <topher67@my-dejanews.com> wrote:
> >The match syntax "?PATTERN?" is very useful and should *not* be removed from
> >perl.
> 
> OK.  Why?
> 
> I'm not trying to start an argument; I'm really curious.  A few months
> ago I tried to make a list of the least-known and littlest-used Perl
> features.  I polled some experienced Perl programmers for advice.
> When I mentioned ?PATTERN? to them, most of them didn't know what I
> was referring to.
> 
> When is ?...? useful?  What do you do with it?

I cannot retrieve part of this thread, so forgive me for repeating, 
before adding a new observation.

Do_this_once_only_the_first_time_we_get_here_but never_again() if ?.*?;

I'll bet you can't do that with fewer characters in the control 
structure!

I discovered that one cannot include a literal question-mark character in 
an RE delimited by ??, no matter how many backslashes are used to escape 
it.  Ilya Zakharevich confirmed this arcane syntactic anomaly (bug).  
Amazing that it has not been encountered until now.  NOT!

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


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

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

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