[16863] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4275 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 10 03:05:36 2000

Date: Sun, 10 Sep 2000 00:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968569513-v9-i4275@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 10 Sep 2000     Volume: 9 Number: 4275

Today's topics:
        Count of items is EXCEPTION not RULE (was Re: Little pe (Randal L. Schwartz)
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <kj0@mailcity.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (Randal L. Schwartz)
    Re: Environment variables - how to list them all? <anmcguire@ce.mediaone.net>
    Re: Environment variables - how to list them all? <mbk59@hotmail.com>
    Re: glob() feature = delightful japh <markmccarthy1@home.com>
    Re: glob() feature = delightful japh <christopher_j@uswest.net>
        Help! uploaded .wav files' corrupted. <kenn_mar@hotmail.com>
    Re: Howto debug a perl cgi script <mtaylorlrim@my-deja.com>
    Re: Howto debug a perl cgi scriptB <anmcguire@ce.mediaone.net>
        Insert file into Mysql <nnort@start.no>
        Is there a file rename function? <kenn_mar@hotmail.com>
    Re: Is there a file rename function? jcs@rt.fm
    Re: Is there a file rename function? <jeffp@crusoe.net>
        Little perl annoyance #371: glob <kj0@mailcity.com>
    Re: Little perl annoyance #371: glob <uri@sysarch.com>
    Re: Little perl annoyance #371: glob <kj0@mailcity.com>
    Re: Little perl annoyance #371: glob (Mark-Jason Dominus)
        Llama 3 (was Re: Count of items is EXCEPTION not RULE) <jeffp@crusoe.net>
    Re: Llama 3 (was Re: Count of items is EXCEPTION not RU (brian d foy)
    Re: Llama 3 (was Re: Count of items is EXCEPTION not RU <christopher_j@uswest.net>
    Re: Matching anything but a certain string (Abigail)
    Re: Matching anything but a certain string <godzilla@stomp.stomp.tokyo>
    Re: Packet problem (Joe Smith)
        Perl + CVS operations <godoy@conectiva.com>
    Re: Perl + CVS operations <randy@theory.uwinnipeg.ca>
    Re: Perl game Query (Christopher Tauss)
        RFOL: zap dupes, preserve order <kj0@mailcity.com>
    Re: RFOL: zap dupes, preserve order <jeff@vpservices.com>
    Re: RFOL: zap dupes, preserve order <kj0@mailcity.com>
    Re: RFOL: zap dupes, preserve order <uri@sysarch.com>
    Re: RFOL: zap dupes, preserve order <kj0@mailcity.com>
    Re: RFOL: zap dupes, preserve order <yanick@babyl.sympatico.ca>
    Re: Tk::NumEntry for Win32 <carvdawg@patriot.net>
    Re: what is the best way to get the lastest line from a <anmcguire@ce.mediaone.net>
    Re: zap dupes, preserve order <christopher_j@uswest.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 09 Sep 2000 18:38:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <m1zolh10wt.fsf@halfdome.holdit.com>

>>>>> "kj0" == kj0  <kj0@mailcity.com> writes:

kj0> I was hoping to get the number of files having a particular format by
kj0> using:

kj0>   my $n = glob("${prefix}*");

kj0> but NOOO!  Instead, in this case Perl puts the first element of the
kj0> array in $n, instead of the size of the array.

Why would you have thought this?  There are *more* operators that do
*not* return the "size" in a scalar context than do!  So "size" is the
exception, not the rule.

It just happens that a few *common* operators do return size: @foo,
grep(), split() (with odd side effects) and I forget the other one or
two.  But many others don't, such as glob or getpwnam or comma or
literal slice or regexp match or filehandle read or.....

Remember - returning a size-count is the *exception*, not the rule!

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 9 Sep 2000 22:47:14 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <8pesni$oac$1@panix3.panix.com>

In <m1zolh10wt.fsf@halfdome.holdit.com> merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "kj0" == kj0  <kj0@mailcity.com> writes:

>kj0> I was hoping to get the number of files having a particular format by
>kj0> using:

>kj0>   my $n = glob("${prefix}*");

>kj0> but NOOO!  Instead, in this case Perl puts the first element of the
>kj0> array in $n, instead of the size of the array.

>Why would you have thought this?

My misguided Perl "intuition", I guess, which went something like
this: glob returns a list, a list is (sort of like?) an array,
evaluating an array in a scalar context gives the size of the array,
etc.  This might be ignorant but not entirely unreasonable.


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

Date: 09 Sep 2000 19:56:12 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <m1its50xbn.fsf@halfdome.holdit.com>

>>>>> "kj0" == kj0  <kj0@mailcity.com> writes:

>> Why would you have thought this?

kj0> My misguided Perl "intuition", I guess, which went something like
kj0> this: glob returns a list, a list is (sort of like?) an array,
kj0> evaluating an array in a scalar context gives the size of the array,
kj0> etc.  This might be ignorant but not entirely unreasonable.

It's that leap that seems to be the norm in most of the Perl docs out
there.  To blur a list with an array name is damaging, as you
discovered.  We're very careful in the classes we teach to distinguish
those.  Llama 3 will go even further to break them apart, as we've
found a whole new way to prevent people from ever thinking about
writing @foo[3].

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 9 Sep 2000 20:25:40 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Environment variables - how to list them all?
Message-Id: <Pine.LNX.4.21.0009092025001.8033-100000@hawk.ce.mediaone.net>

On Sat, 9 Sep 2000, Mike Krell quoth:

MK> 
MK> "Abigail" <abigail@foad.org> wrote in message
MK> news:slrn8ri4qb.vlt.abigail@alexandra.foad.org...
MK> 
MK> > $ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'
MK> 
MK> Wow.  I learned a heck of a lot playing around with this snippet.  But I'm
MK> still puzzled by one thing:  "-l" and "$\ = $/" apparently do the same
MK> thing.  Are both necessary?

Try it and find out. :-)

anm
-- 
BEGIN { $\ = $/; $$_ = $_ for qw~ just another perl hacker ~ }
my $J = sub { return \$just }; my $A = sub { return \$another };
my $P = sub { return \$perl }; my $H = sub { return \$hacker  };
print map ucfirst() . " " => ${&$J()}, ${&$A()}, ${&$P()}, ${&$H()};



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

Date: Sat, 9 Sep 2000 22:53:42 -0400
From: "Mike Krell" <mbk59@hotmail.com>
Subject: Re: Environment variables - how to list them all?
Message-Id: <39baf764_4@news3.prserv.net>


"Andrew N. McGuire " <anmcguire@ce.mediaone.net> wrote in message
news:Pine.LNX.4.21.0009092025001.8033-100000@hawk.ce.mediaone.net...

> MK> "-l" and "$\ = $/" apparently do the same
> MK> thing.  Are both necessary?
>
> Try it and find out. :-)

Actually, I did try it, and it made no difference as far as I could tell.

OTOH, Abigail occasionally posts code containing subtleties which elude me.

    Mike, with a flair for understatement





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

Date: Sun, 10 Sep 2000 01:54:03 GMT
From: "Mark McCarthy" <markmccarthy1@home.com>
Subject: Re: glob() feature = delightful japh
Message-Id: <%QBu5.67721$xg1.631076@news1.rdc1.sdca.home.com>


"Jeff Pinyan" <jeffp@crusoe.net> wrote in message
news:Pine.GSO.4.21.0009091508410.23350-100000@crusoe.crusoe.net...
> On Sep 9, Mark-Jason Dominus said:
>
> >In article <Pine.GSO.4.21.0009091049160.23350-100000@crusoe.crusoe.net>
you write:
> >>$_ *= $_ ++;
> >
> >That's excellent.  Thanks.
> >
> >I thought that the option to use a letter as the delimiter for q() had
> >been removed, but I guess not!
>
> If you'd like, the last line can be the more vexing
>
>   print q...reverse;

Ooh that's pretty nasty. I cant get my brain around it atall and docs dont
offer much...

print q...'hello';#gives hello

but why??? Is it concatenating?

Mark
"Justa Future Perl Hacker";





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

Date: Sat, 9 Sep 2000 19:00:58 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: glob() feature = delightful japh
Message-Id: <nXBu5.1419$Ne7.316363@news.uswest.net>


"Mark McCarthy" <markmccarthy1@home.com> wrote:
> Ooh that's pretty nasty. I cant get my brain around it atall and docs dont
> offer much...
>
> print q...'hello';#gives hello
>
> but why??? Is it concatenating?


What if it were this?

print q// . 'hello';


q.. is equivalent to q// and whitespace is ignored, so it could
just as easily be

print q...'hello';

Or, print q.hel..'lo';





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

Date: Sun, 10 Sep 2000 15:52:42 +1200
From: Ken <kenn_mar@hotmail.com>
Subject: Help! uploaded .wav files' corrupted.
Message-Id: <39BB0589.CC27CAAD@hotmail.com>

Hi all,

A script I have using web upload (CGI.pm) corrupts the uploaded .wav
files. But text and graphics are Ok. What's the problem? Anyone with
similar experience? Any successful in doing that?

-Ken



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

Date: Sun, 10 Sep 2000 02:38:32 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Howto debug a perl cgi script
Message-Id: <8pes76$55t$1@nnrp1.deja.com>

Sounds to me like your path to perl on the first line is incorrect.
From a command line type "which perl" to verify.

Mark




In article <8peehr$mfg$1@nnrp1.deja.com>,
  yossariancomputing@my-deja.com wrote:
> Hi,
>
> Not a full time perl programmer, so forgive me if this is rather
> obvious....
>
> However, I have a strange problem.  I have a perl cgi script that
works
> perfectly via my apache 1.3.12 server running perl 5.005_3 at home,
but
> when run via my apache 1.3.9 5.005_2 live webserver, generates a "500
> Internal error", logging the rather *un*helpful "Premature end of
> script headers".
>
> I accept this could be for a variety of reasons (versions,server
> misconfiguration,script error), but I don't even know where to begin
> debugging the problem.  To debug it, I need some information, but
other
> than perl -w, I don't know how to generate what the scripts doing and
> hence why it breaks one place, but not the other....
>
> Can I run it usefully via the command line..i.e. supply the required
> input for it to generate the web page to stdout?  I've tried;
> script "name=value&othername=othervalue", but that doesn't give me
> anything useful....can I get the script to throw out a little more
info
> somehow?
>
> Any light provided on the subject would be most appreciated....I
learnt
> a long time ago not to let stuff like this frustrate me, but even
> so...I'm frustrated ;)
>
> Rgds,
>
> Steve Huckle
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 9 Sep 2000 20:35:17 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Howto debug a perl cgi scriptB
Message-Id: <Pine.LNX.4.21.0009092027300.8033-100000@hawk.ce.mediaone.net>

On 9 Sep 2000, Tony Curtis quoth:

TC> >> On Sat, 09 Sep 2000 23:48:58 GMT,
TC> >> yossariancomputing@my-deja.com said:
TC> 
TC> > Yup helped...I've been at it far too long....couldn't
TC> > see some basic errors....indeed, permissions were
TC> > incorrect on diorectories I need to write to/read from,
TC> > but I've corrected them now...alas to no avail %(
TC> 
TC> Print out the program.  Get as far away from the computer
TC> as you can.  Walk through it by hand.  Spot where the
TC> extraneous output occurs.

Another interesting way is to get yourself a teddy bear, or
voodoo doll, or whatever, and explain the problem to it.  You
would be suprised how many times the bear will tell you the answer. 
I did not make this up, I got the idea from "The Practice of 
Programming" (page 123) by Brian Kernighan and Robert Pike.  It has
saved me from asking embarassing questions to others , now if
only it could help me with the foot-in-mouth syndrome I have here.

:-)

