[16706] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4118 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 11:10:33 2000

Date: Thu, 24 Aug 2000 08:10:20 -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: <967129820-v9-i4118@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 24 Aug 2000     Volume: 9 Number: 4118

Today's topics:
    Re: Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. (Martien Verbruggen)
    Re: Just another silly post. (Abigail)
    Re: lwp post method matt@NOSPAMcipherdesign.com
    Re: MIME Mail help on NT - no sendmail! <hillr@ugsolutions.com>
    Re: Modifying @INC: my problem and solution (any commen (Steve Simmons)
    Re: newbie question - dont flame me filosmith@my-deja.com
    Re: Numberical args from cmdline. <iltzu@sci.invalid>
        Passing Values Problem <jimmyjames@here.com>
    Re: Passing Values Problem <elephant@squirrelgroup.com>
    Re: Perl vs. other scripting languages (Martien Verbruggen)
    Re: perl/Informix <gellyfish@gellyfish.com>
    Re: Perl/MySQL vs ASP/MS-SQL af778@iname.com
    Re: PLEASE HELP !!! What is wrong with Windows... <guenther.degenfelder@datev.de>
    Re: PLEASE HELP !!! What is wrong with Windows... <elephant@squirrelgroup.com>
        Please wait... [was: Perl - Blinking Text] <iltzu@sci.invalid>
    Re: Please wait... [was: Perl - Blinking Text] (Gwyn Judd)
    Re: Please wait... [was: Perl - Blinking Text] (Greg Bacon)
    Re: Rationale Behind 'Use of Uninitialized Value' Warni <newspost@coppit.org>
        Remove a backslash from a string. <news@emailme.nu>
    Re: Remove a backslash from a string. <uackermann@orga.com>
    Re: Remove a backslash from a string. <news@emailme.nu>
    Re: Remove a backslash from a string. <elephant@squirrelgroup.com>
    Re: sorting a hash by key value (I've looked at the TIE <uackermann@orga.com>
        sorting a hash by key value (I've looked at the TIE fun (Eric White)
    Re: Strict and Binary Image Upload <ewald@electronicfrontiers.com>
    Re: TextAreas and Security (Keith Calvert Ivey)
        unpack format question (Fred R. Buck)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 06:19:06 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A504AA.1BBFF40F@yahoo.com>

Abigail wrote:

> Larry Rosler (lr@hpl.hp.com) wrote on MMDL September MCMXCIII in
> <URL:news:MPG.140e112c7fb2144798acd2@nntp.hpl.hp.com>:
> || In article <39A46159.ECE3174@yahoo.com> on Wed, 23 Aug 2000 18:42:17 -
> || 0500, Policy Man <reljr_2@yahoo.com> says...
> || >
> || > I have a challenge for you. Create perl code according to these
> || > requirements:
> ||
> || Your challenge might be more suitable for the Fun With Perl list,
> || fwp@technofile.org
>
> Nah. Halfway the list of arbitrary restrictions, I hit 'n' key with
> the thought 'this is no fun'.
>
> Oh, btw, there's a trivial way around most of the restrictions. Code
> the thing in whatever way you want. Turn the code into a string. Replace
> all characters with octal escapes. Eval it. (And if down the list it's
> mentioned you can't use "eval", there's always s///e and s///ee).
>
> Abigail
> --
> perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT

You of course would fail the single requirement of 'Don't try to be cute'.
So far all I've seen is a juvenile attempt to avoid solving the actual problem.
I expected as much when I first wrote the challenge. I knew that
cheap answers would be the first to come pouring out. As I stated in the
original post: I could just 'use File::Find' and be done with it.

Is the real problem too difficult?



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

Date: Thu, 24 Aug 2000 06:22:47 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A50587.666D6AB9@yahoo.com>

"Joe C. Hecht" wrote:

> > I have a challenge for you.
>
> Is this a homework assignment you need help with?

Does it strike you as one? If so, why?



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

Date: Thu, 24 Aug 2000 06:33:35 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5080F.3FB38B79@yahoo.com>

brian d foy wrote:

> In article <39A48859.B8FA1697@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:
>
> > brian d foy wrote:
>
> > >       eval ( <> )
> > >
> > > and that pretty much takes care of all of the restrictions
> > > given appropriate input.
>
> > @given = glob "/tmp";
> > print join "\n",
>
> those two lines are not in my program.  even that program has
> one more semicolon than you allow.
>
> > eval (<>)  ;
> >
> > apparently produces nothing.
>
> give it some input.  see the docs on the <> operator.
>
> --
> brian d foy
> CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
> Perl Mongers <URL:http://www.perl.org/>

Brian, perhaps I'm unable to communicate the basic fact that
this code must actually function inside a larger body of code. Perhaps
I failed to make that perfectly clear in the original message. The
'print join "\n",' is there to test the output of the challenge code to
visually determine if the code does anything at all. The '@given'
component is a requirment of the original message.

I am aware of the <> operator. I just don't see how it fits with the requirements I made.

Could you give an example of how your program might actually work
with the '@given' array as I specified in the original message.



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

Date: Thu, 24 Aug 2000 23:27:59 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Just another silly post.
Message-Id: <slrn8qa8mv.5ap.mgjv@martien.heliotrope.home>

On Wed, 23 Aug 2000 18:42:17 -0500,
	Policy Man <reljr_2@yahoo.com> wrote:

> -- The code may employ at most a single ';' and then only as the final
> item/character.

Don't need no steenkin' semicolon.

> -- @given may only appear once and must not be modified.

Just replace @ARGV if you need to.

> -- Generous use of whitespace to add clarity is appreciated.

You have a space bar, don't you? :)

> Do not employ:
> -- objects, packages, modules, methods.
> -- '::'
> -- keywords: 'use', 'do', 'require', 'bless', `` (backticks), 'exec',
> 'system', 'fork'.
> -- external programs of any kind.
> -- named variables other than specials like: '$_ @_ $1 $2 $#' etc. and
> the array @given.
> -- named subroutines other than functions included in the basic perl
> 5.xxx install.

You take the fun out of Perl.

Notes: 
- Do not use a csh or derivative for this. bash, zsh, ksh, will do. If
  you can't stand that, escape the exclamation points.
- The wrap is here for the post. it's not necessary or even wanted in
  the real thing.

$ perl -Mstrict -wle 'sub f(){opendir(D,$/=$_)&&map{-d&&!-l&&&f,print} \
    map"$//$_",grep!/^\.\.?$/,readdir D}map{f,print}@ARGV'

\begin[out of order]{quote} 
> The challenge code must not in any way clutter up the name space of a
> program it might be included in.
\end{quote}

You didn't include that it couldn't clobber or overwrite any global
variable values.  If you don't want that to happen, pass an argument to
the sub, and use @_. It's more typing than the above, so I'll leave that
up to you.

> Prize: The sweet feeling of success in the face of a difficult task.

Pfff. 15 minutes for a good feeling? Does that sound familiar? The only
thing difficult about it was the misleading stuff about @given and the
semicolon that could be used.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | This matter is best disposed of from
Commercial Dynamics Pty. Ltd.   | a great height, over water.
NSW, Australia                  | 


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

Date: 24 Aug 2000 15:00:04 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Just another silly post.
Message-Id: <slrn8qae28.tj3.abigail@alexandra.foad.org>

Policy Man (reljr_2@yahoo.com) wrote on MMDL September MCMXCIII in
<URL:news:39A504AA.1BBFF40F@yahoo.com>:
// 
// You of course would fail the single requirement of 'Don't try to be cute'.
// So far all I've seen is a juvenile attempt to avoid solving the actual proble
// I expected as much when I first wrote the challenge. I knew that
// cheap answers would be the first to come pouring out. As I stated in the
// original post: I could just 'use File::Find' and be done with it.
// 
// Is the real problem too difficult?


What "real" problem? You make up a problem that can trivially be
sold by using File::Find, you come with a list of arbitrary, silly,
restrictions, and now you are pissed people don't come with "serious"
solutions? Get real.



Abigail
-- 
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;        
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";


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

Date: Thu, 24 Aug 2000 10:11:12 GMT
From: matt@NOSPAMcipherdesign.com
Subject: Re: lwp post method
Message-Id: <39a4f346.10270418@news.ntlworld.com>

hey all,
ive managed to get this to work. if anyones interested heres how:

first setup cookies, as this is necessary for the asp prog after
logging in.

my $ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "lwpcookies.txt", autosave
=> 1));

then setup a URI, and encode the login parameters using the query-form
method. this is sent by a user agent using the get method.

#make new uri
my $loginUri = new URI::URL $loginUrl;

#encode the login details
$loginUri->query_form(username => $username, password => $password);

then fill in the form details and post it, using the same useragent.

my $messageReq = POST $messageUrl, [ smsToNumbers => $number,
smsMessage => $message
 ];

finally, log out. to do this manually, you press an image button,
which fetches logout.asp, so i can use another get.

my $logoutReq = GET $logoutUrl;

and it all works fine!

thanks again for the help,
matt


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

Date: Thu, 24 Aug 2000 07:08:48 -0700
From: Ron Hill <hillr@ugsolutions.com>
Subject: Re: MIME Mail help on NT - no sendmail!
Message-Id: <39A52C70.4C4B75ED@ugsolutions.com>

Hi Tracy,

Try this
-------------------------------------------------
use strict;
use Mail::Mailer;
use diagnostics;


my $test="This is a test of the mailer program";



my $mailer = Mail::Mailer->new("smtp", "mailserver");
 $mailer ->open({'From'    =>'me@myplace.com',
                           'To'      =>'you@yourplace.com',
                           'Subject' =>'test'});


print $mailer $test;
----------------------------------------------------------------------
After you compose your mime message you must stringify it so you can send it:
    $a= $top->stringify;

after you do this step simply
print $mailer $a;


Tracy Terrell wrote:

> > > Hey folks, here is an easy one (I bet) ...
> > >
> > > # I'm looking for a "MailTools" replacement for this block.....
> > > open MAIL, "| /usr/lib/sendmail -t -i" or die "open: $!";
> > > $top->print(\*MAIL);
> > > close MAIL;
> >
> > Install one of the windows ports of sendmail?
> >
> > Wyzelli
> >
>
> Well, I'm sure that would work, but I'm already using MailTools to send "no
> attachment" emails in other scripts and would like to stick to one mechanism
> for sending mail (to the degree that it still makes sense...) - if for no
> other reason than to keep overall maintenance straightforward.  Thanks for
> the suggesstion.
>
> T



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

Date: Thu, 24 Aug 2000 15:03:23 GMT
From: scs@ans.net (Steve Simmons)
Subject: Re: Modifying @INC: my problem and solution (any comment?)
Message-Id: <%Oap5.1$n23.24@news.aa.ans.net>

hasant@trabas.com writes:

>The Problem

>Determine a non-standard module path dynamically in the scripts.

We ran into a different flavor of the problem; here's our problem
and (probable) solution:

We release new versions of tools (which are often perl scripts) with
the name `newtool' or `tool.new'.  Once we're convinced they're working
right, they are rotated to production use.

Sometimes the modifications to a tool must be matched to modifications
to an internal module.  The modified module cannot be released directly;
doing so puts current performance of every tool using it at risk.

Our desire -- have tools check their name, and if it starts with
`new', load a different (newer) module.

Probable Solution --

A subdirectory named `new' is created underneath our product library
tree (not the standard perl library).  If the production copy of
Module.pm lives in $TLIB, the new version will live in $TLIB/new.
At the top of all tools which use Module.pm, this boiler plate is
placed:

> #-----------------------------------------------------------------------
> # `new' versions of tools (named either tool.new or newtool) should
> # get the `new' version of Module, etc.  Non-new tools should get the
> # non-new versions.  This BEGIN block takes care of that sort of thing.
> # If you use something other than Module, set the path and module name
> # appropriately.
> #-----------------------------------------------------------------------
> 
> use  lib '/usr/local/pkg/bdtools/lib';
> BEGIN {
>     my $TOOL = basename( $0 ) ;
>     if ( $TOOL =~ /(.*\.new$|new.*$)/ ) {
>         #print "new tool $TOOL requiring 'Module' with new in lib\n" ;
>         eval "use lib qw(/usr/local/pkg/bdtools/lib/new);use Module";
>     } else {
>         #print "Std tool $TOOL requiring 'Module' without new in lib\n" ;
>         eval "use Module";
>     }
> }

Why do I say `probable' solution?  Because similar code has worked in my
tests, but the first release of a `newtool' won't this code won't happen
until next month.

For a longer term (translation: better) solution, see my proposed perl6
versioning mechanism at http://tmtowtdi.perl.org/rfc/78.pod.  Comments
are appreciated.
--
   ``Just imagine we are meeting the aliens for the first time.  Most
people would just shoot them to see how many points they are worth.''
      Simon Cozens in msg <20000803081115.A31631@justanother.perlhacker.org>


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

Date: Thu, 24 Aug 2000 12:54:27 GMT
From: filosmith@my-deja.com
Subject: Re: newbie question - dont flame me
Message-Id: <8o35tr$dm4$1@nnrp1.deja.com>

You guys ROCK. I am really grateful for all your help. It works like I
wanted it to now - not like I wrote it to. I'm going to get a book or
something.

Thanks again,
Filo


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


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

Date: 24 Aug 2000 11:01:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Numberical args from cmdline.
Message-Id: <967114502.26989@itz.pp.sci.fi>

In article <39A4B085.C321F80E@oshconsulting.com>, Kirk Haines wrote:
>Uri Guttman wrote:
>> >>>>> "KH" == Kirk Haines <khaines@oshconsulting.com> writes:
>>   KH> my $n = shift;
>>   KH> die "need number.\n" if $n eq undef;
>> jeez, when will people learn that the only way to test for undef is with
>> defined.
>Jeez, when will people learn not to be rude randomly?

Jeez, when will people learn not to take corrections as insults?


>(my $n = shift) ne undef or die "need number.\n";
>defined(my $n = shift) or die "need number.\n";
>
>Functionally, the two perform identically, however.

They don't.  That's the point Uri was making.

The second one tests whether $n is defined.  The first one stringifies
$n and compares it to the empty string, generating one or two warnings
in the process.  When will people learn to test their code?  With -w?

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: Thu, 24 Aug 2000 11:49:53 -0300
From: jimmyjames <jimmyjames@here.com>
Subject: Passing Values Problem
Message-Id: <39A53611.27C56611@hotmail.com>

I am very new to Perl and I am trying to work with a site that has many
Perl scripts involved. I was wondering if I could get some help with
what I assume are fairly simple problems:

In one script I run this form:

print "<H2>Please choose the location(either start or
destination)</H2>";
print "<form method=post
action='http://134.190.5.4/cgi-bin/placeredirect2.pl'>$
print "<select name='place'>";
#A bunch of selections are here
print "</select>";

#and before the end of the form I try to pass thorugh a bunch of values
with lines like this:

print " <INPUT TYPE = hidden NAME = origin_index_x VALUE = $coordx>\n";
print " <INPUT TYPE = hidden NAME = origin_index_y VALUE = $coordy>\n";

#and then at the end I've got this

print "<input type='submit' value='&nbsp; Go To Location &nbsp;'> ";
print "</FORM>\n";

If I look at the source for this page before I click the 'Go To
Location' button, I have all of the data that I need. I guess my
question is:

What do I need in my second script to get all of that data?

Any help is appreciated

Thanks, Andrew




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

Date: Thu, 24 Aug 2000 15:04:50 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Passing Values Problem
Message-Id: <MPG.140fd706816a53b59896e8@localhost>

jimmyjames <jimmyjames@here.com> wrote ..

  <life story snipped>

>What do I need in my second script to get all of that data?

a program .. I mean seriously - what do you expect ? .. want someone to 
write the program for free ? .. I mean are they advertising this 
newsgroup at the Dinky Toy Web Programming For Dummies course ? .. I 
just don't get this roll on your back and ask complete strangers to 
scratch your tummy attitude

go away .. get a book .. read some documentation .. I mean - have you 
even installed Perl yet ? (the code you supplied doesn't compile)

if you've installed Perl then start reading .. start by typing this at 
the command line

  perldoc perldoc

and take it from there

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 24 Aug 2000 21:06:10 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Perl vs. other scripting languages
Message-Id: <slrn8qa0d2.5ap.mgjv@martien.heliotrope.home>

On Thu, 24 Aug 2000 00:25:26 -0700,
	Godzilla! <godzilla@stomp.stomp.tokyo> wrote:

[fsck. Am I sorry that your score expired just this morning. You've got
a fresh, and this time more permanent one. tata]

To anyone not yet clued in: Mussolini made more sense on his bad days
than this troll on its good days.

Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: Thu, 24 Aug 2000 11:24:28 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: perl/Informix
Message-Id: <MB7p5.208$pD2.17314@news.dircon.co.uk>

On Thu, 24 Aug 2000 00:20:29 GMT, jblatz2@my-deja.com Wrote:
> We are using perl to insert rows into an Informix table.  We are using:
> 
>   Online Dynamic Server ver 7.24
>   Perl ver 5.004
>   Unix on a Siemens platform
> 
> The database is non-logging.
> 
> When we run the program it inserts 2408 of 16,683 rows and then hangs.
> 
> 'onstat -u' looks normal.
> 
> There are no messages in the online log or in any system logs
> indicating a problem.
> 
> The machine that hangs at 2408 rows has 1.5 gig of memory.  When we
> run the same program on another machine that has 3 gig of memory it
> inserts more rows (about 3000 - it varies) but still ends up hanging.
> 

Does the same insert done via dbaccess do the same ?

You might get more help if you posted the absolutely smallest piece of
code that will run and produce the same result - I'm thinking no more than
about ten lines should be sufficient.

You may also want to ask in comp.databases.informix

/J\


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

Date: Thu, 24 Aug 2000 11:00:51 GMT
From: af778@iname.com
Subject: Re: Perl/MySQL vs ASP/MS-SQL
Message-Id: <8o2v8s$6ie$1@nnrp1.deja.com>

Friends,
Thank you very much for your time and support. it has been very useful
for me.

Claudio


--------------------------------------------------------------------
Registrá tu dominio .COM por solo $ 14.95 por año.
http://www.registrolibre.com






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


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

Date: Thu, 24 Aug 2000 16:09:53 +0200
From: "Guenther Degenfelder" <guenther.degenfelder@datev.de>
Subject: Re: PLEASE HELP !!! What is wrong with Windows...
Message-Id: <39a52d41$1@news.datev.de>


"comet999" <comet999@my-deja.com> schrieb im Newsbeitrag
news:8nunms$b2k$1@nnrp1.deja.com...
> Hi,
>
> I'm using the following code to dump the contents of a db ("cats.db")
 ...
> %cats = &readdatabase("h:\data\cats");

Don't confuse your filepaths with backslashes!

Better write
    %cats = &readdatabase("h:/data/cats");
The slash ('/') has on WinXY the same maening like it has on Unix (but only
from Perl ;-).

Regards

    Guenther




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

Date: Thu, 24 Aug 2000 15:01:49 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: PLEASE HELP !!! What is wrong with Windows...
Message-Id: <MPG.140fd64f3b5d6d799896e7@localhost>

Guenther Degenfelder <guenther.degenfelder@datev.de> wrote ..
>
>"comet999" <comet999@my-deja.com> schrieb im Newsbeitrag
>news:8nunms$b2k$1@nnrp1.deja.com...
>> Hi,
>>
>> I'm using the following code to dump the contents of a db ("cats.db")
>...
>> %cats = &readdatabase("h:\data\cats");
>
>Don't confuse your filepaths with backslashes!
>
>Better write
>    %cats = &readdatabase("h:/data/cats");
>The slash ('/') has on WinXY the same maening like it has on Unix (but only
>from Perl ;-).

not 'only' .. just not from the shell

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 24 Aug 2000 12:00:00 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Please wait... [was: Perl - Blinking Text]
Message-Id: <967117675.6043@itz.pp.sci.fi>

In article <spiq6bsdkn9171@corp.supernews.com>, Greg Bacon wrote:
>In article <20000815111353.00174.00003174@ng-ch1.aol.com>,
>    Louis <louis@aol.com> wrote:
>: Hi.  While my perl script is processing, I would like the print line
>: "Please wait, processing data .. " to blink at the command line
>: (UNIX).  Does anyone know how I can get the text to blink?
>
>Yuck.  Just say no.  How about a spinner?

Twirling batons are rather cliche, though.  If you're going to have
your users staring at a "please wait" message, the least you could do
is make it a little bit interesting.

  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
	   => pack "v" => $i while ++$i and sleep 1'

  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
	   => pack "v" => $i^$i/2 while ++$i and sleep 1'

Here are two I came up with right now - I can't decide which one I
like more.  All it takes is a bit of creativity.

[Crossposted from comp.lang.perl.misc to alt.ascii-art.animation.]

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla  | "By promoting postconditions to
and its pseudonyms -    |  preconditions, algorithms become
do not feed the troll.  |  remarkably simple."  -- Abigail



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

Date: Thu, 24 Aug 2000 13:57:55 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Message-Id: <slrn8qaaf0.fkn.tjla@thislove.dyndns.org>

I was shocked! How could Ilmari Karonen <iltzu@sci.invalid>
say such a terrible thing:

>Twirling batons are rather cliche, though.  If you're going to have
>your users staring at a "please wait" message, the least you could do
>is make it a little bit interesting.
>
>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>	   => pack "v" => $i while ++$i and sleep 1'
>
>  perl -e '$|=1; print "\rPlease wait", grep tr/01/ ./ => unpack "b*"
>	   => pack "v" => $i^$i/2 while ++$i and sleep 1'

rand $i makes a nice effect too :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Boob's Law:
	You always find something in the last place you look.


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

Date: Thu, 24 Aug 2000 14:50:10 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Message-Id: <sqadh2gut91134@corp.supernews.com>

In article <967117675.6043@itz.pp.sci.fi>,
    Ilmari Karonen  <usenet11193@itz.pp.sci.fi> wrote:

: Twirling batons are rather cliche, though.  If you're going to have
: your users staring at a "please wait" message, the least you could do
: is make it a little bit interesting.

How about this?

    sub bubbles {
        my @bubble = (' ', '.', 'o', 'O');
        my $len = 10;
        my $tank = join '',
                   map $bubble[rand @bubble],
                   1 .. $len;

        my $tmp;
        while (1) {
            print "\rPlease wait $tank";

            $tank =~ s/(OO+)/$tmp = ' ' x length $1;
                             substr($tmp, rand length $1, 1) = 'O';
                             $tmp/eg;

            $tank =~ s/oo/     rand() < 0.5 ? 'O ' : ' O'/eg;
            $tank =~ s/\.\./   rand() < 0.5 ? 'o ' : ' o'/eg;
            $tank =~ s/Oo/     rand() < 0.5 ? 'O ' : ' O'/egi;
            $tank =~ s/\.o|o\./rand() < 0.5 ? 'o ' : ' o'/eg;
            $tank =~ s/\.O|O\./rand() < 0.5 ? 'oO' : 'Oo'/eg;

            while (rand() < 0.6) {
                substr($tank, rand $len, 1) = $bubble[rand @bubble];
            }

            select undef, undef, undef, 0.2;
        }
    }

Greg
-- 
Windows was created to keep the stoopid people away from Unix, you know.
An "MS advocate" is already beneath contempt.
    -- Tom Christiansen


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

Date: Thu, 24 Aug 2000 09:52:03 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: Rationale Behind 'Use of Uninitialized Value' Warning
Message-Id: <Pine.GSO.4.21.0008240946540.28781-100000@mamba.cs.Virginia.EDU>

On Tue, 22 Aug 2000, Gabe wrote:

> I have not been using -w because I don't like getting all the "Use of
> Uninitialized Value" warnings. What's the value of the warning? Why is it
> better to say "my $foo = '';" as opposed to "my $foo;"?

Check this out:
-------------
sub foo
{
  my $a = shift;
  print "match" if $a =~ /foo/;
}

foo(1);

# Oops. Forgot argument.
foo();
-------------

The latter raises an undefined value warning. The first consideration
for any code is whether it is correct. Use of undefined values is an
indication that the code is sloppy, and therefore prone to bugs. Using
a little discipline (use strict, -w, etc.) can go a long way to
preventing subtle bugs as the size of the code base grows.

David



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

Date: Thu, 24 Aug 2000 16:08:37 +0200
From: Steven <news@emailme.nu>
Subject: Remove a backslash from a string.
Message-Id: <39A52C65.F7CC5E55@emailme.nu>

Hi All,

I have this string and I want to remove the backslash (\) from it.


This code removes the + character

#!/usr/bin/perl
$itemvalue = 'steven+';
$itemvalue =~ tr/+/ /;
print "Content-type: text/html\n\n";
print "$itemvalue";

But how does it work for the backslash? I keep on getting internal
server errors!??

Thanks for any help!


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

Date: Thu, 24 Aug 2000 16:17:03 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: Remove a backslash from a string.
Message-Id: <39A52E5F.86ACC0C8@orga.com>

Steven wrote:
> 
> Hi All,
> 
> I have this string and I want to remove the backslash (\) from it.
> 
> This code removes the + character
> 
> #!/usr/bin/perl
> $itemvalue = 'steven+';
> $itemvalue =~ tr/+/ /;
                    ^^^
This replaces your '+' by a ' ' (space)

> print "Content-type: text/html\n\n";
> print "$itemvalue";
> 
> But how does it work for the backslash? I keep on getting internal
> server errors!??
> 
> Thanks for any help!

Did you mask your backslash? Maybe
    $itemvalue =~ s/\\//;
does what you where looking for.

Ulrich
-- 
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 
mailto:uackermann@orga.com



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

Date: Thu, 24 Aug 2000 16:35:00 +0200
From: Steven <news@emailme.nu>
Subject: Re: Remove a backslash from a string.
Message-Id: <39A53294.A9A1F1C1@emailme.nu>



Ulrich Ackermann wrote:

> > But how does it work for the backslash? I keep on getting internal
> > server errors!??
> >
> > Thanks for any help!
> 
> Did you mask your backslash? Maybe
>     $itemvalue =~ s/\\//;
> does what you where looking for.
> 

Thanks man! That was what I was looking for!

Regards,
Steven.


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

Date: Thu, 24 Aug 2000 14:57:07 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Remove a backslash from a string.
Message-Id: <MPG.140fd5341cc779f19896e6@localhost>

Steven <news@emailme.nu> wrote ..
>I have this string and I want to remove the backslash (\) from it.
>
>
>This code removes the + character
>
>#!/usr/bin/perl
                 ^^...missing -w
 ^^^^^^^^^^...missing use strict;

>$itemvalue = 'steven+';
 ^...missing my

>$itemvalue =~ tr/+/ /;
>print "Content-type: text/html\n\n";
>print "$itemvalue";
>
>But how does it work for the backslash? I keep on getting internal
>server errors!??

like a lot of environments the backslash in Perl escapes whatever it 
follows within a double-quoted string .. and escapes a couple of things 
in a single quoted string (like itself and the single quote)

so .. if you try

  tr/\/ /;

then Perl sees the backslash and recognises that you want the following 
character (the '/') escaped .. so it does and it's trying to parse a tr 
that has only two '/'s

to transliterate the backslash character itself then you have to escape 
it

more information in the perlop manual .. and some stuff in perldata is 
worth reading too

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Thu, 24 Aug 2000 16:07:49 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: sorting a hash by key value (I've looked at the TIE functions and  I'm still confused...)
Message-Id: <39A52C35.F3E31B67@orga.com>

Eric White wrote:
> 
>  Hello,
> 
> I'm using CGI.pm and one thing I'm trying to do is use a hash for my values
> and labels in a checkbox_group form.  Everything works, but now I'd like to
> have the labels displayed in the value order, not the default order of the
> hash.  I'm not sure how to do this.
> 
>  Here's what I've got now:
> 
>          #we look at all the related adults
>          my(@relatives) = qw(B1B B2B B3B B4B B5B B6B B9B B10B B11B B12B B16B);
> 
>          foreach $rel (@relatives) {
>                  if (param("$rel") eq '1') {
>                          $care{"1"} = "Primary Caregiver";
>                  } elsif (param("$rel") eq '2') {
>                          $care{"2"} = "Secondary Caregiver";
>                  } elsif (param("$rel") eq '3') {
>                          $care{"3"} = "Other Adult Relative";
>                  }
>          }
> 
> 
>          #and then the non-relative adults
>          my(@nonrel) = qw(B7B B8B B17B);
>          foreach $nonrel (@nonrel) {
>                  if (param("$nonrel") eq '1') {
>                          $care{"1"} = "Primary Caregiver";
>                  } elsif (param("$nonrel") eq '2') {
>                          $care{"2"} = "Secondary Caregiver";
>                  } elsif (param("$nonrel") eq '3') {
>                          $care{"4"} = "Non-Relative Adult";
>                  }
>          }
> 
>          #and then the sibs or other child relative
>          my(@sib_oth) = qw(B13B B13B2 B13B3 B14B B14B2 B14B3 B15B B15B2
> B15B3);
>          foreach $sib_oth (@sib_oth) {
>                  if (param("$sib_oth") >= 1 ) {
>                          $care{"5"} = "Sibling or Other Dependent Child";
>                  }
>          }
> 
>          #we're always going to have these 2 on the list
>          $care{"97"} = "Other";
>          $care{"98"} = "Unknown / Don't Know";
> 
> 
>          return %care;
>  }
> 
> 
>  ************
>  and from the page using %care....
> 
>          strong("D1A2. "),
>          "Who were the caregivers?",
>          p,
>                  checkbox_group(-name=>'D1A2', -linebreak=>1, Values=>\%care),
>          p,
> 
>  *************
> 
> 
>  What I'd like is for the values always to be displayed in order from 1 - 98
> (the key values).  I've tried a variety of methods and I've looked at the
> IxHash module but I can't find anything that allows me just refer to or create
> a %hash in default value order.  Can I do what I'm trying to do?
> 
>  Thanks very much for any help!
> 
>  Eric
perldoc -q sort
	-> How do I sort a hash (optionally by value instead of key)?

Ulrich
-- 
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 
mailto:uackermann@orga.com



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

Date: Thu, 24 Aug 2000 13:26:44 GMT
From: ejwhite1@facstaff.wisc.edu (Eric White)
Subject: sorting a hash by key value (I've looked at the TIE functions and I'm still confused...)
Message-Id: <8o37e7$mq6$1@news.doit.wisc.edu>

 Hello,
 
I'm using CGI.pm and one thing I'm trying to do is use a hash for my values 
and labels in a checkbox_group form.  Everything works, but now I'd like to 
have the labels displayed in the value order, not the default order of the 
hash.  I'm not sure how to do this.  
 
 Here's what I've got now:
 
         #we look at all the related adults
         my(@relatives) = qw(B1B B2B B3B B4B B5B B6B B9B B10B B11B B12B B16B);
 
         foreach $rel (@relatives) {
                 if (param("$rel") eq '1') {
                         $care{"1"} = "Primary Caregiver";
                 } elsif (param("$rel") eq '2') {
                         $care{"2"} = "Secondary Caregiver";
                 } elsif (param("$rel") eq '3') {
                         $care{"3"} = "Other Adult Relative";
                 }
         }
                                                                    
 
         #and then the non-relative adults
         my(@nonrel) = qw(B7B B8B B17B);
         foreach $nonrel (@nonrel) {
                 if (param("$nonrel") eq '1') {
                         $care{"1"} = "Primary Caregiver";
                 } elsif (param("$nonrel") eq '2') {
                         $care{"2"} = "Secondary Caregiver";
                 } elsif (param("$nonrel") eq '3') {
                         $care{"4"} = "Non-Relative Adult";
                 }
         }                                         
 
         #and then the sibs or other child relative
         my(@sib_oth) = qw(B13B B13B2 B13B3 B14B B14B2 B14B3 B15B B15B2 
B15B3);
         foreach $sib_oth (@sib_oth) {
                 if (param("$sib_oth") >= 1 ) {
                         $care{"5"} = "Sibling or Other Dependent Child";
                 }
         }                                         
                                                           
         #we're always going to have these 2 on the list          
         $care{"97"} = "Other";
         $care{"98"} = "Unknown / Don't Know";                                 
                   
 
         return %care;
 }
 
 
 ************
 and from the page using %care....
 
         strong("D1A2. "),
         "Who were the caregivers?",
         p,
                 checkbox_group(-name=>'D1A2', -linebreak=>1, Values=>\%care),
         p,
 
 *************
 
 
 What I'd like is for the values always to be displayed in order from 1 - 98 
