[15766] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3179 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 26 18:15:50 2000

Date: Fri, 26 May 2000 15:15:25 -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: <959379325-v9-i3179@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 26 May 2000     Volume: 9 Number: 3179

Today's topics:
    Re: seeking method to encode email addresses in web pag <dave@dave.org.uk>
    Re: seeking method to encode email addresses in web pag <godzilla@stomp.stomp.tokyo>
    Re: seeking method to encode email addresses in web pag <godzilla@stomp.stomp.tokyo>
    Re: seeking method to encode email addresses in web pag <lr@hpl.hp.com>
    Re: seeking method to encode email addresses in web pag <godzilla@stomp.stomp.tokyo>
    Re: seeking method to encode email addresses in web pag <lr@hpl.hp.com>
    Re: seeking method to encode email addresses in web pag <godzilla@stomp.stomp.tokyo>
    Re: Sybperl/dump database (Abigail)
    Re: thanks <bachelart.pierre@skynet.be>
    Re: updated : Re: regexes *sigh* damn I hate these thin (Bart Lateur)
    Re: using param() and CGI.pm to store a persistent valu <csorensen@uptimeresources.net>
    Re: using param() and CGI.pm to store a persistent valu <lr@hpl.hp.com>
    Re: using param() and CGI.pm to store a persistent valu <dmeyers@panix.com>
    Re: What package does "xsubpp" belong to and where are  (Yitzchak Scott-Thoennes)
    Re: What web url to send scripts to the world??? <mariska@excite.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 26 May 2000 19:09:52 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <6eftisguui479dh4mbc9utf51gmnmp5omp@4ax.com>

On 26 May 2000 16:17:59 GMT, The WebDragon <nospam@devnull.com> wrote:

>other than that, interesting trick with the sprintf... I wasn't aware 
>one could do that. :)

It's far easier using 'pack' and 'unpack'.

hth,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk
yapc::Europe - London, 22 - 24 Sep <http://www.yapc.org/Europe/>

"There ain't half been some clever bastards" - Ian Dury [RIP]


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

Date: Fri, 26 May 2000 11:56:07 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <392EC8C7.37D16241@stomp.stomp.tokyo>

Dave Cross wrote:
 
> On 26 May 2000 16:17:59 GMT, The WebDragon <nospam@devnull.com> wrote:
 
> >other than that, interesting trick with the sprintf... I wasn't aware
> >one could do that. :)
 
> It's far easier using 'pack' and 'unpack'.
 
In which ways is use of pack easier? Less
typing?

Is there sufficient rationale to justify
use of one over the other? Might be both
perform the same basic functions and produce
the same results?

Godzilla!


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

Date: Fri, 26 May 2000 12:00:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <392EC9C9.491E94B3@stomp.stomp.tokyo>

Dave Cross wrote:
 
> On 26 May 2000 16:17:59 GMT, The WebDragon <nospam@devnull.com> wrote:
 
> >other than that, interesting trick with the sprintf... I wasn't aware
> >one could do that. :)
 
> It's far easier using 'pack' and 'unpack'.


=~ s/%(..)/pack("c",hex($1))/ge;

=~ s/([0-9A-Fa-f]{2})/ sprintf("%c",hex($1)) /ge ;

Which is best and why?

Godzilla!


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

Date: Fri, 26 May 2000 13:03:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <MPG.139878859a5bd9d898aaec@nntp.hpl.hp.com>

In article <392EC9C9.491E94B3@stomp.stomp.tokyo> on Fri, 26 May 2000 
12:00:25 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> Dave Cross wrote:
>  
> > On 26 May 2000 16:17:59 GMT, The WebDragon <nospam@devnull.com> wrote:
>  
> > >other than that, interesting trick with the sprintf... I wasn't aware
> > >one could do that. :)
>  
> > It's far easier using 'pack' and 'unpack'.
> 
> 
> =~ s/%(..)/pack("c",hex($1))/ge;
> 
> =~ s/([0-9A-Fa-f]{2})/ sprintf("%c",hex($1)) /ge ;
> 
> Which is best and why?

In the trivial case above, there isn't much to choose, and in fact my 
measurements make sprintf about twice as fast as pack.

But let's look instead at some code that you posted earlier in this 
thread.

#!/usr/local/bin/perl -w
use strict;
use Benchmark;

use vars '$e';
$e = 'godzilla@stomp.stomp.tokyo';

timethese(1 << (shift || 0), {
  Sprintf => '(my $x = $e) =~ s/(.)/sprintf "%02x", ord $1/ges',
  Unpack  => 'my $x = unpack "H*" => $e',
});
__END__

