[8959] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2577 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 13 03:07:35 1998

Date: Wed, 13 May 98 00:00:55 -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           Wed, 13 May 1998     Volume: 8 Number: 2577

Today's topics:
        Abigail back? (Craig Berry)
    Re: Anagram algorithm anyone. dennis_marti@yahoo.com
    Re: associative array of arrays <roach@necrosis.com>
        Code Formatter for SQL <shankarpj@rhotmail.com>
    Re: Does Perl have a IDE?I don't like command line. (Chip Salzenberg)
    Re: Does Perl have a IDE?I don't like command line. (Chip Salzenberg)
    Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
    Re: Does Perl have a IDE?I don't like command line. (Ilya Zakharevich)
    Re: function prototyping <ljz@asfast.com>
        Get file date <fuc@esquel.com>
    Re: How can you break out of a 'while... ' loop in a fu (Chip Salzenberg)
    Re: Is if ($a="something") a bad style? (Chip Salzenberg)
    Re: MODULE MANIA STRIKES (Was Re: What does this do?) (Chip Salzenberg)
    Re: MODULE MANIA STRIKES (Was Re: What does this do?) (Chip Salzenberg)
        Need Perl command to pull HTML from a remote site. (HTT elitegrp@pond.net
    Re: Need Perl command to pull HTML from a remote site.  <3.14@Math.MIT.edu>
    Re: Need Perl command to pull HTML from a remote site.  (Martien Verbruggen)
    Re: Perl problem <wettels@respublica.de>
    Re: Perl/Wall lingo question <metcher@spider.herston.uq.edu.au>
    Re: Perl/Wall lingo question (Chip Salzenberg)
    Re: Randomly sorting an array (Chip Salzenberg)
    Re: Randomly sorting an array <tchrist@mox.perl.com>
    Re: Scanning Perl scripts for Y2K problems dennis_marti@yahoo.com
    Re: Significant digit? (Ronald J Kimball)
    Re: Strange behaviour of references... (Earl Hood)
    Re: Stripping HTML Tags from a file <wettels@respublica.de>
    Re: Where are pod translators? (Martien Verbruggen)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 May 1998 06:47:43 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Abigail back?
Message-Id: <6jbfmf$jo8$1@marina.cinenet.net>

Abigail (abigail@fnx.com) wrote:
[snip]
: Who will be the first to accuse me of something I didn't say?

Well, as I recall, you said "goodbye" to c.l.p.m in April... :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Wed, 13 May 1998 04:52:09 GMT
From: dennis_marti@yahoo.com
Subject: Re: Anagram algorithm anyone.
Message-Id: <6jb8tp$f5c$1@nnrp1.dejanews.com>



You can make it about four times "quicker" with a couple changes.

In article <MPG.fc2251578eb5d8f9896b1@news.min.net>,
  jdporter@min.net (John Porter) wrote:
>
> #
> # quick anagrams
> # by John Porter
> #
>
> #!/usr/local/bin/perl -w
>
> my $word = join '', sort split //, lc shift;
> my $len = length($word) || die "usage: $0 word\n";
>

# open(F,"/usr/dict/words") || die "open /usr/dict/words: $!";
$pattern = "^[$word\U$word\E]{$len}\$";
open(F, "egrep '$pattern' /usr/dict/words |"); die "error\n" if $?;

# for (<F>) {
while (<F>) {

>   chomp;

    print "$_\n"
#     if length == $len and $word eq join '', sort split //, lc $_;
      if $word eq join '', sort split //, lc $_;

> }
> close(F);
>

On a system without egrep, putting a "next unless /$pattern/o;" at
the top of the while loop will give you a less dramatic improvement.
(40% on my system.)

Just having fun with anagrams.

Dennis Marti

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 13 May 1998 05:50:43 +0000
From: Brian Roach <roach@necrosis.com>
To: dwc <dwc@davewc.mv.com>
Subject: Re: associative array of arrays
Message-Id: <355934B3.5B739489@necrosis.com>

dwc wrote:
> 
> I am using this example from the PerlFAQ (5.2) and I 
> don't understand how to reference an array.  I would 
> like to reference the whole array (alphabet) at
> $T{key2}->{k3}.  For the sake of this example, I would 
> like to print out all the elements in this array.
> 
> %T = ( key0, { k0, v0, k1, v1 }, key1, { k2, v2, k3, v3 }, 
> key2, { k2, v2, k3,['a' .. 'z'] } );

@array = @{ $T{key2}->{k3} };

What you have here is a hash entry ($T{key2}) that contains
a reference to another (anonymous) hash. A key in that
hash {k3} contains a reference to an (anonymous) array.

The -> operator dereferences the first hash reference,
so $T{key2}->{k3} gives you the array reference. You
then need to dereference it. Something that might look
a little clearer is:

$ArrayRef = $T{key2}->{k3};
@array = @$ArrayRef;  # @$ to dereference an array ref

The first example above is simply the way to combine the
two statments.

HTH

- Brian


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

Date: Wed, 13 May 1998 09:53:11 +0530
From: "P. Jaishankar" <shankarpj@rhotmail.com>
Subject: Code Formatter for SQL
Message-Id: <3559202F.B3C5C289@rhotmail.com>




Hi,
I would like to know whether there is any utility in perl/ Sybperl which
formats
sql procedures similar to the way cb formats c programs.

Thanx,
Jai









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

Date: Tue, 12 May 1998 23:49:00 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jan8e$ugr$1@cyprus.atlantic.net>

According to ilya@math.ohio-state.edu (Ilya Zakharevich):
>Yes, when I'm on Solaris, I'm forced to use some broken way like
>pfind'ing (grep is absolutely useless unless you know how deep you
>need to search) if I need to lookup DOCs.

