#!/usr/bin/perl use strict; use warnings; # 783199 my @data = ; for my $line (@data) { chomp $line; # if ( $line =~ /[<>@#\$%^&*()_+=|\{\}\[\]\/\\]/ ) { # OP's char class ie "escaped the $ sign" # if ( $line =~ /[<>@#%^&*()_+=|\{\}\[\]\/\\]\$/ ) { # OP's char class ie "escaped the $ sign" with \$ moved to end of class # if ( $line =~ /[<>@#$%^&*()_+=|\{\}\[\]\/\\]/) { # $ sign not backslashed # if ( $line =~ /[<>@#\$%^&*()_+=|{}\]\/\\]/ ) { # unnecessary backslashes removed if ( $line =~ /[0-9<>@#\$%^&*()_+=|{}[\]\/\\]/ ) { # rule out decimal digits print "\$line: $line \t is not okay \n"; }else { print "\$line: $line \t is okay \n"; } } =head $ sign in char class preceded by a backslash $line: hello there0 is okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay $ sign in char class NOT preceded by a backslash $line: hello there0 is not okay $line: hello there is okay $line: hello there$ now is okay $line: hello there $ now is okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay Unnecessary backslashes removed: $line: hello there0 is okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is okay $line: by [rights] this should fail. is not okay and with Decimal Digits rejected: $line: hello there0 is not okay $line: hello there is okay $line: hello there$ now is not okay $line: hello there $ now is not okay $line: hello there [ is not okay $line: by [rights] this should fail. is not okay =cut __DATA__ hello there0 hello there hello there$ now hello there $ now hello there [ by [rights] this should fail.