anm
-- 
BEGIN { $\ = $/; $$_ = $_ for qw~ just another perl hacker ~ }
my $J = sub { return \$just }; my $A = sub { return \$another };
my $P = sub { return \$perl }; my $H = sub { return \$hacker  };
print map ucfirst() . " " => ${&$J()}, ${&$A()}, ${&$P()}, ${&$H()};



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

Date: Sun, 10 Sep 2000 05:02:36 +0200
From: Tronn =?iso-8859-1?Q?W=E6rdahl?= <nnort@start.no>
Subject: Insert file into Mysql
Message-Id: <39BAF9CC.E840D593@start.no>

Hello

How do I insert a file(*.mp3) in to a Mysql database(ver 3.22) using
Perl ver 5.005_03 on Redhat 6.2
Could someone help,  prefeer working ex ;-)

Tronn



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

Date: Sun, 10 Sep 2000 17:58:20 +1200
From: Ken <kenn_mar@hotmail.com>
Subject: Is there a file rename function?
Message-Id: <39BB22FC.A929D601@hotmail.com>

Hi all,
The subject title says it all. Any doc on how file rename can be done? I
know I did come across it somewhere but just couldn't recall.

-Ken



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

Date: Sun, 10 Sep 2000 05:53:42 GMT
From: jcs@rt.fm
Subject: Re: Is there a file rename function?
Message-Id: <GlFu5.48024$nq4.718541@news-east.usenetserver.com>