Ilya, you're all wet.  Time to quote you to yourself:

>Is somebody twisting your hands to force you make fool of yourself?

 1.  sh$  find /usr/man -type f -print | xargs grep FOO
 2.  zsh$ grep FOO /usr/man/**/*(.)

Try the right tools, like zsh (or at least find!), before complaining
that the tools aren't sharp.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Tue, 12 May 1998 23:51:19 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jancp$uhc$1@cyprus.atlantic.net>

According to Birgitt Funk <birgitt@order.booktraders.com>:
>Tom Christiansen wrote:
>> Despite the confusion of the webblies, Perl has never been nor ever shall
>> be a consumerist toy for the programmatically challenged.
>
>So, I repeat my question, can Perl be the first programming language
>to learn programming with or not ?

I think so.  Having taught a beginning Perl class a few times, I find
Perl's concepts eminently easy to teach.  The only down side is that
the punctuation-heavy syntax can be a bit irritating or intimidating.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 13 May 1998 06:23:59 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jbe9v$af0$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <6jap9f$enu$1@csnews.cs.colorado.edu>:
> In comp.lang.perl.misc, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
> :it is *nix which is tool-challenged.  
> 
> Orwell was here.

Name one *nix tool which is not available on my non-*nix machine.

You are given 3 tries.

Ilya


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

Date: 13 May 1998 06:36:28 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <6jbf1c$au2$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Chip Salzenberg
<chip@mail.atlantic.net>],
who wrote in article <6jan8e$ugr$1@cyprus.atlantic.net>:
> According to ilya@math.ohio-state.edu (Ilya Zakharevich):
> >Yes, when I'm on Solaris, I'm forced to use some broken way like
> >pfind'ing (grep is absolutely useless unless you know how deep you
> >need to search) if I need to lookup DOCs.
> 
> Ilya, you're all wet.  Time to quote you to yourself:
> 
> >Is somebody twisting your hands to force you make fool of yourself?
> 
>  1.  sh$  find /usr/man -type f -print | xargs grep FOO
>  2.  zsh$ grep FOO /usr/man/**/*(.)
> 
> Try the right tools, like zsh (or at least find!), before complaining
> that the tools aren't sharp.

Yet another proof of my point.  One cannot use Perl docs on *nix
without fluency with (4 in your examples) other tools.  

Also: note that the abominations (for a normal Perl user) you
demonstrated *will not* show the manpages.  After they give their
output one would need to manually type all these 12 names of manpages
and inspect them separately.  And what if they say "In Fcntl manpage"?
You need to follow links manually.

Ilya

