[24224] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6416 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 19 14:31:34 2004

Date: Mon, 19 Apr 2004 11:30:55 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 Apr 2004     Volume: 10 Number: 6416

Today's topics:
        help: 2 digit number problem <cb2005uk@yahoo.co.uk>
    Re: help: 2 digit number problem <tadmc@augustmail.com>
    Re: help: 2 digit number problem (David Efflandt)
    Re: help: 2 digit number problem <cb2005uk@yahoo.co.uk>
    Re: help: 2 digit number problem <tadmc@augustmail.com>
    Re: help: 2 digit number problem <Joe.Smith@inwap.com>
    Re: help: 2 digit number problem ctcgag@hotmail.com
    Re: help: 2 digit number problem <matthew.garrish@sympatico.ca>
    Re: I cann't scale gif with correctly with perlmagick. (kenny)
    Re: IRC Trivia Bot <troc@pobox.com>
        is better mingw or cygwin? <sandrinotrepppalle@virgilio.it>
    Re: is better mingw or cygwin? <1usa@llenroc.ude>
    Re: is better mingw or cygwin? <tadmc@augustmail.com>
    Re: is better mingw or cygwin? <sandrinotreppalle@virgilio.it>
        Is there something better than this? user@domain.invalid
    Re: Is there something better than this? <mirod@xmltwig.com>
    Re: Is there something better than this? <tore@aursand.no>
    Re: Is there something better than this? <raisin@delete-this-trash.mts.net>
        ISO module for selectable/scrollable text lists <jkrugman@yahbitoo.com>
    Re: ISO module for selectable/scrollable text lists <spamtrap@dot-app.org>
    Re: ISO module for selectable/scrollable text lists (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 18 Apr 2004 15:21:33 +0100
From: "cb" <cb2005uk@yahoo.co.uk>
Subject: help: 2 digit number problem
Message-Id: <40828f2b$0$15957$cc9e4d1f@news.dial.pipex.com>

I'm sure this is very simple, tried searching google for 2 hrs.

Problem
=======
How do I check if $number is a positive number to 2 decimal places?

ie.

12.12  valid
0      invalid
0.00   invalid
1.0    invalid
12.123 invalid
-1.00  invalid


thanks




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

Date: Sun, 18 Apr 2004 10:34:12 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: help: 2 digit number problem
Message-Id: <slrnc857vk.1fl.tadmc@magna.augustmail.com>

cb <cb2005uk@yahoo.co.uk> wrote:

> How do I check if $number is a positive number to 2 decimal places?


   print "valid\n" if $number =~ /^\d*\.\d\d$/;  # untested


> ie.


You meant "eg." rather than "ie." there.


> 0.00   invalid


Why is that invalid?

Looks like 2 decimal places to me...

Is it a mistake in your examples or a mistake in your specification?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 18 Apr 2004 15:35:33 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: help: 2 digit number problem
Message-Id: <slrnc85824.o7u.efflandt@typhoon.xnet.com>

On Sun, 18 Apr 2004 15:21:33 +0100, cb <cb2005uk@yahoo.co.uk> wrote:
> I'm sure this is very simple, tried searching google for 2 hrs.
> 
> Problem
>=======
> How do I check if $number is a positive number to 2 decimal places?

This works as a test:

my $x = shift || die "enter number on command line\n";
$x += 0;  # to assure a number instead of string
if ($x > 0 && $x =~ /\.\d\d$/) {
    print "$x valid\n";
} else {
    print "$x invalid\n";
}


Note that the '$x += 0;' assures that any trailing decimal zeros used in 
string context are dropped.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: Sun, 18 Apr 2004 17:08:51 +0100
From: "cb" <cb2005uk@yahoo.co.uk>
Subject: Re: help: 2 digit number problem
Message-Id: <4082a81a$0$15967$cc9e4d1f@news.dial.pipex.com>

No, I didn't want 0.00 to be valid.
I want a user to enter a start price for an auction, I don't want 0.00 or
negative numbers to be valid.

if $number =~ /^\d*\.\d\d$/;
works fine :)

I've added a second check to look for 0.00

thanks



----- Original Message ----- 
From: "Tad McClellan" <tadmc@augustmail.com>
Newsgroups: comp.lang.perl.misc
Sent: Sunday, April 18, 2004 4:34 PM
Subject: Re: help: 2 digit number problem


> cb <cb2005uk@yahoo.co.uk> wrote:
>
> > How do I check if $number is a positive number to 2 decimal places?
>
>
>    print "valid\n" if $number =~ /^\d*\.\d\d$/;  # untested
>
>
> > ie.
>
>
> You meant "eg." rather than "ie." there.
>
>
> > 0.00   invalid
>
>
> Why is that invalid?
>
> Looks like 2 decimal places to me...
>
> Is it a mistake in your examples or a mistake in your specification?
>
>
> -- 
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Sun, 18 Apr 2004 14:23:25 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: help: 2 digit number problem
Message-Id: <slrnc85ldd.1mn.tadmc@magna.augustmail.com>