Ken <kenn_mar@hotmail.com> wrote:
> The subject title says it all. Any doc on how file rename can be done? I
> know I did come across it somewhere but just couldn't recall.

perldoc -f rename

-- 
joshua stein <jcs@rt.fm>


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

Date: Sun, 10 Sep 2000 01:56:35 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Is there a file rename function?
Message-Id: <Pine.GSO.4.21.0009100156190.23350-100000@crusoe.crusoe.net>

[posted & mailed]

On Sep 10, Ken said:

>The subject title says it all. Any doc on how file rename can be done? I
>know I did come across it somewhere but just couldn't recall.

Did you try maybe the rename() function?

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: 9 Sep 2000 21:16:37 -0400
From: kj0 <kj0@mailcity.com>
Subject: Little perl annoyance #371: glob
Message-Id: <8pendl$j4f$1@panix3.panix.com>




I was hoping to get the number of files having a particular format by
using:

  my $n = glob("${prefix}*");

but NOOO!  Instead, in this case Perl puts the first element of the
array in $n, instead of the size of the array.  I resorted to the UBE
(ugly but effective) technique:

  my $n = @{ [ glob("${prefix}*") ] };

Actually, this is more like OBE (obscene but effective).

Is there a better way?

kj



  


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

Date: Sun, 10 Sep 2000 01:24:45 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Little perl annoyance #371: glob
Message-Id: <x77l8lhwdf.fsf@home.sysarch.com>

