Skip to content

Perl support #33

Open
Open
@rwstauner

Description

@rwstauner

After seeing the list of supported languages I was quite disappointed to see that Perl was not in the list.

Any plans to support it?

We just started using RedMine at $work.

If the answer is "patches welcome" you may hear from me again sometime...

Activity

korny

korny commented on Sep 2, 2012

@korny
Member

No plans to support it currently. I don't know enough about Perl, and 'm scared of the language's syntax ;-) Also, what to support, Perl 5 or 6?

Patches are very welcome, but we need a LOT of example code to make sure it doesn't crash even on the most hideous Perl code. Forking the Ruby scanner might be a good start.

korny

korny commented on Sep 2, 2012

@korny
Member
rwstauner

rwstauner commented on Sep 2, 2012

@rwstauner
Author

I'd personally be interested in a Perl 5 scanner.
I would suggest if a scanner were added for either version that both be kept in parallel as perl 6 and perl 5 are fairly different languages and have different futures at the moment. If perl 6 ever really replaces perl 5 I expect that will be many years from now.

Thanks for the link... when I tried to look at that site before it seemed to not be working... i kept getting the same message on every page. It looks to be working now, so I'll take a look at it sometime.

Thanks.

korny

korny commented on Sep 3, 2012

@korny
Member

So we should implement a Perl 5 scanner, and make sure it doesn't totally mess up if you give it Perl 6 :-)

Thanks for the link... when I tried to look at that site before it seemed to not be working... i kept getting the same message on every page.

Sorry -.-' I guess that's because we recently upgraded to Ruby 1.9…you know how it goes.

kissifrot

kissifrot commented on Nov 18, 2013

@kissifrot

Hello, any news on this? :-)

korny

korny commented on Nov 18, 2013

@korny
Member

No progress yet, sorry. I'll announce here when there's anything new.

shoorick

shoorick commented on Sep 24, 2016

@shoorick

Sample of simple Perl code:

#!/usr/bin/perl -w
# comments start with #
# first line can be treated as comment but it's a shebang

use strict;

=head1 DESCRIPTION

Here are samples of Perl code.
This chunk is POD - Plain Old Documentation,
it can contain B<bold>, I<italic>, C<code>, links L<http://example.net>,
entitites E<gt>, filenames F<.bashrc>.

POD starts from =word which haven't any chars before.
Words =pod, =head1, =head2, =head3, =head4, =over, =item, =back, =begin, =end, =for,
and =encoding are marking begin of section; word =cut ends any section.

=head1 SEE ALSO

L<perlpod> or L<< http://perldoc.perl.org/perlpod.html >>

=cut

my $scalar = 42;
my @list   = ( 'alice', 'bob', 3.1415926 );
my %hash   = ( bare => 7, 'key' => $scalar );
my $refs   = {
    'scalar' => \$scalar,
    'list'   => \@list,
    'hash'   => \%hash,
};
my $aref = \@list;

# Function with parentheses
print
    join(' ', $list[1], $hash{'bare'}, $refs->{list}->[3]),
    "string can contain variables like $scalar and characters\n",
    qq{can\x20too}, qq=and too\cJ=,
    `uname -a`, qx<df -h>;

# and without them
my @fruits = qw/ apple banana cucumber duck elephant /;
print
    sort { $b cmp $a }
    grep { /a/ } @fruits;

# if can be used without parentheses too
printf
    "%f = %f. File %s, line %d\n",
    $$aref[2], $aref->[2], __FILE__, __LINE__
    if $#list == 2;

# Regular expressions
$list[1] =~ s/b/Bh/g
    if $list[0] =~ /i/
    && $list[1] =~ m-o-;

my @regexps = ( /\d+/, qr{\w} );

LABEL:
foreach ( @fruits ) {
    # implicit using of $_ variable
    next LABEL if /c/;
    print;
}

As written in http://odd-eyed-code.org/projects/coderay/wiki/ScannerRequests

Provide links to useful information about the language lexic, such as:

  • a list of reserved words

http://perldoc.perl.org/perlfunc.html