(the key values).  I've tried a variety of methods and I've looked at the 
IxHash module but I can't find anything that allows me just refer to or create 
a %hash in default value order.  Can I do what I'm trying to do?
 
 Thanks very much for any help!
 
 Eric


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

Date: Thu, 24 Aug 2000 09:08:41 -0400
From: Ed Waldspurger <ewald@electronicfrontiers.com>
Subject: Re: Strict and Binary Image Upload
Message-Id: <MPG.140ee866e9e44365989685@news.mtcibs.com>

In article <u9n1i313pg.fsf@wcl-l.bham.ac.uk>, nobull@mail.com says...
> Ed Waldspurger <ewald@electronicfrontiers.com> writes:
> 
> > I am trying to upload a binary image file using CGI.pm and am having 
> > trouble with strict.
> 
> perldoc CGI
> 
> Read the section that follows the sentence "If you use strict, then
> Perl will complain when you try to use a string as a filehandle."
> 
> 
Thanks for the info.  I read the perl docs on references and strict, but 
was relying on the "Official Guide to Programming with CGI.pm" for info 
on the CGI module. No mention of the strict problem there.  Next time 
I'll read "ALL" the docs.


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

Date: Thu, 24 Aug 2000 13:38:19 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: TextAreas and Security
Message-Id: <39ae244f.48900197@news.newsguy.com>