[ Please do not top-post.
  Please do not quote an entire article.
  Please provide a conventional attribution when quoting someone.
  Thank you.
]


cb <cb2005uk@yahoo.co.uk> wrote:
> ----- Original Message ----- 
> From: "Tad McClellan" <tadmc@augustmail.com>
> Newsgroups: comp.lang.perl.misc
> Sent: Sunday, April 18, 2004 4:34 PM
> Subject: Re: help: 2 digit number problem
> 
> 
>> cb <cb2005uk@yahoo.co.uk> wrote:
>>
>> > How do I check if $number is a positive number to 2 decimal places?

>> > 0.00   invalid
>>
>> Why is that invalid?
>>
>> Looks like 2 decimal places to me...
>>
>> Is it a mistake in your examples or a mistake in your specification?


> No, I didn't want 0.00 to be valid.


So then, it was a mistake in your specification.


> I've added a second check to look for 0.00


Does your "check" use the == operator? (it should)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 18 Apr 2004 21:01:37 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: help: 2 digit number problem
Message-Id: <M0Cgc.156020$gA5.1858512@attbi_s03>

Tad McClellan wrote:

> cb <cb2005uk@yahoo.co.uk> wrote:
>>How do I check if $number is a positive number to 2 decimal places?
>>0.00   invalid
> 
> Why is that invalid?
> 
> Looks like 2 decimal places to me...
> 
> Is it a mistake in your examples or a mistake in your specification?

0.00 falls into the category of non-negative numbers, but it is
not a positive number, which was explictly stated in the specification.
	-Joe


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

Date: 19 Apr 2004 02:35:24 GMT
From: ctcgag@hotmail.com
Subject: Re: help: 2 digit number problem
Message-Id: <20040418223524.845$fn@newsreader.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> >> cb <cb2005uk@yahoo.co.uk> wrote:
> >>
> >> > How do I check if $number is a positive number to 2 decimal places?

> > No, I didn't want 0.00 to be valid.
>
> So then, it was a mistake in your specification.

No, 0.00 is not positive.  Although it is nonnegative.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Mon, 19 Apr 2004 01:26:20 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: help: 2 digit number problem
Message-Id: <RpJgc.4161$CO3.306800@news20.bellglobal.com>


"David Efflandt" <efflandt@xnet.com> wrote in message
news:slrnc85824.o7u.efflandt@typhoon.xnet.com...
> On Sun, 18 Apr 2004 15:21:33 +0100, cb <cb2005uk@yahoo.co.uk> wrote:
> > I'm sure this is very simple, tried searching google for 2 hrs.
> >
> > Problem
> >=======
> > How do I check if $number is a positive number to 2 decimal places?
>
> This works as a test:
>
> my $x = shift || die "enter number on command line\n";
> $x += 0;  # to assure a number instead of string
> if ($x > 0 && $x =~ /\.\d\d$/) {
>     print "$x valid\n";
> } else {
>     print "$x invalid\n";
> }
>
>
> Note that the '$x += 0;' assures that any trailing decimal zeros used in
> string context are dropped.
>

But as I read his question, 0.10, 1.00, 1.10, etc. are all valid, which
won't be the case when you strip the trailing zeros as per your example.

Matt




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

Date: 19 Apr 2004 02:32:57 -0700
From: kennyjohn00001@yahoo.com (kenny)
Subject: Re: I cann't scale gif with correctly with perlmagick.
Message-Id: <2eebf9a.0404190132.7486d5b8@posting.google.com>

Richard Morse <remorse@partners.org> wrote in message news:<remorse-4BFA4C.13334612042004@plato.harvard.edu>...
> In article <2eebf9a.0404120058.59fe98f7@posting.google.com>,
>  kennyjohn00001@yahoo.com (kenny) wrote:
> 
> > eg: first image of animate gif  size is 280X 280 scale to 80%. so
> > image size now is 224X224.
> > 
> > second image of animate gif  size is 150X 150 scale to 80%. so image
> > size now is 187.5X187.5. but..... in the pixel, we don't have .5
> > pixel. so problem is come. so maybe second image scale to 187X187 or
> > 188X188. this situation maybe will leave white dot/blank dot....
> 
> I'm pretty sure that, although you can very probably make animated gifs 
> with different sized components, things will be much easier if all the 
> images in the animation are the same size.
> 
> Perhaps you should try fixing the animated gif to make every frame the 
> same size?
> 
> Ricky

I know fixing the animated gif to make every frame the same size. but
how?

i already try several mehthod scaling the image. when i scale the
second image untill same same as first image. the element in image
become bigger if scale to big size or  become smaller if i scale to
small size.

