Hash :
a1747745
Author :
Date :
2014-12-22T22:15:56
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
<h1>Perl</h1>
<p>To use this language, use the class "language-perl".</p>
<h2>Comments</h2>
<pre><code># Single line comment
=head1 Here There
Be Pods!
=cut</code></pre>
<h2>Strings</h2>
<pre><code>q/foo bar baz/;
q awhy not ?a;
qw(foo bar baz) q{foo bar baz}
q[foo bar baz] qq<foo bar baz>
"foo bar baz" 'foo bar baz' `foo bar baz`</code></pre>
<h2>Regex</h2>
<pre><code>m/foo/ s/foo/bar/
m zfooz s zfoozbarz
qr(foo) m{foo} s(foo)(bar) s{foo}{bar}
m[foo] m<foo> tr[foo][bar] s<foo><bar>
/foo/i
</code></pre>
<h2>Variables</h2>
<pre><code>${^POSTMATCH}
$^V
$element_count = scalar(@whatever);
keys(%users) = 1000;
$1, $_, %!;</code></pre>
<h2>Numbers</h2>
<pre><code>12345
12345.67
.23E-10 # a very small number
3.14_15_92 # a very important number
4_294_967_296 # underscore for legibility
0xff # hex
0xdead_beef # more hex
0377 # octal (only numbers, begins with 0)
0b011011 # binary</code></pre>
<h2>Full example</h2>
<pre><code>sub read_config_file {
my ($class, $filename) = @_;
unless (defined $filename) {
my $home = File::HomeDir->my_home || '.';
$filename = File::Spec->catfile($home, '.pause');
return {} unless -e $filename and -r _;
}
my %conf;
if ( eval { require Config::Identity } ) {
%conf = Config::Identity->load($filename);
$conf{user} = delete $conf{username} unless $conf{user};
}
else { # Process .pause manually
open my $pauserc, '<', $filename
or die "can't open $filename for reading: $!";
while (<$pauserc>) {
chomp;
next unless $_ and $_ !~ /^\s*#/;
my ($k, $v) = /^\s*(\w+)\s+(.+)$/;
Carp::croak "multiple enties for $k" if $conf{$k};
$conf{$k} = $v;
}
}
return \%conf;
}</code></pre>
<h2>Known failures</h2>
<p>There are certain edge cases where Prism will fail.
There are always such cases in every regex-based syntax highlighter.
However, Prism dares to be open and honest about them.
If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
</p>
<h3>Comment-like substring</h3>
<pre><code>"test # test";</code></pre>
<h3>Comment symbol in regexp</h3>
<pre><code>/test#test/;</code></pre>
<h3>Two quotes of the same type (i.e. both single or both double) inside a regex</h3>
<pre><code>/"foo"/;</code></pre>