Benchmark: timing 65536 iterations of Sprintf, Unpack...
   Sprintf: 33 wallclock secs (30.00 usr +  0.00 sys = 30.00 CPU) @ 
2184.53/s (n=65536)
    Unpack:  0 wallclock secs ( 0.78 usr +  0.00 sys =  0.78 CPU) @ 
83912.93/s (n=65536)

Some might consider that result to be a definitive reason for choosing 
one over the other.

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


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

Date: Fri, 26 May 2000 13:33:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <392EDFA2.FC937F79@stomp.stomp.tokyo>

Larry Rosler wrote:
 
> Godzilla! says...
> > Dave Cross wrote:
> > > The WebDragon wrote:

> > > > other than that, interesting trick with the sprintf... 
> > > > I wasn't aware
> > > > one could do that. :)

> > > It's far easier using 'pack' and 'unpack'.

> > =~ s/%(..)/pack("c",hex($1))/ge;

> > =~ s/([0-9A-Fa-f]{2})/ sprintf("%c",hex($1)) /ge ;

> > Which is best and why?
 
> In the trivial case above, there isn't much to choose, and in fact my
> measurements make sprintf about twice as fast as pack.
 
> But let's look instead at some code that you posted 
> earlier in this thread.

(snipped) 

> Some might consider that result to be a definitive 
> reason for choosing one over the other.


You are not using my code for testing.
Therefore, your test results are invalid.

Godzilla!


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

Date: Fri, 26 May 2000 13:56:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <MPG.139884c3b67c721d98aaef@nntp.hpl.hp.com>

In article <392EDFA2.FC937F79@stomp.stomp.tokyo> on Fri, 26 May 2000 
13:33:38 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> Larry Rosler wrote:

 ...

> > But let's look instead at some code that you posted 
> > earlier in this thread.
> 
> (snipped) 
> 
> > Some might consider that result to be a definitive 
> > reason for choosing one over the other.
> 
> 
> You are not using my code for testing.
> Therefore, your test results are invalid.

You light up all of our lives!

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


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

Date: Fri, 26 May 2000 14:37:42 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: seeking method to encode email addresses in web page forms
Message-Id: <392EEEA6.73C3602A@stomp.stomp.tokyo>

Larry Rosler wrote:
> 
> In article <392EDFA2.FC937F79@stomp.stomp.tokyo> on Fri, 26 May 2000
> 13:33:38 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> > Larry Rosler wrote:

> > You are not using my code for testing.
> > Therefore, your test results are invalid.
 
> You light up all of our lives!

If this is true, it is a result of my
being objective and fair yet responding
with firmness and conviction while
tending to diplomacy and grace.

You altered test conditions to yield
the test results you desired. This is
not scientific empiricism nor very
sporting of you.

Godzilla!


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

Date: 26 May 2000 19:59:18 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Sybperl/dump database
Message-Id: <8gml2m$sld$3@news.panix.com>

On Fri, 26 May 2000 15:54:44 +0100, Toby Arkless <tarkless@wilco-int.com> wrote:
++ Hi,
++ 
++ I am running perl 5.005 with Sybperl built on.  I am writing a script to
++ dump the databases and I cannot work out how to process the output.
++ dbresults/dbnextrow seem to have no effect. I guess the script is just
++ outputing to STDOUT/STDERR.
++ 
++ I don't really want to have to output to a file and process that. I am
++ fairly new to perl in general and am still working out the tricks.
++ 
++ The code I am using is (the dump command look OK when printed):
++ 
++         $sql="dump database $dbname to $dumpdev";
++         print "$sql\n";
++         $dbh->dbcmd("$sql");
++         $dbh->dbsqlexec;
++         while ($dbh->dbresults != Sybase::DBlib->NO_MORE_RESULTS) {
++         }
++ 
++ I have tried all sorts of things and got nowhere.


Dumping a database isn't a query with a result set.

All the database sends back are messages (and, if something is wrong,
errors). If you want to catch and process them, you need to install
error and message handles, which are simple callbacks, to be triggered
whenever Sybase sends a message or error.

Sybperl follows the the C API closely, and hence you can use the
extensive Sybase manual to find out all the details. (Although Sybperl
itself comes with a large manual). All Sybase manuals are online:
http://sybooks.sybase.com/. No account needed.



Abigail


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

Date: Fri, 26 May 2000 07:06:10 +0000
From: pierre bachelart <bachelart.pierre@skynet.be>
Subject: Re: thanks
Message-Id: <392E2262.7FE8F1E2@skynet.be>


    Tkank you very much for your answers.
    
    Pierre Bachelart.


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