P.S.  Btw, for those counting keystrokes, here is how you do it with
      online books:
      
      view perl FOO		(xview on Win*)
	   This brings you the "best" page which has FOO (in headers,
		index entries, etc.)
	   If this page is not good enough
	   
      (Mouse-"Search" or Alt-S) FOO (Mouse-"All sections" or Alt-A) ENTER
or
      (Mouse-"Search" or Alt-S) FOO (Mouse-"Index" or Alt-I)	    ENTER
           This brings list of all pages in Perl docs which mention FOO.
		You can now browse these guys (with keyboard or mouse).

If I had source code for the viewer, I would improve it a lot :-( ;-),
but even in this form it is infinitely better than nothing (what man +
zsh + grep + xargs + find are - taken together).


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

Date: 12 May 1998 23:57:05 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: function prototyping
Message-Id: <ltg1ie257y.fsf@asfast.com>

Martin Gregory <mgregory@asc.sps.mot.com> writes:

> Tom Christiansen <tchrist@mox.perl.com> writes:
> 
> >  [courtesy cc of this posting sent to cited author via email]
> > 
> > In comp.lang.perl.misc, 
> >     Martin Gregory <mgregory@asc.sps.mot.com> writes:
> > :> Until you can immediately tell what length(@a) returns
> > :> when @a = (1 .. 1), don't use prototypes.
> > :
> > :Why?
> > :
> > :In otherwords, I knew that length(@a) is 1, but I don't feel any more
> > :confident about function prototypes...
> > 
> > I mean @a = ( 1 .. 10 );
> 
> Ah.  I see that length(@a) is 2.  I have no idea why.  I guess I better
> leave function prototypes alone!

Well, `@a' evaluated in a scalar context yields the number `10', since
there are 10 elements in the array.  Passing `10' to the `length'
function causes the number 10 to be treated as the character string
"10" (since `length' returns the length of the string representation
of its argument).  The length of this 2-character string is 2, and
hence, the return value.

As for why Tom Christiansen made the above statement about function
prototypes ... well, I can't say for sure, because I can't read his
mind.  However, I will venture a guess in an attempt to clarify this
for anyone who might be lost:

In the above example, the `length' function automatically interpreted
its array argument in a scalar context.  This is easy for `length' to
do, because it's a built-in Perl function which is designed to take
only a scalar argument.  However, without function prototypes, it
would be messy for you to write your own Perl function called
`mylength' which would automatically interpret its argument in a
scalar fashion just like `length' does.  But with prototypes, this is
easy.

In other words:

  sub mylength1 {  # no prototype
     my $arg = shift;
     # if an array is passed as an argument, `$arg' will now contain
     # the first element of this array
  }

  sub mylength2($) {  # prototype
     my $arg = shift;
     # the specified prototype causes this function to expect a single
     # scalar argument, and hence, if an array is passed as an argument,
     # it will be scalar-ized before `$arg' is set;  in this case,
     # `$arg' will now contain the number of elements in the array
  }

Search for `Prototypes' in the `perlsub' man pages for a lot more
details about prototypes and how to use them.

-- 
 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: Wed, 13 May 1998 12:45:45 +0800
From: "Chris Fu" <fuc@esquel.com>
Subject: Get file date
Message-Id: <6jb8cm$4or$1@imsp009a.netvigator.com>

Hi everybody,

Anyone knows how to use script to fetch the file date?


Best rgds





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

Date: Wed, 13 May 1998 00:07:22 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <6jaoat$uj5$1@cyprus.atlantic.net>

According to tina@tech.scandinaviaonline.se:
>In article <6j7iml$bp9$1@usenet40.supernews.com>,
>	"Peter Perchansky" <fp@pmpcs.com> writes:
>
>> Look at using "next" and "last".
>
>  Whilst this is a correct answer as far as the question in the subject is
>concerned, methinks it is worth mentioning - and get flamed for as every
>other time I do this :) - that *perhaps* next and last isn't the very
>best things in Perl.

"P" is for "Practical."
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Wed, 13 May 1998 00:10:22 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Is if ($a="something") a bad style?
Message-Id: <6jaogh$ujp$1@cyprus.atlantic.net>