then i try to use annotate method. I try annotate second image(small
size one) to sample  blank image which have same size to first image.
then bigger or smaller size is settle, but....another problem is come,
the position image is running of original one.....because sometimes
second image is place several place. sometime is is
northern,westhern,center,...etc. how i know where the image should i
place in position(x,y).

so any solution to place the image to right position?


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

Date: Sun, 18 Apr 2004 05:32:36 GMT
From: Rocco Caputo <troc@pobox.com>
Subject: Re: IRC Trivia Bot
Message-Id: <slrnc844s5.lqj.troc@eyrie.homenet>

On Wed, 14 Apr 2004 05:30:37 GMT, ZedGama3 wrote:
> Does anyone know of a counterpart for Trivia.pm for POE::Component::IRC?
>
> From what I read POE::Component::IRC is supposed to be alot better than
> Net::IRC because it's event driven rather than loop driven ( if I understand
> that correctly ).
>
> So far I've already setup a bot with POE::Component::IRC and wouldn't be
> opposed to making my own trivia component but I don't know how to setup a
> timed event so the tivia bot will keep going without making other items
> wait.  So if no one gets it right in 10sec it gives a hint, 10sec later
> another hint, until it tells you the answer and picks a new question or if
> someone gets it right the bot automaticly congratulates the user and picks a
> new question.

Timers are supplied by the base POE distribution, not by
POE::Component::IRC.  Look for alarm and delay in perldoc POE.

You may also want to look at a bot that uses timers.  Acro is an acronym
game for IRC, and it uses timers extensively.  See
http://jinzougen.net/?action=display&node=acro

-- Rocco Caputo


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

Date: Sun, 18 Apr 2004 00:55:27 GMT
From: Sandrino <sandrinotrepppalle@virgilio.it>
Subject: is better mingw or cygwin?
Message-Id: <mfk380taeae3i50fdrtb2c3lsk43ip1bad@4ax.com>

I want to set up mingw or cygwin to be able to compile my personal
version of gnu tools like emacs etc. My system is windows XP pro and I
wander what're the differences between mingw and cygwin and what is the
better set to install.

Thanks
Sandrino


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

Date: 18 Apr 2004 01:10:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: is better mingw or cygwin?
Message-Id: <Xns94CED7595806Casu1cornelledu@132.236.56.8>

Sandrino <sandrinotrepppalle@virgilio.it> wrote in 
news:mfk380taeae3i50fdrtb2c3lsk43ip1bad@4ax.com:

> I want to set up mingw or cygwin to be able to compile my personal
> version of gnu tools like emacs etc. My system is windows XP pro and I
> wander what're the differences between mingw and cygwin and what is the
> better set to install.

Not a Perl question. Go to http://www.cygwin.com/, read, and make a choice.

-- 
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)


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

Date: Sat, 17 Apr 2004 21:33:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: is better mingw or cygwin?
Message-Id: <slrnc83q7i.lhi.tadmc@magna.augustmail.com>

Sandrino <sandrinotrepppalle@virgilio.it> wrote:

> I want to set up mingw or cygwin to be able to compile my personal
> version of gnu tools like emacs etc. My system is windows XP pro and I
> wander what're the differences between mingw and cygwin and what is the
> better set to install.


What is your Perl question?

This _is_ the Perl newsgroup you know.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sun, 18 Apr 2004 07:53:07 GMT
From: Sandrino <sandrinotreppalle@virgilio.it>
Subject: Re: is better mingw or cygwin?
Message-Id: <hrc48096gfrpqg7hleif0d64doinbiv9m7@4ax.com>

On 18 Apr 2004 01:10:10 GMT, "A. Sinan Unur" <1usa@llenroc.ude> wrote:

>Not a Perl question. Go to http://www.cygwin.com/, read, and make a choice.

Sorry Tad and Sinan, I've posted in the wrong group :-( 

Too much beer yesterday.

Sandrino


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

Date: Mon, 19 Apr 2004 11:29:30 +0200
From: user@domain.invalid
Subject: Is there something better than this?
Message-Id: <c6065q$eqs$1@ctb-nnrp2.saix.net>

Is there another way to handle failure to create a directory handle
other than the following:
   opendir($MYHANDLE,$mydir) || die ("Unable to open dir $mydir");

Another way to put this would be, is there a way to tell the reason
for the failure create the handle?



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

Date: Mon, 19 Apr 2004 13:05:01 +0200
From: Michel Rodriguez <mirod@xmltwig.com>
Subject: Re: Is there something better than this?
Message-Id: <c606k6$1sh$1@news-reader2.wanadoo.fr>

user@domain.invalid wrote:
> Is there another way to handle failure to create a directory handle
> other than the following:
>   opendir($MYHANDLE,$mydir) || die ("Unable to open dir $mydir");
> 
> Another way to put this would be, is there a way to tell the reason
> for the failure create the handle?
> 

