[28254] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9618 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 14:20:36 2006

Date: Thu, 17 Aug 2006 11:20:29 -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           Thu, 17 Aug 2006     Volume: 10 Number: 9618

Today's topics:
        Question on File::Find <Diana@hotmail.com>
    Re: Question on File::Find <mritty@gmail.com>
    Re: Question on File::Find <mritty@gmail.com>
    Re: Question on File::Find <Diana@hotmail.com>
    Re: Question on File::Find <benmorrow@tiscali.co.uk>
        Regular Expression for Integer and float values <tarun.sinha@gmail.com>
    Re: Regular Expression for Integer and float values <klaus03@gmail.com>
    Re: Regular Expression for Integer and float values axel@white-eagle.invalid.uk
    Re: Regular Expression for Integer and float values <daveandniki@ntlworld.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Aug 2006 12:48:19 GMT
From: "Diana" <Diana@hotmail.com>
Subject: Question on File::Find
Message-Id: <nAZEg.35878$_k2.636654@news2.nokia.com>

Hi,
I am struggling to use File::Find module,
the issue is, I can use with defining find function with &wanted, but
not with %options, here is what I am doing
my %findoption=( bydepth=>"1" , no_chdir => "1" ); 
push (@All,find(\%fort,"$Location"));
thx
-D 



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

Date: 17 Aug 2006 06:05:05 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Question on File::Find
Message-Id: <1155819905.860611.190150@75g2000cwc.googlegroups.com>

Diana wrote:
> Hi,
> I am struggling to use File::Find module,
> the issue is, I can use with defining find function with &wanted, but
> not with %options, here is what I am doing
> my %findoption=( bydepth=>"1" , no_chdir => "1" );
> push (@All,find(\%fort,"$Location"));

1) You didn't include the wanted option in your %findoption hash.  If
you pass a hash reference as the first option to find, one of the
key-value pairs of that hash must be 'wanted' with the value of the
subroutine you want to call.
2) find() does not return a list of files it finds.  I have no idea
what you think your push statement is doing
3) Do not needlessly double-quote variables (like you did to
$Location).  See `perldoc -q quoting`

Paul Lalli



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

Date: 17 Aug 2006 06:07:22 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Question on File::Find
Message-Id: <1155820042.449064.320860@m79g2000cwm.googlegroups.com>

Paul Lalli wrote:
> Diana wrote:

> > I am struggling to use File::Find module,
> > the issue is, I can use with defining find function with &wanted, but
> > not with %options, here is what I am doing
> > my %findoption=( bydepth=>"1" , no_chdir => "1" );
> > push (@All,find(\%fort,"$Location"));
>
> 1) You didn't include the wanted option in your %findoption hash.  If
> you pass a hash reference as the first option to find, one of the
> key-value pairs of that hash must be 'wanted' with the value of the
> subroutine you want to call.
> 2) find() does not return a list of files it finds.  I have no idea
> what you think your push statement is doing
> 3) Do not needlessly double-quote variables (like you did to
> $Location).  See `perldoc -q quoting`

4) What the heck is %fort?  You declared %findoption, but are passing a
reference to %fort?  If this is your real code, please enable `use
strict;` and `use warnings;` in your code.  If this is not your real
code, please DON'T DO THAT!

Paul Lalli



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

Date: Thu, 17 Aug 2006 13:15:11 GMT
From: "Diana" <Diana@hotmail.com>
Subject: Re: Question on File::Find
Message-Id: <zZZEg.35879$_k2.636654@news2.nokia.com>

Paul Lalli wrote:

> Paul Lalli wrote:
> > Diana wrote:
> 
> > > I am struggling to use File::Find module,
> > > the issue is, I can use with defining find function with &wanted,
> > > but not with %options, here is what I am doing
> > > my %findoption=( bydepth=>"1" , no_chdir => "1" );
> > > push (@All,find(\%fort,"$Location"));
> > 
> > 1) You didn't include the wanted option in your %findoption hash.
> > If you pass a hash reference as the first option to find, one of the
> > key-value pairs of that hash must be 'wanted' with the value of the
> > subroutine you want to call.
> > 2) find() does not return a list of files it finds.  I have no idea
> > what you think your push statement is doing
> > 3) Do not needlessly double-quote variables (like you did to
> > $Location).  See `perldoc -q quoting`
> 
> 4) What the heck is %fort?  You declared %findoption, but are passing
> a reference to %fort?  If this is your real code, please enable `use
> strict;` and `use warnings;` in your code.  If this is not your real
> code, please DON'T DO THAT!
> 
> Paul Lalli

