On 20/11/2010 21:48, shawn wilson wrote:
so, i've read data in from a spreadsheet, assign it to a 3d array and i need
to output another spreadsheet with worksheets that are named like one of the
cell of the first. however, when i do i get this:
Invalid character []:*?/\ in worksheet name: M/V AUTO ATLAS at ./
xldatesel.pl line 93
ok, find, so i do this:
my $name = $xldata[ $row ][ 14 ] =~ tr/[^A-Za-z0-9]//d;
so, then i get this:
Worksheet name '10', with case ignored, is already in use at
./xldatesel.plline 93
i'm actually printing out the results of $name and i'm seeing numbers from 8
to about 15. it seems to be giving me the string length and not the name.
wtf?
Hi Shawn
First of all, the tr/// operator does not take a regular expression for
its searchlist. You need to use the /c modifier to complement the list
of valid characters:
tr/A-Za-z0-9//dc;
Also, the =~ operator binds more tightly than =, so you are modifying
the array element in-place, and assigning the number of deleted
characters to $name. Simply use parentheses to force the desired priority:
(my $name = $xldata[$row][14]) =~ tr/A-Za-z0-9//cd;
HTH,
- Rob
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/