Eric Benson <j-e-b@swbell.net> wrote:

>I have a Perl book that has the following quotes:
>
>"...it would be relatively simple for a visitor...to crank up a file
>transfer and dump a few megabytes of garbage (into a Text of TextArea
>input field)."
[snip]
>Of course, the Text tag in HTML has a MAXLENGTH attribute which will
>prevent this.

The MAXLENGTH attribute of the INPUT tag doesn't protect you at
all.  People trying to crash your site aren't going to be using
the form -- they're going to be sending data directly to your
program.  So program defensively, whatever form controls you're
using.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 14:34:31 GMT
From: frbuck@bell-labs.com (Fred R. Buck)
Subject: unpack format question
Message-Id: <39a5319f.71040400@nntpa.cb.lucent.com>

open(hBinFile, "<$ARGV[0]") or die "could not open $ARGV[0] as
hBinFile";
binmode(hBinFile);
	read (hBinFile, $header, 4+4+2+4+128+4+4);
	($id, $idx, $count, $length, @binblock, $progn, $pcount) =
unpack('IISIC128II', $header);

given the script fragment above my problem is the number of bytes
extracted into @binblock.  When I run the script $#binblock yields 129
and empty values for $progn and $pcount. $id, $idx, $count and $length
all contain appropriate values after the unpack.  

If I increase the read size so more data is available and add
additional "I"'s to the format $#binblock increases by 1 for each
additional "I" I add to the format.



Why?  I thought that counts i.e. C128  were absolute limits. 



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

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


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