Here are Perl's functions (including things that look like functions, like some keywords and named operators) arranged by category. Some functions appear in more than one place.

  • Functions for SCALARs or strings
    chomp, chop, chr, crypt, fc, hex,index, lc, lcfirst, length, oct, ord, pack, q//, qq//, reverse, rindex, sprintf, substr, tr///, uc, ucfirst, y///
  • Regular expressions and pattern matching
    m//, pos, qr//, quotemeta, s///, split, study
  • Numeric functions
    abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand
  • Functions for real @ARRAYs
    each, keys, pop, push, shift, splice, unshift, values
  • Functions for list data
    grep, join, map, qw//, reverse, sort, unpack
  • Functions for real %HASHes
    delete, each, exists, keys, values
  • Input and output functions
    binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock, format, getc, print, printf, read, readdir, readline rewinddir, say, seek, seekdir, select, syscall, sysread, sysseek, syswrite, tell, telldir, truncate, warn, write
  • Functions for fixed-length data or records
    pack, read, syscall, sysread, sysseek, syswrite, unpack, vec
  • Functions for filehandles, files, or directories
    -X (see below), chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat, mkdir, open, opendir, readlink, rename, rmdir, select, stat, symlink, sysopen, umask, unlink, utime
  • Keywords related to the control flow of your Perl program
    break, caller, continue, die, do, dump, eval, evalbytes, exit, __FILE__, goto, last, __LINE__, next, __PACKAGE__, redo, return, sub, __SUB__, wantarray
  • Keywords related to scoping
    caller, import, local, my, our, package, state, use
  • Miscellaneous functions
    defined, formline, lock, prototype, reset, scalar, undef
  • Functions for processes and process groups
    alarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe, qx//, readpipe, setpgrp, setpriority, sleep, system, times, wait, waitpid
  • Keywords related to Perl modules
    do, import, no, package, require, use
  • Keywords related to classes and object-orientation
    bless, dbmclose, dbmopen, package, ref, tie, tied, untie, use
  • Low-level socket functions
    accept, bind, connect, getpeername, getsockname, getsockopt, listen, recv, send, setsockopt, shutdown, socket, socketpair
  • System V interprocess communication functions
    msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget, shmread, shmwrite
  • Fetching user and group info
    endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid, getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent
  • Fetching network info
    endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent, getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber, getprotoent, getservbyname, getservbyport, getservent, sethostent, setnetent, setprotoent, setservent
  • Time-related functions
    gmtime, localtime, time, times
  • Non-function keywords
    and, AUTOLOAD, BEGIN, CHECK, cmp, CORE, __DATA__, default, DESTROY, else, elseif, elsif, END, __END__, eq, for, foreach, ge, given, gt, if, INIT, le, lt, ne, not, or, UNITCHECK, unless, until, when, while, x, xor

-X are -r, -w, -x, -o, -R, -W, -X, -O, -e, -s, -z, -f, -d, -l, -p, -S, -b, -c, -t, -u, -g, -k, -T, -B, -M, -A, -C.

  • rules for string and number literals
"string with interpolated $variables\n", qq{more}, qq/and more/,
'without them', q{without}, q/them/, q^any symbol after q is OK^, q<but brackets must be paired>,
42, 3.1415926, 1e6, 16_777_216, 012 (octal), 0xFF and 0xff (hexadecimal)

Can a double quoted string contain a newline?

my $multiline = "Yes,
it can.";
  • rules for comments
# There is a comment
$var = 42; # life, the Universe, and everything

Does Language have a special syntax for multiline comments?

Yes, it have. See perlpod

  • a description of any unusual syntactic features (There's this weird %w() thing in Ruby...)

There is a lot of unusual syntax and Ruby got some of its features :-)

  1. Strings can be specified with Quote-Like Operators
  2. Lists can be specified as ('list', 'items') or as qw( words without quotation marks ),
  3. Regexps can be written as /regexp/ or as qr/regexp/. There are modifiers for regexps. See perlre
  4. Output of system command can be obtained as command or as qx(command)
  5. There are matching and translation operators s///, m//, tr///, y///

If there are different versions / implementations / dialects of this language: How do they differ?

Hmmm... There is Perl 5 and Perl 6. But I propose to use Perl 5 only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kissifrot@rwstauner@shoorick@korny

        Issue actions

          Perl support · Issue #33 · rubychan/coderay