ironpaw has asked for the wisdom of the Perl Monks concerning the following question:
lo gain monks.
After reading a little about; use strict I am still confussed. Other than just declairing my variables about the place in a seemingly useless way can I get my scripts to run with this option and I fail to see the reason (I am sure there is a good one). I thought I'd try a different approach. Take the following horribly written script of mine (it works but pick it to bits if you like). What would be the most logical way to add Use Strict to this and why is that a benefit. If it makes it more readable how is that (how are you expecting to read a script)? I know I should use this option (I keep getting told to) but not really how or why. Does it improve speed? Does it prevent errors and if so how. I know this is a common question but maybe this way someone might answer it in a way we greenies understand (those who are learning without structure but want some like me). Thanks, I'm all for a good idea if I can understand and use it. Paw
After reading a little about; use strict I am still confussed. Other than just declairing my variables about the place in a seemingly useless way can I get my scripts to run with this option and I fail to see the reason (I am sure there is a good one). I thought I'd try a different approach. Take the following horribly written script of mine (it works but pick it to bits if you like). What would be the most logical way to add Use Strict to this and why is that a benefit. If it makes it more readable how is that (how are you expecting to read a script)? I know I should use this option (I keep getting told to) but not really how or why. Does it improve speed? Does it prevent errors and if so how. I know this is a common question but maybe this way someone might answer it in a way we greenies understand (those who are learning without structure but want some like me). Thanks, I'm all for a good idea if I can understand and use it. Paw
use File::Find; $feeddir = "c:/orant8"; chdir("$feeddir"); find(\&wanted, "$feeddir"); sub wanted { m/TNSNAMES.ORA/i or return; Details($File::Find::name); } sub Details { $file = shift; open(CLEAN, "$file"); @cleanup = <CLEAN>; for ($i = 0; $i < scalar(@cleanup); $i++) { $cleanup[$i] =~ s/oldserv001/newserv001/ig; $cleanup[$i] =~ s/oldserv002/newserv002/ig; $cleanup[$i] =~ s/oldserv003/newserv003/ig; $cleanup[$i] =~ s/oldserv004/newserv004/ig; $cleanup[$i] =~ s/oldserv005/newserv005/ig; $cleanup[$i] =~ s/oldserv006/newserv006/ig; $cleanup[$i] =~ s/oldserv2001/newserv2001/ig; $cleanup[$i] =~ s/oldserv2006/newserv2002/ig; $cleanup[$i] =~ s/oldserv2008/newserv2003/ig; $cleanup[$i] =~ s/oldserv2009/newserv2004/ig; $cleanup[$i] =~ s/oldserv2010/newserv2005/ig; $cleanup[$i] =~ s/oldserv2011/newserv2006/ig; $cleanup[$i] =~ s/oldserv2012/newserv2007/ig; $new[$i]=$cleanup[$i]; } close CLEAN; } open(WRITE, "> $file"); print WRITE @new;
Edit by tye, title, add READMORE
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Use Strict
by dvergin (Monsignor) on Jul 17, 2003 at 02:50 UTC | |
by barbie (Deacon) on Jul 17, 2003 at 09:06 UTC | |
by cfreak (Chaplain) on Jul 17, 2003 at 13:46 UTC | |
by barbie (Deacon) on Jul 18, 2003 at 08:54 UTC | |
by cfreak (Chaplain) on Jul 18, 2003 at 14:47 UTC | |
Re: Use Strict
by Trimbach (Curate) on Jul 17, 2003 at 03:09 UTC | |
Re: Use Strict
by Cody Pendant (Prior) on Jul 17, 2003 at 06:19 UTC |
Back to
Seekers of Perl Wisdom