opendir($MYHANDLE,$mydir) || die ("Unable to open dir $mydir: $!");

$! gives you the error as sent by the OS.

 From man perlvar



$OS_ERROR
$ERRNO
$!      If used numerically, yields the current value of the C "errno"
         variable, or in other words, if a system or library call fails,
         it sets this variable.  This means that the value of $! is
         meaningful only immediately after a failure:

             if (open(FH, $filename)) {
                 # Here $! is meaningless.
                 ...
             } else {
                 # ONLY here is $! meaningful.
                 ...
                 # Already here $! might be meaningless.
             }
             # Since here we might have either success or failure,
             # here $! is meaningless.

         In the above meaningless stands for anything: zero, non-zero,
         "undef".  A successful system or library call does not set the
         variable to zero.

         If used as a string, yields the corresponding system error
         string.  You can assign a number to $! to set errno if, for
         instance, you want "$!" to return the string for error n, or
         you want to set the exit value for the die() operator.
         (Mnemonic: What just went bang?)

         Also see "Error Indicators".



--
Michel Rodriguez
Perl &amp; XML
http://www.xmltwig.com



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

Date: Mon, 19 Apr 2004 14:45:58 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Is there something better than this?
Message-Id: <pan.2004.04.19.12.02.39.787842@aursand.no>

On Mon, 19 Apr 2004 11:29:30 +0200, user wrote:
> Is there another way to handle failure to create a directory handle
> other than the following:
>    opendir($MYHANDLE,$mydir) || die ("Unable to open dir $mydir");
> 
> Another way to put this would be, is there a way to tell the reason
> for the failure create the handle?

The '$!' variable holds the error message;

  opendir( $MYHANDLE, $mydir ) or die "$!\n";

If you don't want to die each time something like this fails, you can do
something like this;

  if ( opendir($MYHANDLE, $mydir) ) {
      # ...
      closedir( $MYHANDLE );
  }
  else {
      # Handle error
  }

 ...or you could check out the Error module which lets you do try, catch
and all that stuff.


-- 
Tore Aursand <tore@aursand.no>
"What we see depends mainly on what we look for." (Sir John Lubbock)


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

Date: Mon, 19 Apr 2004 08:00:57 -0500
From: Web Surfer <raisin@delete-this-trash.mts.net>
Subject: Re: Is there something better than this?
Message-Id: <MPG.1aed89812965731198980c@news.mts.net>

[This followup was posted to comp.lang.perl.misc]

In article <c6065q$eqs$1@ctb-nnrp2.saix.net>, user@domain.invalid 
says...
> Is there another way to handle failure to create a directory handle
> other than the following:
>    opendir($MYHANDLE,$mydir) || die ("Unable to open dir $mydir");
> 
> Another way to put this would be, is there a way to tell the reason
> for the failure create the handle?


opendir(MYHANDLE,$mydir) ||
    die("opendir failed for $mydir : $!\n");


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

Date: Sat, 17 Apr 2004 02:56:18 +0000 (UTC)
From: J Krugman <jkrugman@yahbitoo.com>
Subject: ISO module for selectable/scrollable text lists
Message-Id: <c5q6ci$j3j$1@reader2.panix.com>



There are many tasks that involve inspecting a table of records,
selecting some records, and doing something to the selected records.

With a text interface, this is typically done by displaying records
one screenful at a time, using reverse video (or some other technique)
to indicate the "current record"; using Up, Down, Page-Up, Page-Down
keys to move the location of the "current record" indicator; and
using certain keys to select/deselect records and to perform
pre-determined actions on either the current record or the set of
selected records.

I'm looking for a CPAN Perl module that'd facilitate the coding of
such a text-based interface on a Linux system, but I have no idea
of what keywords to search for.  Does anybody know of a module like
this?

Thanks!

jill
-- 
To  s&e^n]d  me  m~a}i]l  r%e*m?o\v[e  bit from my a|d)d:r{e:s]s.



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

Date: Fri, 16 Apr 2004 23:10:35 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: ISO module for selectable/scrollable text lists
Message-Id: <1qCdnRhW062JPR3dRVn-hg@adelphia.com>

J Krugman wrote:

> I'm looking for a CPAN Perl module that'd facilitate the coding of
> such a text-based interface on a Linux system

Curses

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 17 Apr 2004 10:06:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: ISO module for selectable/scrollable text lists
Message-Id: <c5qvip$kf9$1@mamenchi.zrz.TU-Berlin.DE>

Sherm Pendley  <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> J Krugman wrote:
> 
> > I'm looking for a CPAN Perl module that'd facilitate the coding of
> > such a text-based interface on a Linux system
> 
> Curses

 ...and/or Curses::UI

Anno


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

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


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