>>>>> "k" == kj0  <kj0@mailcity.com> writes:

  k> I was hoping to get the number of files having a particular format by
  k> using:

  k>   my $n = glob("${prefix}*");

  k> but NOOO!  Instead, in this case Perl puts the first element of the
  k> array in $n, instead of the size of the array.  I resorted to the UBE
  k> (ugly but effective) technique:

  k>   my $n = @{ [ glob("${prefix}*") ] };

  k> Actually, this is more like OBE (obscene but effective).

very obscene. it makes a full copy of the list and throws it away.

the less ugly idiom is used with split. it should work here too:

	my $n = () = glob( blah ) ;

replacing this idiom has been discussed in the perl6 lists.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 9 Sep 2000 22:30:43 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: Little perl annoyance #371: glob
Message-Id: <8peroj$n8r$1@panix3.panix.com>

In <x77l8lhwdf.fsf@home.sysarch.com> Uri Guttman <uri@sysarch.com> writes:

>the less ugly idiom is used with split. it should work here too:

>	my $n = () = glob( blah ) ;

It does work...  What does

  () = glob( blah )

mean?


>replacing this idiom has been discussed in the perl6 lists.

You mean that in future versions of Perl the one liner

>	my $n = () = glob( blah ) ;

may no longer work?



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

