Idiomatically determine all the characters that can be used for symbols: Difference between revisions

Added Perl example
(Scala contribution added.)
(Added Perl example)
Line 294:
{{out}}
<pre>%1 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "_"]</pre>
 
=={{header|Perl}}==
<lang perl># When not using the <code>use utf8</code> pragma, any word character in the ASCII range is allowed.
# the loop below returns: 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz
for $i (0..0x7f) {
$c = chr($i);
print $c if $c =~ /\w/;
}
 
# When 'use utf8' is in force, the same holds true, but the Unicode-aware version of the 'word-character' test is used.
# not supplying output, too much of it
use utf8;
binmode STDOUT, ":utf8";
for (0..0x1ffff) {
$c = chr($_);
print $c if $c =~ /\p{Word}/;
}</lang>
 
=={{header|Perl 6}}==
2,392

edits