Forum Moderators: coopster & phranque

Message Too Old, No Replies

Anything wrong with this code?

Causes ISE message on some servers.

         

Jesse_Smith

12:08 pm on Jan 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there anything wrong with this code? On some users servers it generates the ISE message, but I never get it, so I can't fix it, except by having them use a version from before I added it!


}
sub clean_my_title {
my $old_title = shift;
$old_title =~ s/\(¦\/¦\\¦%¦,¦\@¦\[¦\]¦>¦<¦"¦\+¦\*¦\?¦$¦=¦:¦\)¦\&amp;¦\$¦'¦,¦\#¦\!//g;
$old_title =~ s/ ¦__¦___/_/g;
$old_title =~ s/_-_/-/g;
$old_title =~ s/-_/-/g;
return $old_title;
}
1;

Would one of those marks need a \ before it?

With the older version that code is replaced with....


}
1;
}

rocknbil

11:49 pm on Jan 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try backslashing your undescores

\_

and look up the documentation on using underscores in variable names, particularly beginning characters. I say to look it up because I forget what it said, only that using underscores can cause some odd results. Just remember what

@_
and
$_ do and you'll see why. :-)

I hope that helps.

EDIT: on second look, think about what

[a-z][0-9]

does and you may want to backslash your hyphens too.

jollymcfats

1:13 am on Jan 27, 2005 (gmt 0)

10+ Year Member



The only error I saw in there is fixed below:
$old_title =~ s/\(¦\/¦\\¦%¦,¦\@¦\[¦\]¦>¦<¦"¦\+¦\*¦\?¦\$¦=¦:¦\)¦\&amp;¦\$¦'¦,¦\#¦\!//g;

I wouldn't expect that to produce an ISE, but I suppose it's possible. Otherwise the code should run on any release of Perl 5. There might be something else going on, maybe line ending problems for the latest version of the file, caused by transfer from Unix to Windows or vice versa.

You could simplify the first regex by reversing it:

$old_title =~ s/&amp;//g;
$old_title =~ s/[^\w\d\-_. ]//g;

The last will drop anything but a "word character" (a-z and their accented versions depending on your locale settings), digits and anything extra you'd like to let through.