in reply to Re: find and replace project with values coming from a table
in thread find and replace project with values coming from a table
There are a couple of minor issues with this implementation related to the last bit of code (to print out the results).
First off, it is extremely unwise to set any punctuation vars (which $LIST_SEPERATOR happens to be, even if it doesnt look it) without utilizing a local and an enclosing scope. Even though it isnt directly an issue in the code you posted its best not to get into bad habits. (This criticism applies to Abigail-II as well. You and he probably know when this is ok and when not, but it is unlikely the OP does. :-)
Second is the use of use English; which unless this has been fixed (I dont know if it has or not in newer perls, and certainly hasnt in older ones) then the module carries an unnacceptable performance penalty for programs that use regexes. (It triggers "saw-ampersand" which causes regexes to be signifigantly slower in ALL code used in the current running interpreter.) The general rule of thumb is to not use English but just learn the mnemomics of the punctuation vars. $" and $, are not difficult to remember IMO, even if they do look weird.
Anyway, all that aside IMO Its better to just say
# And show the resulting array. foreach my $row (@data) { print qq(["),join('", "',@$row),qq("]\n); }
as it actually works out that even when you use $" or $, directly that the join statement is less chars to type:
{local$"=','; print "@array\n";} print join(',',@array),"\n";
And doesnt have any potential for accidental action at a distance which is what you get by setting any of the punction vars without localizing them as tightly as possible.
Anyway, it was cool of you to produce a "beginners" version of Abigail-IIs code. ++ to you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find and replace project with values coming from a table
by Abigail-II (Bishop) on Jul 05, 2003 at 22:20 UTC | |
by demerphq (Chancellor) on Jul 06, 2003 at 11:32 UTC | |
by Abigail-II (Bishop) on Jul 06, 2003 at 21:23 UTC | |
by demerphq (Chancellor) on Jul 06, 2003 at 22:24 UTC | |
by Abigail-II (Bishop) on Jul 06, 2003 at 22:49 UTC | |
by Anonymous Monk on Jul 05, 2003 at 23:39 UTC |