Re: File::Find NO RECURSION Howto

2010-03-03 Thread Shlomi Fish
On Monday 01 Mar 2010 19:31:15 Shawn H Corey wrote:
> Shlomi Fish wrote:
> > Well, Matt S. Trout shared his sentiments about "I cannot use CPAN" here:
> > 
> > http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/
> 
> Well, Matt is wrong.  You can't always use CPAN.  Yes, you can set it up
> so you can use it in development, but that doesn't mean you can do it in
> production.  I have worked in places where the policy was no software
> that's not approved by the sysadmins and approval of a single module may
> take 6 to 18 months.  They're even very strict about downloading a copy
> and cut & paste.  A foolish policy, kinda like, our horse will never get
> sick from bad grain if we never feed it but managers _always_ know best. 
> ;)

Heh, tell me about it. Medium-to-large businesses shoot themselves in the foot 
by incorporating these god-awful policies and becoming very non-agile. Then 
they wonder why startups with much fewer resources can often easily out-
compete them. I read somewhere (Paul Graham I think, but I can no longer find 
it) that as companies grow they adopt more and more rules and regulations 
after learning from mistakes they made in the past. But these rules prevent a 
lot of legitimate actions and in turn make the company much less agile. And 
sometimes they impose these rules on start-ups that they buy.

It was later compared to 
http://en.wikipedia.org/wiki/Sarbanes%E2%80%93Oxley_Act which killed the IPOs 
in .us and was another regulation that was passed and which had unwanted side-
effects.

In any case, such antagonism towards using third-party code will make the 
person working for such companies beyond help and doomed anyway you look at 
it, so we can ignore it.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shawn H Corey
Shlomi Fish wrote:
> Well, Matt S. Trout shared his sentiments about "I cannot use CPAN" here:
> 
> http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/
> 

Well, Matt is wrong.  You can't always use CPAN.  Yes, you can set it up
so you can use it in development, but that doesn't mean you can do it in
production.  I have worked in places where the policy was no software
that's not approved by the sysadmins and approval of a single module may
take 6 to 18 months.  They're even very strict about downloading a copy
and cut & paste.  A foolish policy, kinda like, our horse will never get
sick from bad grain if we never feed it but managers _always_ know best.  ;)


-- 
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shlomi Fish
On Monday 01 Mar 2010 15:00:26 raphael() wrote:
> On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey  wrote:
> > raphael() wrote:
> > > Hi,
> > > 
> > > How can I stop File::Find to go below current dir? i.e. no recursion.
> > > 
> > > Although I can use glob or <*> to get file names in current dir.
> > > But I wanted to know if File::Find has a maxdepth limit like linux
> > 
> > "find".
> > 
> > > The script I created uses a switch which decides if recursion is
> > > allowed
> > 
> > or
> > 
> > > not.
> > > It uses the system find like this..
> > > 
> > > open(FIND, "find -maxdepth $recursive |" );
> > > 
> > > I wanted to remove this dependency on system find. Is it possible with
> > > File::Find?
> > > 
> > > I tried this after googling
> > > 
> > > http://www.perlmonks.org/?node_id=676958
> > > 
> > > sub wanted
> > > {
> > > 
> > > if ( -d ) { # should I write this as -d $File::Find::name
> > 
> > # No, this is shorthand for:
> >if( -d $_ ){
> >
> > >   $File::Find::prune = 1;
> > >   return;
> > > 
> > > }
> > > print $File::Find::name . "\n";
> > > 
> > > }
> > 
> > And didn't it work?  The if statement works on all directories.  This
> > means that all directories except the top-level one will not be searched.
> > 
> > 
> > --
> > Just my 0.0002 million dollars worth,
> > 
> >  Shawn
> > 
> > Programming is as much about organization and communication
> > as it is about coding.
> > 
> > I like Perl; it's the only language where you can bless your
> > thingy.
> > 
> > Eliminate software piracy:  use only FLOSS.
> 
> Nope. It ddn't work. Any ideas?
> I am thinking to use File::Find::Rule. But I didn't want any module
> dependency for this script.

You can look at how File::Find::Rule does it and duplicate the logic.

> 
> And Shlomi your message came in while I was typing this. Going to check the
> modules you mentioned.

Thanks.

> But it would have been great if I didn't has to use a module :( The people
> around me no sh*t about installing perl
> modules from CPAN.

Well, Matt S. Trout shared his sentiments about "I cannot use CPAN" here:

http://www.shadowcat.co.uk/blog/matt-s-trout/but-i-cant-use-cpan/

I've placed a link to it here:

http://perl-begin.org/topics/cpan/

> 
> Thanks all.
> 
> PS - Shlomi, your website is GOOD!

Thanks for the compliment! If possible, please share it with your friends and 
on social-bookmarking/social-networks/etc. sites that you belong to.

BTW, you shoulnd't highlight words using all-uppercase-letters. (It's 
considered akin to shouting). Instead use *...* , /.../ or _..._ .

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Optimising Code for Speed - http://shlom.in/optimise

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
On Mon, Mar 1, 2010 at 6:18 PM, Shawn H Corey  wrote:

> raphael() wrote:
> > Hi,
> >
> > How can I stop File::Find to go below current dir? i.e. no recursion.
> >
> > Although I can use glob or <*> to get file names in current dir.
> > But I wanted to know if File::Find has a maxdepth limit like linux
> "find".
> >
> > The script I created uses a switch which decides if recursion is allowed
> or
> > not.
> > It uses the system find like this..
> >
> > open(FIND, "find -maxdepth $recursive |" );
> >
> > I wanted to remove this dependency on system find. Is it possible with
> > File::Find?
> >
> > I tried this after googling
> >
> > http://www.perlmonks.org/?node_id=676958
> >
> > sub wanted
> > {
> > if ( -d ) { # should I write this as -d $File::Find::name
>
> # No, this is shorthand for:
>if( -d $_ ){
>
> >   $File::Find::prune = 1;
> >   return;
> > }
> > print $File::Find::name . "\n";
> > }
> >
>
> And didn't it work?  The if statement works on all directories.  This
> means that all directories except the top-level one will not be searched.
>
>
> --
> Just my 0.0002 million dollars worth,
>  Shawn
>
> Programming is as much about organization and communication
> as it is about coding.
>
> I like Perl; it's the only language where you can bless your
> thingy.
>
> Eliminate software piracy:  use only FLOSS.
>

Nope. It ddn't work. Any ideas?
I am thinking to use File::Find::Rule. But I didn't want any module
dependency for this script.

And Shlomi your message came in while I was typing this. Going to check the
modules you mentioned.
But it would have been great if I didn't has to use a module :( The people
around me no sh*t about installing perl
modules from CPAN.

Thanks all.

PS - Shlomi, your website is GOOD!


Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shlomi Fish
On Monday 01 Mar 2010 13:23:16 raphael() wrote:
> Hi,
> 
> How can I stop File::Find to go below current dir? i.e. no recursion.
> 
> Although I can use glob or <*> to get file names in current dir.
> But I wanted to know if File::Find has a maxdepth limit like linux "find".
> 

Not, by itself, but there are wrappers around it that provides you with it. 
And there are several alternative modules like File-Find-Object or File-Next 
that solve some of its inherent philosophical limitations. For a summary see:

* http://www.shlomifish.org/open-source/projects/File-Find-Object/

* http://www.perlfoundation.org/perl5/index.cgi?alternatives_to_file_find

> The script I created uses a switch which decides if recursion is allowed or
> not.
> It uses the system find like this..
> 
> open(FIND, "find -maxdepth $recursive |" );
> 
> I wanted to remove this dependency on system find. Is it possible with
> File::Find?

It is possible.

> 
> I tried this after googling
> 
> http://www.perlmonks.org/?node_id=676958
> 
> sub wanted
> {
> if ( -d ) { # should I write this as -d $File::Find::name
>   $File::Find::prune = 1;
>   return;
> }
> print $File::Find::name . "\n";
> }

Well, this will only be equivalent to -maxdepth 1 not to larger values. I 
can't tell you offhand whether it's "-d $_" or "-d $File::Find::name" because 
the File::Find interface is evil-incarnate and I'm trying to forget it. If you 
want to prune after an arbitrary maxdepth, you'll need to keep track of the 
current depth and the level there. May be File::Find gives you that but you 
really should be using File::Find::Object, File::Find::Rule or 
File::Find::Object::Rule .

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
What does "Zionism" mean? - http://shlom.in/def-zionism

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: File::Find NO RECURSION Howto

2010-03-01 Thread Shawn H Corey
raphael() wrote:
> Hi,
> 
> How can I stop File::Find to go below current dir? i.e. no recursion.
> 
> Although I can use glob or <*> to get file names in current dir.
> But I wanted to know if File::Find has a maxdepth limit like linux "find".
> 
> The script I created uses a switch which decides if recursion is allowed or
> not.
> It uses the system find like this..
> 
> open(FIND, "find -maxdepth $recursive |" );
> 
> I wanted to remove this dependency on system find. Is it possible with
> File::Find?
> 
> I tried this after googling
> 
> http://www.perlmonks.org/?node_id=676958
> 
> sub wanted
> {
> if ( -d ) { # should I write this as -d $File::Find::name

# No, this is shorthand for:
if( -d $_ ){

>   $File::Find::prune = 1;
>   return;
> }
> print $File::Find::name . "\n";
> }
> 

And didn't it work?  The if statement works on all directories.  This
means that all directories except the top-level one will not be searched.


-- 
Just my 0.0002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




File::Find NO RECURSION Howto

2010-03-01 Thread raphael()
Hi,

How can I stop File::Find to go below current dir? i.e. no recursion.

Although I can use glob or <*> to get file names in current dir.
But I wanted to know if File::Find has a maxdepth limit like linux "find".

The script I created uses a switch which decides if recursion is allowed or
not.
It uses the system find like this..

open(FIND, "find -maxdepth $recursive |" );

I wanted to remove this dependency on system find. Is it possible with
File::Find?

I tried this after googling

http://www.perlmonks.org/?node_id=676958

sub wanted
{
if ( -d ) { # should I write this as -d $File::Find::name
  $File::Find::prune = 1;
  return;
}
print $File::Find::name . "\n";
}