Date: Fri, 26 May 2000 07:35:24 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: updated : Re: regexes *sigh* damn I hate these things
Message-Id: <392e24df.654706@news.skynet.be>

The WebDragon wrote:

>is there an easier way to get a count of the $name(s) than this? I can 
>do a scalar(keys %listing) to get a count of the gametypes found, but 
>how do I get a count of the $listing{*}{$name} keys ? is there a 
>shortcut or no?

I think you want the sum of the number of keys for each gametype.

Functional programming solution:

	@totalgames = sum( map { scalar keys %{listing{$_}} }
	  keys %listing);

	sub sum {
	    my $total = shift;
	    $total += $_ foreach @_;
	    return $total;
	}


Procedural programming solution:

	my $totalgames = 0;
	foreach (keys %listing) {
	    $totalgames += keys %{$listing{$_}};
	}

-- 
	Bart.


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

Date: 26 May 2000 14:17:51 EDT
From: Chris <csorensen@uptimeresources.net>
Subject: Re: using param() and CGI.pm to store a persistent value
Message-Id: <392EBFBF.C2D42808@uptimeresources.net>

IT WORKS !!!

I finally got the silly thing to set a cookie and redirect .. sheesh ..

thanks for everyone's help !



#!/usr/bin/perl
# Script: stick and move

use CGI qw/:standard/;


$the_cookie = cookie(-name=>'ident',
                     -value=>param("siteID"),
                     -expires=>'+1d');


print header('text/html'),
print redirect('http://www.insuremybiz.com');




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

Date: Fri, 26 May 2000 11:49:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: using param() and CGI.pm to store a persistent value
Message-Id: <MPG.1398672ed056537898aae7@nntp.hpl.hp.com>

In article <392EB088.54B93F66@uptimeresources.net> on 26 May 2000 
13:12:56 EDT, Chris <csorensen@uptimeresources.net> says...
> Godzilla is certainly correct when pointing out that I am unfamiliar with
> cookies
> however - I have no choice .. I have to get this done as soon as possible
> (the pointy headed boss is starting to get on my nerves)

I'll toss you a life-preserver.  Next learn how to swim!

> #!/usr/bin/perl -w
> use CGI qw(:standard);
> use strict;

A fine start.  But you impose some requirements on yourself by using 
these programming aids.

> $the_cookie = cookie(-name=>'siteID',
>                      -value=>param("siteID") );

In particular, you must declare this variable (and all others).  Stick 
'my ' at the beginning of the first line.

> print header(-cookie=>$the_cookie);
> 
> print $q->redirect('http://www.insuremybiz.com');

Here you are mixing the OO interface of CGI.pm with the functional 
interface.  You have told CGI (in your second line) that you want to use 
the functional interface, so do so.  Drop the '$q->' and all will be 
well.
 
 ...

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


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

Date: 26 May 2000 15:13:21 -0400
From: David Meyers <dmeyers@panix.com>
Subject: Re: using param() and CGI.pm to store a persistent value
Message-Id: <yobpuq96s6m.fsf@panix6.panix.com>

Chris <csorensen@uptimeresources.net> writes:

> use strict;
> 
> $the_cookie = cookie(-name=>'siteID',
>                      -value=>param("siteID") );

> Global symbol "$the_cookie" requires explicit package name at new5.cgi line 8.

try:

my $the_cookie = ...

--d



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

Date: Fri, 26 May 2000 11:41:56 -0700
From: sthoenna@efn.org (Yitzchak Scott-Thoennes)
Subject: Re: What package does "xsubpp" belong to and where are updates?
Message-Id: <0VsL5gzkgOgV092yn@efn.org>

In article <XYjX4.93847$hT2.388039@news1.rdc1.ct.home.com>,
Dan Sugalski <dan@tuatha.sidhe.org> wrote:
[refering to upgrading xsubpp]
> It's part and parcel of the main perl distribution. You'll need to upgrade
> to a more recent version of perl to get it. (It's got far too much
> dependence on perl's guts to be a drop-in replacement)

I believe you, but can you explain:

[D:\perl\lib\5.6.0\ExtUtils]fgrep "require 5." xsubpp
require 5.002;


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

Date: Fri, 26 May 2000 20:58:57 +0200
From: "Mariska" <mariska@excite.nl>
Subject: Re: What web url to send scripts to the world???
Message-Id: <392eca1f$0$15429@reader2>

zdnet has also a perl script archive.
Not so big at the time but its growing...

Mariska





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

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


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