[25613] in Perl-Users-Digest
Perl-Users Digest, Issue: 7857 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 4 18:06:04 2005
Date: Fri, 4 Mar 2005 15:05:38 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 4 Mar 2005 Volume: 10 Number: 7857
Today's topics:
ANNOUNCE: IO::Capture::Stdout::Extended 0.03 <jkeen_via_google@yahoo.com>
BerkeleyDB oddity? <admin@asarian-host.net>
bug in perl <webmaster @ infusedlight.net>
Re: bug in perl <1usa@llenroc.ude.invalid>
cgi question kinda <robin@infusedlight.net>
Re: cgi question kinda <1usa@llenroc.ude.invalid>
Re: cgi question kinda <peter@berghold.net>
Re: cgi question kinda <sbryce@scottbryce.com>
Re: cgi question kinda <no@email.com>
Re: cgi question kinda <darkon.tdo@gmail.com>
Re: cgi question kinda <webmaster @ infusedlight.net>
Re: cgi question kinda <webmaster @ infusedlight.net>
Re: cgi question kinda <webmaster @ infusedlight.net>
Re: cgi question kinda <robin@infusedlight.net>
Re: cgi question kinda <no@email.com>
Re: cgi question kinda <shawn.corey@sympatico.ca>
Re: cgi question kinda <no@email.com>
comparing two numbers <usaims@yahoo.com>
Re: comparing two numbers <1usa@llenroc.ude.invalid>
Re: comparing two numbers <darkon.tdo@gmail.com>
Re: comparing two numbers <postmaster@castleamber.com>
Re: comparing two numbers <darkon.tdo@gmail.com>
Re: disagree with a few things in perlsec <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 2 Mar 2005 03:01:24 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: ANNOUNCE: IO::Capture::Stdout::Extended 0.03
Message-Id: <ICuKtH.14vI@zorch.sf-bay.org>
IO::Capture::Stdout::Extended has been uploaded to CPAN. From the
documentation:
=head1 NAME
IO::Capture::Stdout::Extended - Extend functionality of IO::Capture::Stdout
=head1 SYNOPSIS
use IO::Capture::Stdout::Extended;
$capture = IO::Capture::Stdout::Extended->new();
$capture->start();
# some code that prints to STDOUT
$capture->stop();
# scalar context: return number of print statements with 'fox'
$matches = $capture->grep_print_statements('fox');
# list context: return list of print statements with 'fox'
@matches = $capture->grep_print_statements('fox');
# return number of print statements
$matches = $capture->statements;
# scalar context: return number of pattern matches
$regex = qr/some regular expression/;
$matches = $capture->matches($regex);
# list context: return list of pattern matches
@matches = $capture->matches($regex);
# return reference to array holding list of pattern matches
$matchesref = $capture->matches_ref($regex);
=head1 DESCRIPTION
IO::Capture::Stdout::Extended is a collection of subroutines which
may be useful in extending the functionality of CPAN module
IO::Capture::Stdout, particularly when used in a testing context
such as that provided by Test::Simple, Test::More or other modules
built on Test::Builder.
Send comments to jkeenan [at] cpan [dot] org. Thanks.
------------------------------
Date: Fri, 4 Mar 2005 23:32:08 +0100
From: "Mark" <admin@asarian-host.net>
Subject: BerkeleyDB oddity?
Message-Id: <0MCdnYNymNN9fLXfRVnyhQ@giganews.com>
Dear group,
Using the tied interface of BerkeleyDB 0.26 ("use BerkeleyDB"), I
encountered an oddity; at least to me. :) Consider this, please:
if ($badtokens{$key}) {
print "PRESENT: $key\n";
if ($_ = delete $badtokens{$key}) {
print "DELETED: $key\n";
}
}
Now, 'regularly', in scalar context,the delete() function (Perl 5.8.6)
will return the value of the last element deleted (or the undefined value
if that element did not exist). However, even though the item is
definitely deleted from the database, the return of the delete is always
an empty string (but not undef!).
Maybe there is something I do not understand about the underlying tie
structure, in which case I would appreciate if someone enlightened me, or
else I would probably consider this to be a small bug.
Feel free to correct me if applicable. :)
- Mark
------------------------------
Date: Fri, 4 Mar 2005 15:37:11 -0700
From: "Robin" <webmaster @ infusedlight.net>
Subject: bug in perl
Message-Id: <pqWdncOuVb2ff7XfRVn-1g@comcast.com>
why does it not work to say
print <<END if defined ($var)
line
line
line
or
print <<END;
line
line
line
END
is that code wrong or is a bug in perl?
--
Robin
--
webmaster@infusedlight.net
--
------------------------------
Date: Fri, 04 Mar 2005 22:38:14 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: bug in perl
Message-Id: <Xns960FB36A4F77Casu1cornelledu@127.0.0.1>
"Robin" <webmaster @ infusedlight.net> wrote in news:pqWdncOuVb2ff7XfRVn-
1g@comcast.com:
> why does it not work to say
> print <<END if defined ($var)
> line
> line
> line
> or
> print <<END;
> line
> line
> line
> END
>
> is that code wrong
Whatever language the code is in, it is not Perl.
> or is a bug in perl?
Yes, and you, of all people, have found it. Seriously, look up the syntax
and use the proper syntax.
From perlfaq4.pod:
Why don't my <<HERE documents work?
Sinan.
------------------------------
Date: 4 Mar 2005 10:36:48 -0800
From: "robin" <robin@infusedlight.net>
Subject: cgi question kinda
Message-Id: <1109961408.385476.297040@g14g2000cwa.googlegroups.com>
I know this may not be a question for this group, but is there some
kind of
secret involved in putting a new line into a single line (non-textarea)
input field on an html page, a special kind of character perhaps? I'm
using
CGI.pm for a script and I was wondering what that character is so I can
parse it out, remove them, etc... It really screws up my bbs script
when
someone does it. Thanks in advance- Robin
------------------------------
Date: 4 Mar 2005 19:20:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: cgi question kinda
Message-Id: <Xns960F91D17DEasu1cornelledu@132.236.56.8>
"robin" <robin@infusedlight.net> wrote in news:1109961408.385476.297040
@g14g2000cwa.googlegroups.com:
> I know this may not be a question for this group,
Then why are you posting here.
> but is there some kind of secret involved in putting a new line into a
> single line (non-textarea)
Who knows? Why not ask a group that actually deals with HTML?
> It really screws up my bbs script when someone does it.
If that is the only thing messing up your script, then your programming
must have improved at a super-human pace.
On the other hand, if such things are messing up your script, then your
script cannot be very good.
Sinan.
------------------------------
Date: Fri, 04 Mar 2005 14:48:45 -0500
From: "Peter L. Berghold" <peter@berghold.net>
Subject: Re: cgi question kinda
Message-Id: <4228bb0e$0$25001$9a6e19ea@unlimited.newshosting.com>
robin wrote:
> I know this may not be a question for this group,
If you don't think your question is appropriate or on topic why are you
posting it?
>but is there some
> kind of
> secret involved in putting a new line into a single line (non-textarea)
>
????
There are damn few secrets in cyberspace. :-)
> I was wondering what that character is so I can
>
> parse it out, remove them, etc... It really screws up my bbs script
> when
> someone does it
>
Don't you think your question is rather vague?
Here's the deal: You designed the application, you know what input to
it is valid and therefore you should be able to test those inputs for
validity before the input can do any harm to your application.
Application design: 102.
--
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Peter L. Berghold Peter@Berghold.Net
"Those who fail to learn from history are condemned to repeat it."
AIM: redcowdawg Yahoo IM: blue_cowdawg ICQ: 11455958
------------------------------
Date: Fri, 04 Mar 2005 13:05:39 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: cgi question kinda
Message-Id: <E8KdnVBwPfcJIrXfRVn-2A@comcast.com>
robin wrote:
> I was wondering what that character is so I can parse it out, remove
> them
I would think that if you have a Perl script that has a variable that
contains a string that contains an unknown character, you should be able
to write a routine that tells you what characters are in the string.
------------------------------
Date: Fri, 04 Mar 2005 20:11:55 +0000
From: Brian Wakem <no@email.com>
Subject: Re: cgi question kinda
Message-Id: <38rtobF5r8nbfU1@individual.net>
robin wrote:
> I know this may not be a question for this group, but is there some
> kind of
> secret involved in putting a new line into a single line (non-textarea)
>
> input field on an html page, a special kind of character perhaps? I'm
> using
> CGI.pm for a script and I was wondering what that character is so I can
>
> parse it out, remove them, etc... It really screws up my bbs script
> when
> someone does it. Thanks in advance- Robin
I might have read this wrong but it seems to me you are asking how to remove
the newline from the end of a string that is submitted via a form. If this
is the case then -
$myvar =~ s!\n$!!;
--
Brian Wakem
------------------------------
Date: Fri, 04 Mar 2005 20:45:38 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: cgi question kinda
Message-Id: <Xns960FA052A6707dkwwashere@216.168.3.30>
robin <robin@infusedlight.net> wrote:
> I know this may not be a question for this group, but is there
> some kind of secret involved in putting a new line into a single
> line (non-textarea)
Only the Shadow knows.
> input field on an html page, a special kind of character perhaps?
> I'm using CGI.pm for a script and I was wondering what that
> character is so I can parse it out, remove them, etc... It really
> screws up my bbs script when someone does it. Thanks in advance-
> Robin
Why not go about it the other direction? Define whch characters you
want to allow, and remove everything else.
------------------------------
Date: Fri, 4 Mar 2005 15:30:01 -0700
From: "Robin" <webmaster @ infusedlight.net>
Subject: Re: cgi question kinda
Message-Id: <7pqdnSB_Bp3hfbXfRVn-hw@comcast.com>
thanks for all your help.
-robin
------------------------------
Date: Fri, 4 Mar 2005 15:34:22 -0700
From: "Robin" <webmaster @ infusedlight.net>
Subject: Re: cgi question kinda
Message-Id: <uZCdnRjzJanFfLXfRVn-hA@comcast.com>
"Brian Wakem" <no@email.com> wrote in message
news:38rtobF5r8nbfU1@individual.net...
> robin wrote:
>
>> I know this may not be a question for this group, but is there some
>> kind of
>> secret involved in putting a new line into a single line (non-textarea)
>>
>> input field on an html page, a special kind of character perhaps? I'm
>> using
>> CGI.pm for a script and I was wondering what that character is so I can
>>
>> parse it out, remove them, etc... It really screws up my bbs script
>> when
>> someone does it. Thanks in advance- Robin
>
>
> I might have read this wrong but it seems to me you are asking how to
> remove
> the newline from the end of a string that is submitted via a form. If
> this
> is the case then -
>
> $myvar =~ s!\n$!!;
>
>
> --
> Brian Wakem
there isn't a newline at the end of a string from a form field. The raw
data? is that what you mean?
-robin
------------------------------
Date: Fri, 4 Mar 2005 15:35:21 -0700
From: "Robin" <webmaster @ infusedlight.net>
Subject: Re: cgi question kinda
Message-Id: <pqWdncCuVb2ff7XfRVn-1g@comcast.com>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns960F91D17DEasu1cornelledu@132.236.56.8...
> "robin" <robin@infusedlight.net> wrote in news:1109961408.385476.297040
> @g14g2000cwa.googlegroups.com:
>
>> I know this may not be a question for this group,
>
> Then why are you posting here.
>
>> but is there some kind of secret involved in putting a new line into a
>> single line (non-textarea)
>
> Who knows? Why not ask a group that actually deals with HTML?
yeah, that's what I thought.
>
>> It really screws up my bbs script when someone does it.
>
> If that is the only thing messing up your script, then your programming
> must have improved at a super-human pace.
hehehehehehe....
>
> On the other hand, if such things are messing up your script, then your
> script cannot be very good.
yeah, well, it's getting better.
>
> Sinan.
------------------------------
Date: 4 Mar 2005 14:34:53 -0800
From: "robin" <robin@infusedlight.net>
Subject: Re: cgi question kinda
Message-Id: <1109975693.931561.235610@z14g2000cwz.googlegroups.com>
good call.
-robin
------------------------------
Date: Fri, 04 Mar 2005 22:35:37 +0000
From: Brian Wakem <no@email.com>
Subject: Re: cgi question kinda
Message-Id: <38s65pF5r28buU1@individual.net>
Robin wrote:
>
> "Brian Wakem" <no@email.com> wrote in message
> news:38rtobF5r8nbfU1@individual.net...
>> robin wrote:
>>
>>> I know this may not be a question for this group, but is there some
>>> kind of
>>> secret involved in putting a new line into a single line (non-textarea)
>>>
>>> input field on an html page, a special kind of character perhaps? I'm
>>> using
>>> CGI.pm for a script and I was wondering what that character is so I can
>>>
>>> parse it out, remove them, etc... It really screws up my bbs script
>>> when
>>> someone does it. Thanks in advance- Robin
>>
>>
>> I might have read this wrong but it seems to me you are asking how to
>> remove
>> the newline from the end of a string that is submitted via a form. If
>> this
>> is the case then -
>>
>> $myvar =~ s!\n$!!;
>>
>>
>> --
>> Brian Wakem
>
> there isn't a newline at the end of a string from a form field. The raw
> data? is that what you mean?
No, and I have no idea what you mean.
--
Brian Wakem
------------------------------
Date: Fri, 04 Mar 2005 17:25:25 -0500
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: cgi question kinda
Message-Id: <df5Wd.56987$Vf6.1566894@news20.bellglobal.com>
Brian Wakem wrote:
>
> $myvar =~ s!\n$!!;
>
chomp ($myvar);
See perldoc -f chomp
--- Shawn
------------------------------
Date: Fri, 04 Mar 2005 22:45:36 +0000
From: Brian Wakem <no@email.com>
Subject: Re: cgi question kinda
Message-Id: <38s6ogF5r28buU2@individual.net>
Shawn Corey wrote:
> Brian Wakem wrote:
>>
>> $myvar =~ s!\n$!!;
>>
> chomp ($myvar);
>
> See perldoc -f chomp
TIMTOWTDI
--
Brian Wakem
------------------------------
Date: 4 Mar 2005 12:37:26 -0800
From: "usaims" <usaims@yahoo.com>
Subject: comparing two numbers
Message-Id: <1109968646.156295.113790@o13g2000cwo.googlegroups.com>
Hi, I'm new to Perl and I have limited programming skills. I'm trying
to see if numbers in a list are not identical, for example:
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553366
Noticed that the last one is different, I want perl to tell me that. A
little kick in the butt would be greatly appreciated. Thanks in
advance.
usaims
------------------------------
Date: 4 Mar 2005 20:48:38 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: comparing two numbers
Message-Id: <Xns960FA0D59B75asu1cornelledu@132.236.56.8>
"usaims" <usaims@yahoo.com> wrote in news:1109968646.156295.113790
@o13g2000cwo.googlegroups.com:
> Hi, I'm new to Perl and I have limited programming skills. I'm trying
> to see if numbers in a list are not identical, for example:
>
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553365
> 1207553366
>
> Noticed that the last one is different, I want perl to tell me that. A
> little kick in the butt would be greatly appreciated. Thanks in
> advance.
Then you need to specify the problem a little better. For example, given
the input below, what output would you like your program to produce?
Please do read the posting guidelines to find out how you can help others
help you.
You will need to better describe what you are trying to do and make an
effort yourself if you are to get the maximum possible help here.
Here is something that might do what you are after. Please study it (not
as a great example of programming) to try and understand in what ways it
meets your specs, and in what ways it doesn't, and then formulate your
next attempt based on that new understanding.
#! /usr/bin/perl
use strict;
use warnings;
if(defined(my $prev = <DATA>)) {
chomp($prev);
while(defined(my $curr = <DATA>)) {
chomp $curr;
last unless length $curr;
unless($curr == $prev) {
print "$.: $curr not equal to $prev\n";
$prev = $curr;
}
}
}
__END__
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553366
1207553365
Sinan
------------------------------
Date: Fri, 04 Mar 2005 21:04:38 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: comparing two numbers
Message-Id: <Xns960FA38E8171Bdkwwashere@216.168.3.30>
A. Sinan Unur <1usa@llenroc.ude.invalid> wrote:
> "usaims" <usaims@yahoo.com> wrote in news:1109968646.156295.113790
> @o13g2000cwo.googlegroups.com:
>
>> Hi, I'm new to Perl and I have limited programming skills. I'm
>> trying to see if numbers in a list are not identical, for
>> example:
>>
[snip]
> You will need to better describe what you are trying to do and
> make an effort yourself if you are to get the maximum possible
> help here.
Agreed. But I still might recommend looking at
'perldoc -q duplicate'.
> Here is something that might do what you are after. Please study
> it (not as a great example of programming) to try and understand
> in what ways it meets your specs, and in what ways it doesn't, and
> then formulate your next attempt based on that new understanding.
Here's another approach, which is what happens when the problem is
not specified well:
use strict;
use warnings;
my @nums = qw(
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553365
1207553366
1207553365
);
my %hash;
@hash{@nums} = ();
# a little long-winded here, but I thought using ?:
# might confuse the OP
if ( 1 == keys %hash ) {
print "All the same\n";
}
else {
print "At least one is different\n";
}
------------------------------
Date: 4 Mar 2005 21:11:30 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: comparing two numbers
Message-Id: <Xns960F9A89953FDcastleamber@130.133.1.4>
David K. Wall wrote:
> if ( 1 == keys %hash ) {
> print "All the same\n";
Aargh, keys %hash = 1 with warnings on gives:
Found = in conditional, should be == at ...
Never understood crippled^H^H^H^H^H^H^H^Hdefensive programming :-(
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Fri, 04 Mar 2005 22:47:03 -0000
From: "David K. Wall" <darkon.tdo@gmail.com>
Subject: Re: comparing two numbers
Message-Id: <Xns960FB4E922E1Edkwwashere@216.168.3.30>
John Bokma <postmaster@castleamber.com> wrote:
> David K. Wall wrote:
>
>> if ( 1 == keys %hash ) {
>> print "All the same\n";
>
> Aargh, keys %hash = 1 with warnings on gives:
> Found = in conditional, should be == at ...
>
> Never understood crippled^H^H^H^H^H^H^H^Hdefensive programming :-(
It wasn't intended to be defensive. I typed it that way because I was
too lazy to type an extra set of parentheses. :-)
------------------------------
Date: 04 Mar 2005 21:41:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: disagree with a few things in perlsec
Message-Id: <slrnd2hlfk.v9v.abigail@alexandra.abigail.nl>
GreenLeaf (newspost@kohombanDELETE.net) wrote on MMMMCCIII September
MCMXCIII in <URL:news:38pufmF5qumdhU1@individual.net>:
)) el_roachmeister@yahoo.com wrote:
))
)) > A wealthy person hides a treasure on an island.
))
)) How much wealthy is irrelevant. Where do *you* prefer to keep *your*
)) money? Bank or Island? :o)
))
)) And why?
Bank, because even if it gets robbed, I still get my money.
If we had old fashioned banks, were you would lose your money if it
gets robbed, I'd prefer to hide it on a island if I would know noone
knew the location, and the island wasn't too far away. In reality,
islands are far away, and there's no way of knowing noone saw me
hide the treasure.
But the bank analogue is flawed because nowadays, one of the features
of a bank is that the banks takes the responsibility.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 7857
***************************************