According to Yong Huang <yong@shell.com>:
>In C, we often say
>if (a="something")
>But in Perl, a warning is given.

No it isn't.  What makes you think it is?  (Assuming you correct the
code to say '$a', of course.)
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Tue, 12 May 1998 23:32:36 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <6jam9n$ueh$1@cyprus.atlantic.net>

According to tina@tech.scandinaviaonline.se:
>What *is* asked is that when someone asks to learn about A, he or she
>isn't told to go use B instead. The pupil is told where to find what
>he/she needs to learn what she/he wants to learn - not that something
>else is a better tool.

Your requests are contradictory.

What the user _wants_ and _asks_for_ is A.
What the user _needs_ is B.

Now which answer do you ask for?  Make up your mind, please.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Tue, 12 May 1998 23:35:17 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: MODULE MANIA STRIKES (Was Re: What does this do?)
Message-Id: <6jamen$uf2$1@cyprus.atlantic.net>

According to tina@tech.scandinaviaonline.se:
>In article <35593078.2587571@news.tornado.be>,
>	bart.mediamind@tornado.be (Bart Lateur) writes:
>> The same goes for Perl itself: you MAY NOT expect people to learn the
>> Perl syntax by looking at the Perl compiler source.

Sure; Perl and C are distinct skills.

>  Agreed. However, I want to take this one step further: one MAY NOT expect
>people to learn good, or even correct, Perl programming by reading module
>source code; be those modules everso much from CPAN.

No way.  Perl code is Perl code.  There is no substitute for learning
by example.
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Wed, 13 May 1998 04:44:59 GMT
From: elitegrp@pond.net
Subject: Need Perl command to pull HTML from a remote site. (HTTPGET)??
Message-Id: <6jb8gb$ebu$1@nnrp1.dejanews.com>

Thanks in advance for any assistance I can get!

I am trying to find a command in Perl (possibly HTTPGET??) that will pull
HTML off of a remote site by URL alone.  Also, once this document is pulled
from the remote server, is there a way I can find the date of that file (the
last time it was updated)?

Although I am certain there is no command that does "just that"...I would
surely appreciate any suggestions that anyone would have......tiny code
snippets are also welcomed...just a Perl beginner here trying to make a
script! :)

Krista
elitegrp@pond.net

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 13 May 1998 01:15:56 -0400
From: Boris 'pi' Piwinger <3.14@Math.MIT.edu>
Subject: Re: Need Perl command to pull HTML from a remote site. (HTTPGET)??
Message-Id: <35592ac5.0@news.netway.com>

elitegrp@pond.net wrote:

>I am trying to find a command in Perl (possibly HTTPGET??) that will =
pull
>HTML off of a remote site by URL alone.

Just use lynx.

pi
--=20
Yogi Berra said:
>It's like deja vu all over again!


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

Date: 13 May 1998 06:20:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need Perl command to pull HTML from a remote site. (HTTPGET)??
Message-Id: <6jbe2t$86o$1@comdyn.comdyn.com.au>

[alt.perl? I have never seen that one on any server. Dejanews seems to
have only 17 references to it. perl doesn't belong in alt anyway.
Removed from Newsgroups]

In article <6jb8gb$ebu$1@nnrp1.dejanews.com>,
	elitegrp@pond.net writes:
> Thanks in advance for any assistance I can get!
> 
> I am trying to find a command in Perl (possibly HTTPGET??) that will pull
> HTML off of a remote site by URL alone.  Also, once this document is pulled
> from the remote server, is there a way I can find the date of that file (the
> last time it was updated)?

There is a package of modules out there that does what you want. You
might actually already have it installed. It's called LWP, and you can
get it from CPAN: http://www.perl.com/CPAN/. You can check if it's
installed by 

# perldoc LWP
# perldoc lwpcook
# perl -MLWP -e ""

If the last one fails, it's not installed.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.       | accept as reality - Calvin
NSW, Australia                      | 


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

Date: Tue, 12 May 1998 17:09:57 +0200
From: Heribert Wettels <wettels@respublica.de>
Subject: Re: Perl problem
Message-Id: <35586645.3921939C@respublica.de>

if ($function eq "+") {
    $ans = $a + $b + $c;
}



A.H. Roberts wrote:

> I have just recently started to learn Perl, and have come across a problem
> with something I am trying to do.
>
> Basically I wrote a program to take 3 numbers to <STDIN> ($a, $b and $c),
> then have a symbol typed in and called $function - the sybmol being
> +, -, * or /.
>
> Then the program uses if, elsif and else to either add, subtract, multiply or
> divide depending on $function e.g.
>
> if ($function = "+">
> {
> $ans = $a + $b + $c
> }
>
> The answer was then printed to a new line.
>
> What I am TRYING to do is have $function do this:
>
> $ans = $a $function $b $function $c
>
> and give an answer depending on which operator $function was.
>
> However, as it records $function as a string not an operator it don't work.
>
> IS there a way of doing this?



--
PGP fingerprint =  4B 68 BF FA B0 81 59 F7  E2 86 5C D2 78 B9 37 28
Public key at: http://www.respublica.de/pgp/wettels-pubkey.txt




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

Date: Wed, 13 May 1998 14:35:12 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Perl/Wall lingo question
Message-Id: <35592300.BAFE194@spider.herston.uq.edu.au>

Greg Bacon wrote:
> 
> In article <35528609.125139E8@spider.herston.uq.edu.au>,
>         Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
> : So my vote is for computer science as a branch of Engineering, which is
> : based on anything deemed to be useful.
> 
> Ugh.  CS is as much of an art as it is a science.  I don't think you'll
> find many engineers who'd admit that art is part of what they do.
> 
> Engineers make poor computer science teachers (at least in my
> experience).
> 
> Greg

<sophistry>
Engineers!  That's a whole different subject.  I was talking about
Engineering...
</sophistry>

-- 
Jaime Metcher


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

Date: Wed, 13 May 1998 00:01:29 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Perl/Wall lingo question
Message-Id: <6janvs$ui3$1@cyprus.atlantic.net>

According to Greg Bacon <gbacon@cs.uah.edu>:
>In article <35528609.125139E8@spider.herston.uq.edu.au>,
>	Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
>: So my vote is for computer science as a branch of Engineering, which is
>: based on anything deemed to be useful.
>
>Ugh.  CS is as much of an art as it is a science.  I don't think you'll
>find many engineers who'd admit that art is part of what they do.

Of course you will ... at least as many engineers as programmers.

To paraphrase the otherwise forgettable Dan Bernstein:

  Engineering is achieving desired results with limited means.
  Art is creating things.
  There is no inherent conflict between these activities.

-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Tue, 12 May 1998 23:24:34 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: Randomly sorting an array
Message-Id: <6jalql$udt$1@cyprus.atlantic.net>
Keywords: adieu codebreak staple worthwhile

According to tchrist@mox.perl.com (Tom Christiansen):
>In comp.lang.perl.misc, chip@mail.atlantic.net (Chip Salzenberg) writes:
>:A simpler approach:
>:    sub shuffle {
>:        my @new;
>:        push @new, $_[rand @_] while @_;
>:	@new;
>:    }
>
>And when were you expecting @_ to go false?

*sigh*  I _knew_ I'd forgotten something!  When I thought of it I
used splice(), but there's many a slip 'twixt cup and lip....  Try:

    sub shuffle {
        my @new;
        push @new, splice @_, rand @_, 1 while @_;
	@new;
    }

-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 13 May 1998 05:31:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Randomly sorting an array
Message-Id: <6jbb70$d7f$1@csnews.cs.colorado.edu>
Keywords: adieu codebreak staple worthwhile

In comp.lang.perl.misc, chip@mail.atlantic.net (Chip Salzenberg) writes:
:    sub shuffle {
:        my @new;
:        push @new, splice @_, rand @_, 1 while @_;
:	@new;
:    }

Does it bother you knowing that that's quadratic?

--tom
-- 
I have a different view of the world.  --Andrew Hume. Show&Tell '87


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

Date: Wed, 13 May 1998 05:38:18 GMT
From: dennis_marti@yahoo.com
Subject: Re: Scanning Perl scripts for Y2K problems
Message-Id: <6jbbkb$j2s$1@nnrp1.dejanews.com>

In article <6ja86f$42i$1@ns1.arlut.utexas.edu>,
  smcdow@arlut.utexas.edu (Stuart McDow) wrote:

> $year = (localtime)[5];
> EX1: print "The year is ", 1900 + $year, "\n";  # Y2K
> EX2: print "The year is 19${year}\n";           # not Y2K
>
> I wouldn't be at all surprised to see, in older legacy code, usage
> similar to EX2.

hahaha

Don't be surprised _when_ you find it in code that doesn't exist
today. People write this kind of stuff all the time. There have
been answers using things like EX2 posted to this group in the
last year.

Dennis Marti

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 13 May 1998 00:03:00 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Significant digit?
Message-Id: <1d8xxf6.1jgki791tiijxkN@bay1-73.quincy.ziplink.net>

Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:

> Don't look at the ANSI C standard, look at Perl's documentation for the
> sprintf function:
> 
>     ...The * character as a length specifier is not supported.  But,
>     you can easily get around this by including the length expression
>     directly into FORMAT...

As Tom C. pointed out, this is no longer true.  So, from the
documentation which is actually current (duh!):

    Where a number would appear in the flags, an asterisk ("*") may be
    used instead, in which case Perl uses the next item in the
    parameter list as the given number (that is, as the field width
    or precision). If a field width obtained through "*" is negative,
    it has the same effect as the '-' flag: left-justification.

-- 
 _ / '  _      /         - 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: 12 May 1998 15:02:20 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: Strange behaviour of references...
Message-Id: <6j9o9s$pnu@news.service.uci.edu>

In article <6j84jg$s4t$1@comdyn.comdyn.com.au>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:

>> #!/usr/bin/perl -w
>> 
>> @list=(1..10);
>> print ref(\@list)."\n";      # prints ARRAY... OK
>> print ref(\(1..10))."\n";    # prints ARRAY... that's what I would expect
>
>The last element between the brackets here is an array

To be more specific, what is actually created is a temporary array.
Hence, \(1..10) actually returns a reference to an array with item 1
through 10, and not a list of references for each item denoted in the
range.  An inconsistancy(?) in Perl due to current implementations
of the range operator.

>> #### Even more surprising:
>> print ref(\(1,10..15))."\n";      # prints ARRAY... OK
>
>The last element is an array

Yes, with items 10 through 15.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Tue, 12 May 1998 17:06:23 +0200
From: Heribert Wettels <wettels@respublica.de>
Subject: Re: Stripping HTML Tags from a file
Message-Id: <3558656F.4861ED06@respublica.de>



Hakan Hjelmstrom wrote:

> [CC of this post emailed to author]
> On Mon 11 May 1998 12:53:26 +1200, Matt McKenzie wrote:
> > I have spent days trying various methods including the HTML::Parser,
> > HTML::Filter modules, reading the FAQ's:
> > <snipped from perlfaq9>------How do I remove HTML from a string?
> > #!/usr/bin/perl -p0777
> > s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
> > -----------------------------------
> > I'm not sure how to implement this into my script.
>
> $html_laden_text =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
> would do the trick, but as the FAQ states, using the modules availible
> is safer.
>

or for an array:

foreach $text(@text) {
    $text =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs
}

Heribert

> Hekan Hjelmstrvm
> hawk@algonet.se



--
PGP fingerprint =  4B 68 BF FA B0 81 59 F7  E2 86 5C D2 78 B9 37 28
Public key at: http://www.respublica.de/pgp/wettels-pubkey.txt




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

Date: 13 May 1998 06:22:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Where are pod translators?
Message-Id: <6jbe6a$86o$2@comdyn.comdyn.com.au>

In article <3558F811.9C13756D@starnetinc.com>,
	Daniel Warren <dwarren@starnetinc.com> writes:
> I've downloaded Perl 5.003 for Win32 binary (from ActiveState or maybe
> one of the CPAN mirrors,) but I couldn't find the pod translators in the
> distribution.  I've been unable to find the translators anywhere else on
> CPAN.   I'm particularly interested in pod2LaTeX.  Help?

They come with perl 5.004_04. I am not sure when pod2latex was installed, but
you might have success with perl 5.004_02, the GS port, which you can get from
http://www.perl.com/latest.html.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

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

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