File indexing completed on 2024-05-12 04:02:11

0001 #!/usr/bin/perl -w
0002 # This is a pseudo Perl file to test Kate's Perl syntax highlighting.
0003 # TODO: this is incomplete, add more syntax examples!
0004 
0005 sub prg($)
0006 {
0007     my $var = shift;
0008 
0009     $var =~ s/bla/foo/igs;
0010     $var =~ s!bla!foo!igs;
0011     $var =~ s#bla#foo#igs;
0012     $var =~ tr/a-z/A-Z/;
0013     ($match) = ($var =~ m/(.*?)/igs);
0014 
0015     $test = 2/453453.21;
0016     $test /= 2;
0017 
0018     print qq~d fsd fsdf sdfl sd~
0019     
0020     $" = '/';
0021     
0022     $foo = <<__EOF;
0023 d ahfdklf klsdfl sdf sd
0024 fsd sdf sdfsdlkf sd
0025 __EOF
0026 
0027     $x = "dasds";
0028 
0029     next if( $match eq "two" );
0030     next if( $match =~ /go/i );
0031 
0032     @array = (1,2,3);       # a comment
0033     # Test qw versions with special ending characters
0034     @array = qw(apple foo bar);
0035     @array = qw[apple foo bar];
0036     @array = qw{apple foo bar};
0037     @array = qw<apple foo bar>;
0038     @array = qw(
0039         multi
0040         line
0041         test
0042     );
0043     # Test qw with non special ending characters;
0044     @array = qw/apple foo bar/;
0045     @array = qw|apple foo bar|;
0046     @array = qw@apple foo bar@;
0047     @array = qw!apple foo bar!;
0048     @array = qw"apple foo bar";
0049     @array = qw'apple foo bar';
0050     push(@array, 4);
0051     %hash = (red => 'rot',
0052         blue => 'blau');
0053     print keys(%hash);
0054 }
0055 
0056 sub blah {
0057     my $str = << '    EOS';
0058         this is my string
0059         and it's continuation
0060     EOS
0061 
0062     $str = "hello world";
0063 
0064     $str = << "    EOS";
0065         this is my string
0066         and it's continuation
0067     EOS
0068 }
0069 
0070 &blah;
0071 prg("test");
0072 
0073 # Bracket closures in RegExp patterns (bug #364866)
0074 qr{ ${var} aa{aa{a}a} aa*b?};
0075 qr(aa(a(a(a(b|c)a)a)a)aa*b?);
0076 s{aaa {aaa} a \x{A2} *b?}{aa};
0077 s(aa(a(a(a(b|c)a)a)a)aa)(aa);
0078 
0079 # Strings as scalar references (bug #348765)
0080 $x = \'Reference of a String';
0081 $y = \"Reference of a String";
0082 
0083 # Variables that start with underscore (bug #355300)
0084 $_variable
0085 $_ # Reserved var.
0086 
0087 for my $x ($hash->{arr}->@*) {
0088     for my $k (keys $k->%*) {
0089         ...
0090     }
0091 }
0092 
0093 # Highlight correctly operator // (bug #407327)
0094 $x = ns // "";
0095 print $x;