Date: 10 Sep 2000 03:28:26 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Little perl annoyance #371: glob
Message-Id: <8pev4q$5t1$1@tikehau.netreach.net>

In article <8pendl$j4f$1@panix3.panix.com>, kj0  <kj0@mailcity.com> wrote:
>
>I was hoping to get the number of files having a particular format by
>using:
>
>  my $n = glob("${prefix}*");
>
>but NOOO!  Instead, in this case Perl puts the first element of the
>array in $n, instead of the size of the array.  

No, that's good, because it means you can write

        while ($n = glob("${prefix}*")) {
          # do something with $n
        }

If it returned the number of entries, you wouldn't be able to get that
behavior without reading the (possibly humongous) result into memory
all at once.



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

Date: Sat, 9 Sep 2000 23:24:50 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Llama 3 (was Re: Count of items is EXCEPTION not RULE)
Message-Id: <Pine.GSO.4.21.0009092324150.23350-100000@crusoe.crusoe.net>

On Sep 9, Randal L. Schwartz said:

>Llama 3 will go even further to break them apart, as we've found a whole
>new way to prevent people from ever thinking about writing @foo[3].

Oh no... what new way is this?

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Sun, 10 Sep 2000 00:22:20 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Llama 3 (was Re: Count of items is EXCEPTION not RULE)
Message-Id: <brian-ya02408000R1009000022200001@news.panix.com>

In article <Pine.GSO.4.21.0009092324150.23350-100000@crusoe.crusoe.net>, japhy@pobox.com posted:

> On Sep 9, Randal L. Schwartz said:
> 
> >Llama 3 will go even further to break them apart, as we've found a whole
> >new way to prevent people from ever thinking about writing @foo[3].
> 
> Oh no... what new way is this?

just wait and see ;)

unless Randal and rootbeer have come up with a new new way, we
introduce arrays in terms of single element access before we talk
about operations on the array as a whole. beat all of that into
the students heads before you show them a slice.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Sat, 9 Sep 2000 22:41:43 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: Llama 3 (was Re: Count of items is EXCEPTION not RULE)
Message-Id: <zaFu5.1497$Ne7.387035@news.uswest.net>

oooo, a Llama 3, cool.

Hrm, it's bad I already know Perl or I'd buy it.




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

Date: 10 Sep 2000 05:22:26 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Matching anything but a certain string
Message-Id: <slrn8rm6im.b1k.abigail@alexandra.foad.org>

Randal L. Schwartz (merlyn@stonehenge.com) wrote on MMDLXVI September
MCMXCIII in <URL:news:m1hf7p2w3h.fsf@halfdome.holdit.com>:
`' 
`'     $word =~ m{
`'       horse                 # start with a horse
`'       (?:                   # and between them
`'         [^pig]+             # permit a run of any uninteresting chars
`'         |                   # or
`'         (?!pig).            # any single character as long as we're not stari
`'                             # at our forbidden string
`'       )*                    # and that's ok 0 or more times
`'       cow                   # and end up at cow
`'     }six;                   # and that's the end
`' 
`' Others will probably have better optimizations, but this will do in a
`' pinch.


