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 90 91 92 93 94 95 96 97 98 99 100 101 102
|
<!DOCTYPE html>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>highlight.pl</title>
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (Perl) - Theme (Breeze Light)"/>
</head><body style="background-color:#ffffff;color:#1f1c1b"><pre>
<span style="font-weight:bold">#!/usr/bin/perl -w</span>
<span style="color:#898887"># This is a pseudo Perl file to test Kate's Perl syntax highlighting.</span>
<span style="color:#898887"># </span><span style="color:#ca9219;background-color:#451e1a;font-weight:bold">TODO</span><span style="color:#898887">: this is incomplete, add more syntax examples!</span>
<span style="font-weight:bold">sub </span><span style="color:#644a9b">prg</span>(<span style="color:#0057ae">$</span>)
{
<span style="font-weight:bold">my</span> <span style="color:#0057ae">$var</span> = <span style="color:#644a9b">shift</span>;
<span style="color:#0057ae">$var</span> =~ <span style="color:#006e28;font-weight:bold">s/</span><span style="color:#006e28">bla</span><span style="color:#006e28;font-weight:bold">/</span><span style="color:#bf0303">foo</span><span style="color:#006e28;font-weight:bold">/igs</span>;
<span style="color:#0057ae">$var</span> =~ <span style="color:#006e28;font-weight:bold">s!</span><span style="color:#006e28">bla</span><span style="color:#006e28;font-weight:bold">!</span><span style="color:#bf0303">foo</span><span style="color:#006e28;font-weight:bold">!igs</span>;
<span style="color:#0057ae">$var</span> =~ <span style="color:#006e28;font-weight:bold">s#</span><span style="color:#006e28">bla</span><span style="color:#006e28;font-weight:bold">#</span><span style="color:#bf0303">foo</span><span style="color:#006e28;font-weight:bold">#igs</span>;
<span style="color:#0057ae">$var</span> =~ <span style="color:#006e28;font-weight:bold">tr</span><span style="color:#006e28">/a-z/A-Z/</span>;
(<span style="color:#0057ae">$match</span>) = (<span style="color:#0057ae">$var</span> =~ <span style="color:#006e28;font-weight:bold">m/</span><span style="color:#924c9d">(</span><span style="color:#006e28">.</span><span style="color:#924c9d">*?)</span><span style="color:#006e28;font-weight:bold">/igs</span>);
<span style="color:#0057ae">$test</span> = <span style="color:#b08000">2</span>/<span style="color:#b08000">453453.21</span>;
<span style="color:#0057ae">$test</span> /= <span style="color:#b08000">2</span>;
<span style="color:#644a9b">print</span> <span style="color:#006e28;font-weight:bold">qq~</span><span style="color:#bf0303">d fsd fsdf sdfl sd</span><span style="color:#006e28;font-weight:bold">~</span>
<span style="color:#bf0303">$"</span> = <span style="color:#006e28;font-weight:bold">'</span><span style="color:#ff5500">/</span><span style="color:#006e28;font-weight:bold">'</span>;
<span style="color:#0057ae">$foo</span> = <span style="color:#006e28;font-weight:bold"><<</span><span style="font-weight:bold">__EOF;</span>
<span style="color:#bf0303">d ahfdklf klsdfl sdf sd</span>
<span style="color:#bf0303">fsd sdf sdfsdlkf sd</span>
<span style="font-weight:bold">__EOF</span>
<span style="color:#0057ae">$x</span> = <span style="color:#006e28;font-weight:bold">"</span><span style="color:#bf0303">dasds</span><span style="color:#006e28;font-weight:bold">"</span>;
<span style="font-weight:bold">next</span> <span style="font-weight:bold">if</span>( <span style="color:#0057ae">$match</span> <span style="color:#006e28;font-weight:bold">eq</span> <span style="color:#006e28;font-weight:bold">"</span><span style="color:#bf0303">two</span><span style="color:#006e28;font-weight:bold">"</span> );
<span style="font-weight:bold">next</span> <span style="font-weight:bold">if</span>( <span style="color:#0057ae">$match</span> =~ <span style="color:#006e28;font-weight:bold">/</span><span style="color:#006e28">go</span><span style="color:#006e28;font-weight:bold">/i</span> );
<span style="color:#0057ae">@array</span> = (<span style="color:#b08000">1</span>,<span style="color:#b08000">2</span>,<span style="color:#b08000">3</span>); <span style="color:#898887"># a comment</span>
<span style="color:#898887"># Test qw versions with special ending characters</span>
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw(</span>apple foo bar<span style="color:#006e28;font-weight:bold">)</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw[</span>apple foo bar<span style="color:#006e28;font-weight:bold">]</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw{</span>apple foo bar<span style="color:#006e28;font-weight:bold">}</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw<</span>apple foo bar<span style="color:#006e28;font-weight:bold">></span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw(</span>
multi
line
test
<span style="color:#006e28;font-weight:bold">)</span>;
<span style="color:#898887"># Test qw with non special ending characters;</span>
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw/</span>apple foo bar<span style="color:#006e28;font-weight:bold">/</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw|</span>apple foo bar<span style="color:#006e28;font-weight:bold">|</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw@</span>apple foo bar<span style="color:#006e28;font-weight:bold">@</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw!</span>apple foo bar<span style="color:#006e28;font-weight:bold">!</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw"</span>apple foo bar<span style="color:#006e28;font-weight:bold">"</span>;
<span style="color:#0057ae">@array</span> = <span style="color:#006e28;font-weight:bold">qw'</span>apple foo bar<span style="color:#006e28;font-weight:bold">'</span>;
<span style="color:#644a9b">push</span>(<span style="color:#0057ae">@array</span>, <span style="color:#b08000">4</span>);
<span style="color:#0057ae">%hash</span> = (red => <span style="color:#006e28;font-weight:bold">'</span><span style="color:#ff5500">rot</span><span style="color:#006e28;font-weight:bold">'</span>,
blue => <span style="color:#006e28;font-weight:bold">'</span><span style="color:#ff5500">blau</span><span style="color:#006e28;font-weight:bold">'</span>);
<span style="color:#644a9b">print</span> <span style="color:#644a9b">keys</span>(<span style="color:#0057ae">%hash</span>);
}
<span style="font-weight:bold">sub </span><span style="color:#644a9b">blah</span> {
<span style="font-weight:bold">my</span> <span style="color:#0057ae">$str</span> = <span style="color:#006e28;font-weight:bold"><<</span><span style="font-weight:bold"> ' EOS';</span>
this is my string
and it's continuation
<span style="font-weight:bold"> EOS</span>
<span style="color:#0057ae">$str</span> = <span style="color:#006e28;font-weight:bold">"</span><span style="color:#bf0303">hello world</span><span style="color:#006e28;font-weight:bold">"</span>;
<span style="color:#0057ae">$str</span> = <span style="color:#006e28;font-weight:bold"><<</span><span style="font-weight:bold"> " EOS";</span>
<span style="color:#bf0303"> this is my string</span>
<span style="color:#bf0303"> and it's continuation</span>
<span style="font-weight:bold"> EOS</span>
}
&blah;
prg(<span style="color:#006e28;font-weight:bold">"</span><span style="color:#bf0303">test</span><span style="color:#006e28;font-weight:bold">"</span>);
<span style="color:#898887"># Bracket closures in RegExp patterns (bug #364866)</span>
<span style="color:#006e28;font-weight:bold">qr{</span><span style="color:#006e28"> </span><span style="color:#924c9d">$</span><span style="color:#006e28">{var} aa{aa{a}a} aa</span><span style="color:#924c9d">*</span><span style="color:#006e28">b</span><span style="color:#924c9d">?</span><span style="color:#006e28;font-weight:bold">}</span>;
<span style="color:#006e28;font-weight:bold">qr(</span><span style="color:#006e28">aa</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">b</span><span style="color:#924c9d">|</span><span style="color:#006e28">c</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">aa</span><span style="color:#924c9d">*</span><span style="color:#006e28">b</span><span style="color:#924c9d">?</span><span style="color:#006e28;font-weight:bold">)</span>;
<span style="color:#006e28;font-weight:bold">s{</span><span style="color:#006e28">aaa {aaa} a </span><span style="color:#bf0303">\x{A2}</span><span style="color:#006e28"> </span><span style="color:#924c9d">*</span><span style="color:#006e28">b</span><span style="color:#924c9d">?</span><span style="color:#006e28;font-weight:bold">}{</span><span style="color:#bf0303">aa</span><span style="color:#006e28;font-weight:bold">}</span>;
<span style="color:#006e28;font-weight:bold">s(</span><span style="color:#006e28">aa</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">a</span><span style="color:#924c9d">(</span><span style="color:#006e28">b</span><span style="color:#924c9d">|</span><span style="color:#006e28">c</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">a</span><span style="color:#924c9d">)</span><span style="color:#006e28">aa</span><span style="color:#006e28;font-weight:bold">)(</span><span style="color:#bf0303">aa</span><span style="color:#006e28;font-weight:bold">)</span>;
<span style="color:#898887"># Strings as scalar references (bug #348765)</span>
<span style="color:#0057ae">$x</span> = \<span style="color:#006e28;font-weight:bold">'</span><span style="color:#ff5500">Reference of a String</span><span style="color:#006e28;font-weight:bold">'</span>;
<span style="color:#0057ae">$y</span> = \<span style="color:#006e28;font-weight:bold">"</span><span style="color:#bf0303">Reference of a String</span><span style="color:#006e28;font-weight:bold">"</span>;
<span style="color:#898887"># Variables that start with underscore (bug #355300)</span>
<span style="color:#0057ae">$_variable</span>
<span style="color:#bf0303">$_</span> <span style="color:#898887"># Reserved var.</span>
<span style="font-weight:bold">for</span> <span style="font-weight:bold">my</span> <span style="color:#0057ae">$x</span> (<span style="color:#0057ae">$hash</span>->{arr}-><span style="color:#0057ae">@</span><span style="color:#006e28;font-weight:bold">*</span>) {
<span style="font-weight:bold">for</span> <span style="font-weight:bold">my</span> <span style="color:#0057ae">$k</span> (<span style="color:#644a9b">keys</span> <span style="color:#0057ae">$k</span>->%<span style="color:#006e28;font-weight:bold">*</span>) {
...
}
}
<span style="color:#898887"># Highlight correctly operator // (bug #407327)</span>
<span style="color:#0057ae">$x</span> = ns // <span style="color:#006e28;font-weight:bold">""</span>;
<span style="color:#644a9b">print</span> <span style="color:#0057ae">$x</span>;
</pre></body></html>
|