sorry for the mistake, I presume I modified during posting, my mistake,
it seems I am NOW able to use options like this


my %fort=(wanted=>sub{push (@AllDir,$File::Find::name)},bydepth=>"1" ,
no_chdir => "1" ); ;
find(\%fort,$Location);

-- 



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

Date: Thu, 17 Aug 2006 17:58:26 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Question on File::Find
Message-Id: <iqjer3-k3r.ln1@osiris.mauzo.dyndns.org>


Quoth "Diana" <Diana@hotmail.com>:
>
[File::Find]
> it seems I am NOW able to use options like this
> 
> my %fort=(wanted=>sub{push (@AllDir,$File::Find::name)},bydepth=>"1" ,
> no_chdir => "1" ); ;
> find(\%fort,$Location);

There's no need to quote "1", either. Note that you can build the
hashref inline:

    find ({
        wanted   => sub {
            push (@AllDir, $File::Find::name);
        },
        bydepth  => 1,
        no_chdir => 1,
    }, $Location);

Personally I wouldn't use any of those parens, but you may find them
helpful.

Ben

-- 
Raise your hand if you're invulnerable.
                                                  [benmorrow@tiscali.co.uk]


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

Date: 16 Aug 2006 23:47:38 -0700
From: "Roop" <tarun.sinha@gmail.com>
Subject: Regular Expression for Integer and float values
Message-Id: <1155797258.202024.150170@i3g2000cwc.googlegroups.com>

Hello All

I want to ask regading regular expression.
I want to use such regular expression which only allow integers and
float value.
for example :--

12
12.34
23.456
0.5
0.0
0

I found but not able to find. Please Help me . Suggest me the regular
expression for that 


with regards
Tarun sinha



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

Date: 17 Aug 2006 00:24:25 -0700
From: "Klaus" <klaus03@gmail.com>
Subject: Re: Regular Expression for Integer and float values
Message-Id: <1155799465.118568.140740@m79g2000cwm.googlegroups.com>

Roop wrote:
> I want to ask regading regular expression.
> I want to use such regular expression which only allow integers and
> float value.

see Perlfaq 4:
How do I determine whether a scalar is a number/whole/integer/float?



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

Date: Thu, 17 Aug 2006 08:50:03 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Regular Expression for Integer and float values
Message-Id: <%4WEg.14029$lv.12600@fed1read12>

Roop <tarun.sinha@gmail.com> wrote:
 
> I want to ask regading regular expression.
> I want to use such regular expression which only allow integers and
> float value.
> for example :--
 
> 12
> 12.34
> 23.456
> 0.5
> 0.0
> 0
 
> I found but not able to find. Please Help me . Suggest me the regular
> expression for that 
 
Lets take this step by step... based on your examples...

m/^\d+		# At least one digit (and nothing else) to start the value
 (?:		# Start a cluster but don't capture
   \.\d+	# We may have a decimal point followed by at least one digit
 )?		# The decimal point + following digits may occur either
		# once or not at all
$		# Nothing else can follow
/x;		# And allow whitespace and comments in the RE

This allows all your examples, but not for example: 5.
as it does not have a following digit.

Axel


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

Date: Thu, 17 Aug 2006 11:15:49 +0200
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: Regular Expression for Integer and float values
Message-Id: <44e433cf$0$864$ba4acef3@news.orange.fr>


"Roop" <tarun.sinha@gmail.com> wrote in message 
news:1155797258.202024.150170@i3g2000cwc.googlegroups.com...
> Hello All
>
> I want to ask regading regular expression.
> I want to use such regular expression which only allow integers and
> float value.
> for example :--
>
> 12
> 12.34
> 23.456
> 0.5
> 0.0
> 0
>
> I found but not able to find. Please Help me . Suggest me the regular
> expression for that
>
>
> with regards
> Tarun sinha
>

Look at the cpan module Regexp::Common. Better than re-inventing the wheel 
unless you have unusual constraints.

Something like:
use Regexp::Common;
my $NUMBER = $RE{num}{real}{-keep};
# later
my ($number) = $input =~ $NUMBER;

but read the docs to get just what you want.

Advise based on Perl Best Practices p263






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

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


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