Well, `i' and `g' are very uninteresting characters as well. The only 
character to trigger an exception is `p'. Hence, we can optimize to:

    m/horse(?:[^p]+|p(?!ig))*cow/;

And we can optimize the alternation away:

    m/horse[^p]*(?:p+(?!ig)[^p]*)*cow/;




Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Sat, 09 Sep 2000 23:59:26 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Matching anything but a certain string
Message-Id: <39BB314E.ED677201@stomp.stomp.tokyo>

Thomas wrote:
 
> Is there a way to match anything but a certain string?
> For example, I want to match anything but the word "pig".
> If I used [^pig]* then it would not match the letters "p",
> "i", and "g".  But I want those letters to be matched unless
> they are in the word pig.  Does anybody know how to do this?


Oink!

Godzilla!
-- 
Androids And More.
  http://la.znet.com/~callgirl/android.html


TEST SCRIPT:
____________


#!/usr/local/bin/perl

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

$string = "Kira is not really a big fat pig with a Duroc hog's arse.
         Souuuie pig pig pig pig pig!
           Souuuie pig pig pig pig!
             Souuuie pig pig pig!
               Souuuie pig pig!
                Souuuie pig!
                 Souuuuie!
                   pig!";

print "Input:\n\n$string\n\n";

$string =~ s¡pig¡ô¿ô¡gi;

print "Processing:\n\n$string\n\n";

$string =~ s¡not ¡¡;

$string =~ s¡ô¿ô¡pig¡g;

print "Output:\n\n$string";

exit;



PRINTED RESULTS:
________________


Input:

Kira is not really a big fat pig with a Duroc hog's arse.
         Souuuie pig pig pig pig pig!
           Souuuie pig pig pig pig!
             Souuuie pig pig pig!
               Souuuie pig pig!
                Souuuie pig!
                 Souuuuie!
                   pig!

Processing:

Kira is not really a big fat ô¿ô with a Duroc hog's arse.
         Souuuie ô¿ô ô¿ô ô¿ô ô¿ô ô¿ô!
           Souuuie ô¿ô ô¿ô ô¿ô ô¿ô!
             Souuuie ô¿ô ô¿ô ô¿ô!
               Souuuie ô¿ô ô¿ô!
                Souuuie ô¿ô!
                 Souuuuie!
                   ô¿ô!

Output:

Kira is really a big fat pig with a Duroc hog's arse.
         Souuuie pig pig pig pig pig!
           Souuuie pig pig pig pig!
             Souuuie pig pig pig!
               Souuuie pig pig!
                Souuuie pig!
                 Souuuuie!
                   pig!


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

Date: 10 Sep 2000 01:36:34 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Packet problem
Message-Id: <8peoj2$2mld$1@nntp1.ba.best.com>

In article <8pd1da$8g1$1@news8.svr.pol.co.uk>,
King Fu <jon@king-fu.freeserve.co.uk> wrote:
>>     # Build a string with mixed binary and printable characters.
>>     # (This is to simulate a string that came from reading a socket.)
>>     $string = "!\x80m\x87\x00\x00HTTP/1.0 3"; # Build string
>>     print SOCKET $string;
>
>Thanx! doing the above did the trick, obviously what i was doing was missing
>out the "\x" to specify a hex digit. I can't thank you enough. However by
>just sending $string to the socket works fine...why are all those statements
>below required?

You want to send raw binary to sockets.  Either by using raw binary
data you have read from a file/socket, or by carefully building a
binary string.

If you are debugging your code and want to send verbose messages to the
terminal, then you would use the code below to convert to human readable
form before displaying.

>>     # Now convert each byte to two hex digits and a blank.
>>     $hexstring = join " ",
>> map {sprintf "%02X",ord $_}
>> split "",$string; # Build hex string
>>     ($printable = $string) =~ tr /\x20-\x7e/./c; # "." for unprintable
>>     print STDOUT $hexstring," = ",$printable,"\n"; # Readable format

	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 09 Sep 2000 22:44:51 -0300
From: Jorge Godoy <godoy@conectiva.com>
Subject: Perl + CVS operations
Message-Id: <kp4s3pxbos.fsf@dagon.casa>


Hi!


Is there any module to handle CVS commands with Perl? I'm writing some
CGIs to work with our documents and I'd like to make it as modular as
possible. I've written some modules to handle other parts of the
system (image conversion, comparison to see if a file is newer than
some reference, file conversion, etc.) that were specific to our needs
(I've tried making them as generic as possible, but...) and before I
started with this one I wanted to see if somebody had something
already done (I've found nothing on CPAN searching for "CVS"). 



Thanks for any information,
-- 
Godoy. <godoy@conectiva.com>

Departamento de Publicações       Conectiva S.A.
Publishing Department             Conectiva Inc.


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

Date: Sat, 9 Sep 2000 23:17:19 -0500
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Perl + CVS operations
Message-Id: <8pf27g$kvh$1@canopus.cc.umanitoba.ca>

Jorge Godoy <godoy@conectiva.com> wrote
    in message news:kp4s3pxbos.fsf@dagon.casa...

> Is there any module to handle CVS commands with Perl? I'm writing some
> CGIs to work with our documents and I'd like to make it as modular as
> possible. I've written some modules to handle other parts of the
> system (image conversion, comparison to see if a file is newer than
> some reference, file conversion, etc.) that were specific to our needs
> (I've tried making them as generic as possible, but...) and before I
> started with this one I wanted to see if somebody had something
> already done (I've found nothing on CPAN searching for "CVS").
>
What about VCS::CVS? Documentation on it's use is available,
for example, at
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?doc=VCS::CVS

best regards,
randy kobes






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

Date: 10 Sep 2000 06:45:29 GMT
From: ct60@aol.com (Christopher Tauss)
Subject: Re: Perl game Query
Message-Id: <20000910024529.04459.00000466@ng-cs1.aol.com>

>Hi,
>
>> Does anyone know if there is available Perl modules for playing backgammon?
>> Creating such a program is an enormous challenge and I would really like to
>see
>> how others may have attempted it.
>
>Look at http://www.perl.com/pub/language/ppt/src/backgammon/index.html
>HTH,
>--
>Alain & Estelle BARBET
>http://www.alianwebserver.com
>
Thanks for the link.  I could not find any code to look at, but it seems like a
good place to start






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

Date: 9 Sep 2000 21:21:14 -0400
From: kj0 <kj0@mailcity.com>
Subject: RFOL: zap dupes, preserve order
Message-Id: <8penma$jcb$1@panix3.panix.com>




Request For One-Liner
that eliminates duplicates from an array preserving the original order
of the first instances of each element.

KJ

(I'd die of shame to publish my solution to this problem; suffice it
to say that they require more than one line.)


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

Date: Sat, 09 Sep 2000 18:27:58 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: RFOL: zap dupes, preserve order
Message-Id: <39BAE39E.CF68BC2C@vpservices.com>

kj0 wrote:
> 
> Request For One-Liner
> that eliminates duplicates from an array preserving the original order
> of the first instances of each element.
> 
> KJ
> 
> (I'd die of shame to publish my solution to this problem; suffice it
> to say that they require more than one line.)


for (@a) { print unless $h{$_}; $h{$_}=1}

-- 
Jeff


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

Date: 9 Sep 2000 22:20:37 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: RFOL: zap dupes, preserve order
Message-Id: <8per5l$mop$1@panix3.panix.com>

In <39BAE39E.CF68BC2C@vpservices.com> Jeff Zucker <jeff@vpservices.com> writes:

>kj0 wrote:
>> 
>> Request For One-Liner
>> that eliminates duplicates from an array preserving the original order
>> of the first instances of each element.
>> 
>> KJ
>> 
>> (I'd die of shame to publish my solution to this problem; suffice it
>> to say that they require more than one line.)


>for (@a) { print unless $h{$_}; $h{$_}=1}


No, I'm talking about the order-preserving version of

@unique = keys %{ { map { ($_, 1) } @has_repeats } };

KJ


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

Date: Sun, 10 Sep 2000 02:25:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: RFOL: zap dupes, preserve order
Message-Id: <x74s3phtjn.fsf@home.sysarch.com>

>>>>> "k" == kj0  <kj0@mailcity.com> writes:

  >> for (@a) { print unless $h{$_}; $h{$_}=1}


  k> No, I'm talking about the order-preserving version of

  k> @unique = keys %{ { map { ($_, 1) } @has_repeats } };

so just convert that to grep:

@unique = do { my %h; grep !$h{$_}++, @has_repeats } ;

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 9 Sep 2000 22:34:42 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: RFOL: zap dupes, preserve order
Message-Id: <8pes02$nef$1@panix3.panix.com>

In <x74s3phtjn.fsf@home.sysarch.com> Uri Guttman <uri@sysarch.com> writes:

>  k> No, I'm talking about the order-preserving version of

>  k> @unique = keys %{ { map { ($_, 1) } @has_repeats } };

>so just convert that to grep:

>@unique = do { my %h; grep !$h{$_}++, @has_repeats } ;


way cool


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

Date: Sun, 10 Sep 2000 03:14:18 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: RFOL: zap dupes, preserve order
Message-Id: <e0Du5.251428$1h3.4738753@news20.bellglobal.com>

Jeff Zucker <jeff@vpservices.com> wrote:
: kj0 wrote:
:> 
:> Request For One-Liner
:> that eliminates duplicates from an array preserving the original order
:> of the first instances of each element.

: for (@a) { print unless $h{$_}; $h{$_}=1}

	@a=grep!$h{$_}++,@a

/Yanick
-- 
eval" use 'that poor Yanick' ";
print map{ (sort keys %{{ map({$_=>1}split'',$@) }})[hex] }
qw/8 b 15 1 9 10 11 15 c b 13 1 12 b 13 f 1 c 9 a e b 13 0/;


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

Date: Sat, 09 Sep 2000 22:22:11 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Tk::NumEntry for Win32
Message-Id: <39BAF053.687570E3@patriot.net>

Randy,

Thanks.  The GBARR portion of Tk is available from ActiveState...I can
easily
install it via PPM

Thanks again.

Randy Kobes wrote:

> H C <carvdawg@patriot.net> wrote in
>     message news:39BA848F.1FFA9F8E@patriot.net...
> > I have ActivePerl build 615, and the Tk::NumEntry widget isn't
> > included.  Does
> > anyone know where I can get one that works with Win32?
>
> It's in the Tk-GBARR distribution - see, eg,
> http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?mod=Tk::NumEntry
> for a link to the package. After unpacking, you can
> install it with
>     perl Makefile.PL
>     nmake
>     nmake test
>     nmake install
> (get the 'nmake' make program from
> ftp://ftp.microsoft.com/softlib/MSLFILES/nmake15.exe
> if you don't have it). Or, you can use the CPAN.pm
> module to install things:
>     perl -MCPAN -e shell
>     [ possible configuration dialogue]
>     cpan> install Tk::NumEntry
>
> best regards,
> randy kobes

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 10 Sep 2000 01:13:04 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: what is the best way to get the lastest line from a file?
Message-Id: <Pine.LNX.4.21.0009100107410.10599-100000@hawk.ce.mediaone.net>

On Sat, 9 Sep 2000, Rick Delaney quoth:

RD> 
RD> "Andrew N. McGuire" wrote:
RD> > 
RD> > Here is another method, a spoof of your 'count the lines' one
RD> > -liner.  It is slower than tail as well, but cute (I think).
RD> > 
RD> > perl -wne '$l=$_}{print$l' file
RD> 
RD> Another variation:
RD> 
RD>     perl -pe '$l=$_}{$_=$l' file

Yes, I thought about that one later in my car, driving to dinner.
I like that version better because it is shorter and nearly 
symmetrical (sort of aesthetically[sp?] pleasing).

anm
-- 
BEGIN { $\ = $/; $$_ = $_ for qw~ just another perl hacker ~ }
my $J = sub { return \$just }; my $A = sub { return \$another };
my $P = sub { return \$perl }; my $H = sub { return \$hacker  };
print map ucfirst() . " " => ${&$J()}, ${&$A()}, ${&$P()}, ${&$H()};



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

Date: Sat, 9 Sep 2000 18:40:10 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: zap dupes, preserve order
Message-Id: <NDBu5.1384$Ne7.310126@news.uswest.net>

%arr=(); @arr{@arr} = (0..@arr); @arr{values %arr} = (keys %arr); foreach
(sort keys %arr) { push @arr, $arr{$_}; }




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

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


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


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