Perl on JVM Feature Matrix
May 13, 2026 ยท View on GitHub
Status Legend
- โ Fully implemented
- ๐ง Partially implemented
- ๐ก Implemented with limitations
- โ Not implemented
Table of Contents
- Compiler Usability
- Testing
- Autovivification
- Scalars
- Objects
- Operators
- Arrays, Hashes, and Lists
- Subroutines
- Regular Expressions
- Statements and Special Operators
- I/O Operations
- Namespaces and Global Variables
- Perl Modules, Pragmas, Features
- Features Incompatible with JVM
- Optimizations
Summary
PerlOnJava implements most core Perl features with some key differences:
โ Fully Supported:
- Core language features (variables, loops, conditionals, subroutines)
- Most operators and built-in functions
- Basic OOP with packages, inheritance, and method calls
- Regular expressions (most features)
- DBI with JDBC integration
- Subroutine prototypes
- Tied variables
- Method Resolution Order
๐ง Partially Supported:
- Warnings and strict pragma
- Some core modules and pragmas
- File operations and I/O
- Overload
formatoperator
โ Not Supported:
- XS modules and C integration
- Threading
Compiler Usability
- โ Wrapper scripts: (jperl/jperl.bat) for easier command-line usage.
- โ Perl-like compile-time error messages: Error messages mimic those in Perl for consistency.
- โ Perl line numbers in bytecode: Bytecode includes line numbers for better debugging.
- โ Perl-like runtime error messages: Runtime errors are formatted similarly to Perl's.
- โ Comments: Support for comments and POD (documentation) in code is implemented.
- โ
Environment: Support for
PERL5LIB,PERL5OPTenvironment variables. - ๐ง Perl-like warnings: Lexical warnings with FATAL support. Block-scoped warnings pending.
Perl Debugger
The built-in Perl debugger (perl -d) provides interactive debugging. See Debugger Reference for full documentation.
Execution Commands
| Command | Status | Description |
|---|---|---|
s | โ | Step into - execute one statement, entering subroutines |
n | โ | Next - execute one statement, stepping over subroutines |
r | โ | Return - execute until current subroutine returns |
c [line] | โ | Continue - run until breakpoint or specified line |
q | โ | Quit - exit the debugger |
Breakpoints
| Command | Status | Description |
|---|---|---|
b [line] | โ | Set breakpoint at line |
b file:line | โ | Set breakpoint at line in file |
B [line] | โ | Delete breakpoint |
B * | โ | Delete all breakpoints |
L | โ | List all breakpoints |
b line condition | โ | Conditional breakpoints |
Source and Stack
| Command | Status | Description |
|---|---|---|
l [range] | โ | List source code |
. | โ | Show current line |
T | โ | Stack trace |
w expr | โ | Watch expression |
a line command | โ | Set action at line |
Expression Evaluation
| Command | Status | Description |
|---|---|---|
p expr | โ | Print expression result |
x expr | โ | Dump expression with Data::Dumper |
Debug Variables
| Variable | Status | Description |
|---|---|---|
$DB::single | โ | Single-step mode flag |
$DB::trace | โ | Trace mode flag |
$DB::signal | โ | Signal flag |
$DB::filename | โ | Current filename |
$DB::line | โ | Current line number |
%DB::sub | โ | Subroutine locations (name โ file:start-end) |
@DB::args | โ | Current subroutine arguments |
Not Implemented
- โ
-d:Module- Custom debugger modules (e.g.,-d:NYTProf) - โ
perl5db.plcompatibility - โ
R- Restart program - โ History and command editing
Command Line Switches
-
โ Accept input program in several ways:
- Piped input:
echo 'print "Hello\n"' | ./jperl- reads from pipe and executes immediately - Interactive input:
./jperl- shows a prompt and waits for you to type code, then press Ctrl+D (on Unix/Linux/Mac) or Ctrl+Z (on Windows) to signal end of input - File redirection:
./jperl < script.pl- reads from the file - With arguments:
./jperl -e 'print "Hello\n"'or./jperl script.pl
- Piped input:
-
โ UTF-16 is accepted in source code.
-
โ Accept command line switches from the shebang line.
-
โ Accept command line switches:
-c,-e,-E,-p,-n,-i,-I,-0,-a,-d,-f,-F,-m,-M,-g,-l,-h,-s,-S,-x,-v,-V,-?,-w,-W,-Xare implemented. -
โ Missing command line switches include:
-T: Taint checks.-t: Taint checks with warnings.-u: Dumps core after compiling.-U: Allows unsafe operations.-D[number/list]: Sets debugging flags.-C [number/list]: Controls Unicode features.
Testing
- โ TAP tests: Running standard Perl testing protocol.
- โ CI/CD: Github testing pipeline in Ubuntu and Windows.
Autovivification
Distinguish between contexts where undefined references should automatically create data structures versus where they should throw errors.
When Autovivification Occurs:
- Lvalue contexts:
$arr->[0] = 'value',$hash->{key} = 'value' - Modifying operations:
push @{$undef}, 'item',pop @{$undef},shift @{$undef},unshift @{$undef}, 'item' - Element access:
$undef->[0],$undef->{key}(creates the container but not the element) - Operations that can modify through aliases:
grep { $_ = uc } @{$undef},map { $_ * 2 } @{$undef} - Foreach loops:
foreach (@{$undef}) { ... }
When Autovivification Does NOT Occur, and throws error in strict mode:
- Non-modifying operations:
sort @{$undef},reverse @{$undef} - Rvalue dereferencing:
my @list = @{$undef},my %hash = %{$undef} - Scalar context:
my $count = @{$undef}
Examples:
# These autovivify (create the data structure):
my $x;
$x->[0] = 'hello'; # $x becomes []
push @{$x}, 'world'; # works, autovivifies
my $y;
$y->{name} = 'Alice'; # $y becomes {}
$y->{age}++; # autovivifies element
# These throw "Can't use an undefined value as an ARRAY/HASH reference":
my $z;
my @sorted = sort @{$z}; # ERROR
my @reversed = reverse @{$z}; # ERROR
my @copy = @{$z}; # ERROR
Scalars
- โ
myvariable declaration: Local variables can be declared usingmy. - โ
ourvariable declaration: Global variables can be declared usingour. - โ
localvariable declaration: Dynamic variables are implemented. - โ
statevariable declaration: State variables are implemented. State variables are initialized only once. - โ
Declared references:
my \$x,my(\@arr),my(\%hash)are implemented. - โ Variable assignment: Basic variable assignment is implemented.
- โ Basic types: Integers, doubles, strings, v-strings, regex, CODE, undef, and references are supported.
- โ String Interpolation: Both array and scalar string interpolation are supported.
- โ
String Interpolation escapes: Handles escape sequences like
\n,\N{name},\Q,\E,\U,\L,\u,\lwithin interpolated strings. - โ String numification: Strings can be converted to numbers automatically.
- โ
Numbers with underscores: Numbers with underscores (e.g.,
1_000) are supported. - โ
Numbers in different bases: Numbers in binary, hex, octal:
0b1010,0xAA,078. - โ Infinity, -Infinity, NaN: Special number values are implemented.
- โ Hexadecimal floating point: Numbers like 0x1.999aP-4 are supported.
- โ References: References to variables and data structures are supported.
- โ Autovivification: Autovivification is implemented.
- โ File handles: Support for file handles is implemented.
- โ
localspecial cases:localis implemented for typeglobs and filehandles. - โ
Typeglob as hash:
*$val{$k}forSCALAR,ARRAY,HASH,CODE,IOis implemented. - โ Use string as a scalar reference: Support for scalar references from strings is implemented.
- โ Tied Scalars: Support for tying scalars to classes is implemented. See also Tied Arrays, Tied Hashes, Tied Handles.
- โ Taint checks: Support for taint checks is not implemented.
- โ
localspecial cases:local *HANDLE = *HANDLEdoesn't create a new typeglob. - ๐ง Variable attributes:
my $x : attrsupported viaMODIFY_SCALAR_ATTRIBUTESetc.
Objects
- โ Objects: Creating classes and method call syntax are implemented.
- โ
Object operators:
refandbless - โ
Special variables:
@ISAis implemented. - โ Multiple Inheritance: C3 method resolution is implemented.
- โ Method caching: Method resolution is cached.
- โ
Version check: Method
VERSION ( [ REQUIRE ] )is implemented. - โ
Inheritance:
SUPER::methodis implemented. - โ
Autoload:
AUTOLOADmechanism is implemented;$AUTOLOADvariable is implemented. - โ
class:classkeyword fully supported with blocks. - โ Indirect object syntax indirect object syntax is implemented.
- โ
:isa: Class inheritance with version checking is implemented. - โ
method: Method declarations with automatic$self. - โ
field: Field declarations with all sigils supported. - โ
:param: Constructor parameter fields fully working. - โ
:reader: Reader methods with context awareness. - โ
ADJUST:ADJUSTblocks with field transformation work. - โ
Constructor generation: Automatic
new()method creation. - โ
Field transformation: Fields become
$self->{field}in methods. - โ
Lexical method calls:
$self->&privsyntax is implemented. - โ Object stringification: Shows OBJECT not HASH properly.
- โ Field defaults: Default values for fields work.
- โ Field inheritance: Parent class fields are inherited.
- ๐ก
__CLASS__: Compile-time evaluation only, not runtime. - ๐ก Argument validation: Limited by operator implementation issues.
- โ
Moose / Class::MOP: Moose 2.4000 is bundled.
Upstream Moose tests pass ~99%; DBIx::Class (installed via
jcpan) passes 100%. See bundled modules. - โ
DESTROY: Destructor methods with selective reference counting.
Operators
Arithmetic and Comparison
- โ
Simple arithmetic: Operators like
+,-,*, and%are supported. - โ
Numeric Comparison operators: Comparison operators such as
==,!=,>,<, etc., are implemented. - โ
Chained operators: Operations like
$x < $y <= $zare implemented. - โ
defined-or:
//operator. - โ
low-precedence-xor:
^^and^^=operator.
String Operators
- โ
String concat: Concatenation of strings using
.is supported. - โ
String Comparison operators: String comparison operators such as
eq,ne,lt,gt, etc., are implemented. - โ
q,qq,qw,qxString operators: Various string quoting mechanisms are supported. - โ
Scalar string and math operators:
quotemeta,ref,undef,log,rand,oct,hex,ord,chr,int,sqrt,cos,sin,exp,atan2,lc,lcfirst,uc,ucfirst,chop,fc,index,rindex,prototype. - โ
join: Join operator for combining array elements into a string is supported. - โ
sprintf: String formatting is supported. - โ
substr: Substring extraction is implemented. - โ
Lvalue
substr: Assignable Substring extraction is implemented. - โ
chomp:chompis implemented.
Bitwise Operators
- โ
Bitwise operators: Bitwise operations like
~,&,|,^,~.,&.,|.,^.,<<, and>>are supported. - โ Bitwise operators: Bitwise integer and string operations are implemented.
- โ Bitwise operators return unsigned: Emulate unsigned integers.
- โ
Vectors:
vecis implemented. - โ
Lvalue
vec: Assignablevecis implemented.
List and Array Operators
- โ
grep,map,sort: List processing functions are implemented. - โ
packandunpackoperators:packandunpackare implemented.
Other Operators
- โ Autoincrement, Autodecrement; String increment: Increment and decrement operators, including for strings, are implemented.
- โ
Time-related functions:
time,times,gmtime,localtimeare implemented. - โ
cryptoperator:cryptis implemented. - โ
study,srand:study,srandare implemented. - โ
sleep:sleepis implemented. It takes fractional seconds. - โ
alarm:alarmis implemented with$SIG{ALRM}signal handling support. - โ
stat:stat,lstatare implemented. Some fields are not available in JVM and returnundef.
Arrays, Hashes, and Lists
- โ Array, Hash, and List infrastructure: Basic infrastructure for arrays, hashes, and lists is implemented.
- โ
List assignment: Supports list assignment like
($a, undef, @b) = @c. - โ
my LIST: Declaration of lists usingmyis supported. - โ
Autoquote before
=>: Autoquoting before=>is implemented. - โ Select an element from a list: Indexing into lists is supported.
- โ
List subscripts: like:
(stat($file))[8] - โ
Taking References of a List: like:
\(1,2,3) - โ List assignment in scalar context: List assignment in scalar context returns the number of elements produced by the expression on the right side of the assignment
- โ
$#array: Operator for array count is implemented. - โ
scalar: Operator to get scalar value is implemented. - โ
Array dereference: Dereferencing arrays using
@$x. - โ
Hash dereference: Dereferencing hashes using
%$x. - โ
**Dereference with var{...}
and$$var[...]` is implemented. - โ
Basic Array Operations:
push,unshift,pop,shift,splice,reverseare implemented. - โ
Slices: Array and Hash slices like
@array[2, 3],@hash{"a", "b"}and%hash{"a", "b"}are implemented. - โ Array literals: Array literals are supported.
- โ
Basic Hash Operations:
keys,values,delete,exists,eachare implemented. - โ Hash literals: Hash literals are supported.
- โ
List operator
..: List constructors are implemented. - โ
Flip-flop operator
..and...: The flip-flop operators are implemented. - โ
$#array: Lvalue array count is implemented:$#{$sl} = 10. - โ
Array exists:
existsfor array indexes is implemented. - โ
Array delete:
deletefor array indexes is implemented. - โ Tied Arrays: Tied arrays are implemented. See also Tied Scalars, Tied Hashes, Tied Handles.
- โ Tied Hashes: Tied hashes are implemented. See also Tied Scalars, Tied Arrays, Tied Handles.
- โ Restricted hashes:
Hash::Utillock/unlock functions (lock_keys,lock_hash, etc.) are not implemented.
Subroutines
- โ Subroutine hoisting: Invoking subroutines before their actual declaration in the code.
- โ Anonymous subroutines with closure variables: Anonymous subs and closures are supported.
- โ Return from inside a block: Return statements within blocks work correctly.
- โ Assigning to a closure variable mutates the variable in the original context: Closure variable mutation is implemented.
- โ
@_contains aliases to the caller variables: The@_array reflects caller arguments correctly. - โ Named subroutines: Support for named subroutines is implemented.
- โ
Calling context:
wantarrayis implemented. - โ
exists:
exists &subis implemented. - โ
defined:
defined &subis implemented. - โ
CORE namespace:
COREis implemented. - โ
CORE::GLOBAL namespace:
CORE::GLOBALand core function overrides are implemented. - โ
alternate subroutine call syntax:
&$sub,&$sub(args)syntax is implemented. - โ
Subroutine prototypes: Prototypes
$,@,%,&,;,_,+,*,\@,\%,\$,\[@%], empty string and undef are supported. - โ Subroutine signatures: Formal parameters are implemented.
- โ
lvaluesubroutines: Subroutines with attribute:lvalueare supported. - โ
Forcing main package: Identifiers starting with::are inmainpackage. - โ
Lexical subroutines: Subroutines declared
my,state, orourare supported. - ๐ง Subroutine attributes:
:lvalue,:prototype, and custom attributes viaMODIFY_CODE_ATTRIBUTES/FETCH_CODE_ATTRIBUTES. - โ
CORE operator references:
\&CORE::Xreturns callable CODE refs for built-in functions with correct prototypes:my $r = \&CORE::length; $r->("hello")
Regular Expressions
- โ
Basic Matching: Operators
qr//,m//,s///,splitare implemented. - โ
Regex modifiers: Modifiers
/p/i/m/s/n/g/c/r/e/ee/x/xxare implemented. - โ
Special variables: The special variables
$1,$2... are implemented. - โ
Transliteration:
trandytransliteration operators are implemented. - โ
pos:posoperator is implemented. - โ
\G:\Goperator in regex is implemented. - โ
\N{name}:\N{name}and\N{U+hex}operator for named characters in regex is implemented. - โ
\N: Not-newline operator. - โ
lvalue
pos: lvalueposoperator is implemented. - โ
m?pat?one-time match is implemented. - โ
resetresetting one-time match is implemented - โ
@-,@+,%+,%-,@{^CAPTURE},${^LAST_SUCCESSFUL_PATTERN}variables: regex special variables are implemented - โ
$&variables:$`,$&,$',$+special variables are implemented, and aliases:${^PREMATCH},${^MATCH},${^POSTMATCH}. - โ
[[:pattern:]]:[[:ascii:]],[[:print:]]are implemented. - โ
Matching plain strings:
$var =~ "Test"is implemented. - โ
Inline comments:
(?#comment)in regex is implemented. - โ
caret modifier:
(?^embedded pattern-match modifier, shorthand equivalent to "d-imnsx". - โ
\b inside character class:
[\b]is supported in regex. - โ \b{gcb} \B{gcb}: Boundary assertions.
- โ
Variable Interpolation in Regex: Features like
${var}for embedding variables. - โ
Non-capturing groups:
(?:...)is implemented. - โ
Named Capture Groups: Defining named capture groups using
(?<name>...)or(?'name'...)is supported. - โ
Backreferences to Named Groups: Using
\k<name>or\g{name}for backreferences to named groups is supported. - โ
Relative Backreferences: Using
\g{-n}for relative backreferences. - โ
Unicode Properties: Matching with
\p{...}and\P{...}(e.g.,\p{L}for letters). - โ Unicode Properties: Add regex properties supported by Perl but missing in Java regex.
- โ
Possessive Quantifiers: Quantifiers like
*+,++,?+, or{n,m}+, which disable backtracking, are not supported. - โ
Atomic Grouping: Use of
(?>...)for atomic groups is supported. - โ
\Kassertion: Keep left โ ins///, text before\Kis preserved; match variables reflect only the portion after\K. - โ
Preprocessor:
\Q,\L,\U,\l,\u,\Eare preprocessed in regex. - โ
Overloading:
qroverloading is implemented. See also overload pragma.
Missing Regular Expression Features
- โ Dynamically-scoped regex variables: Regex variables are not dynamically-scoped.
- โ Recursive Patterns: Features like
(?R),(?0)or(??{ code })for recursive matching are not supported. - โ Backtracking Control: Features like
(?>...),(?(DEFINE)...), or(?>.*)to prevent or control backtracking are not supported. - โ Lookbehind Assertions: Variable-length negative or positive lookbehind assertions, e.g.,
(?<=...)or(?<!...), are not supported. - โ Branch Reset Groups: Use of
(?|...)to reset group numbering across branches is not supported. - โ Advanced Subroutine Calls: Sub-pattern calls with numbered or named references like
(?1),(?&name)are not supported. - โ Conditional Expressions: Use of
(?(condition)yes|no)for conditional matching is not supported. - โ Extended Unicode Regex Features: Some extended Unicode regex functionalities are not supported.
- โ Extended Grapheme Clusters: Matching with
\Xfor extended grapheme clusters is not supported. - โ Embedded Code in Regex: Inline Perl code execution with
(?{ code })or(??{ code })is not supported. - โ Regex Debugging: Debugging patterns with
use re 'debug';to inspect regex engine operations is not supported. - โ Regex Optimizations: Using
use re 'eval';for runtime regex compilation is not supported. - โ Regex Compilation Flags: Setting default regex flags with
use re '/flags';is not supported. - โ Stricter named captures
- โ No underscore in named captures
(?<test_field>test)the name in named captures cannot have underscores. - โ No duplicate named capture groups: In Java regular expression engine, each named capturing group must have a unique name within a regular expression.
- โ No underscore in named captures
Statements and Special Operators
- โ Context void, scalar, list: Contexts for void, scalar, and list are supported.
- โ
if/else/elsifandunless: Conditional statements are implemented. - โ
3-argument
forloop: Theforloop with three arguments is supported. - โ
foreachloop: Theforeachloop is implemented. - โ
whileanduntilloop:whileanduntilloops are supported. - โ
ifunlessStatement modifiers: Conditional modifiers forifandunlessare implemented. - โ
whileuntilStatement modifiers: Loop modifiers forwhileanduntilare supported. - โ
whileuntilStatement modifiers:last,redo,nextgive an errorCan't "last" outside a loop block. - โ
forforeachStatement modifiers: Loop modifiers forforandforeachare implemented. - โ
continueblocks:continueblocks in looks are implemented. - โ
try/catchtry-catch is supported. - โ
evalstring with closure variables:evalin string context with closures is supported. - โ
evalstring sets$@on error; returnsundef:evalsets$@on error and returnsundef. - โ
evalblock:evalblocks are implemented. - โ
doblock:doblocks are supported. - โ
dofile: File execution usingdois implemented. - โ
do \&subroutine: is implemented. - โ
printoperators:print,printfandsaystatements are implemented, with support for file handles. - โ
printfandsprintf: String formatting is implemented. - โ Short-circuit and, or: Short-circuit logical operators are supported.
- โ
Low-precedence/high precedence operators: Logical operators like
not,or,and,xorare supported. - โ Ternary operator: The ternary conditional operator is implemented.
- โ Compound assignment operators: Compound assignment operators are implemented.
- โ
packagedeclaration:package BLOCKis also supported. - โ
Typeglob operations: Operations like
*x = sub {},*x = \@a,*x = *yare supported. - โ
Code references: Code references like
\&subr,\&$subname,\&{$subname}, are implemented. - โ
Special literals:
__PACKAGE__,__FILE__,__LINE__ - โ
die,warnoperators:die,warnare supported. - โ
dierelated features:$SIG{__DIE__},$SIG{__WARN__} - โ
diewith object:PROPAGATEmethod is supported. - โ
exit:exitis supported. - โ
kill:killis supported. - โ
waitpid:waitpidis partially supported. - โ
utime:utimeis supported. - โ
umask:umaskis supported. - โ
chown:chownis supported. - โ
readlink:readlinkis supported. - โ
link,symlink: link is supported. - โ
rename:renameis supported. - โ
requireoperator: Therequireoperator implemented; version checks are implemented. - โ
requireoperator:pmcfiles are supported. - โ
useandnostatements: Module imports and version check viauseandnoare implemented; version checks are implemented.usearguments are executed at compile-time. - โ
use version:use versionenables the corresponding features, strictures, and warnings. - โ
Import methods:
importandunimportare implemented. - โ
__SUB__: The__SUB__keyword is implemented. - โ
BEGINblock:BEGINspecial block is implemented. - โ
ENDblock:ENDspecial block is implemented. - โ
INIT: special block is implemented. - โ
CHECK: special block is implemented. - โ
UNITCHECK: special block is implemented. - โ Labels: Labels are implemented.
- โ Here-docs: Here-docs for multiline string literals are implemented.
- โ
Preprocessor:
# linedirective is implemented. - โ
glob:globoperator is implemented. - โ
<>:<>operator is implemented. - โ
<$fh>:<$fh>and<STDIN>operators are implemented. - โ
<ARGV>:ARGVand $ARGV are implemented. - โ
<*.*>:<*.*>glob operator is implemented. - โ
End of file markers: Source code control characters
^Dand^Z, and the tokens__END__and__DATA__are implemented. - โ Startup processing: processing
$sitelib/sitecustomize.plat startup is not enabled. - โ Smartmatch operator:
~~andgiven/whenconstruct are not implemented. - โ
File test operators:
-R,-W,-X,-O(for real uid/gid), this implementation assumes that the real user ID corresponds to the current user running the Java application. - โ
File test operators:
-t(tty check), this implementation assumes that the -t check is intended to determine if the program is running in a TTY-compatible environment. - โ
File test operators:
-p,-S,-b, and-care approximated using file names or paths, as Java doesn't provide direct equivalents. - โ
File test operators:
-k(sticky bit) is approximated using the "others execute" permission, as Java doesn't have a direct equivalent. - โ
File test operators:
-Tand-B(text/binary check) are implemented using a heuristic similar to Perl's approach. - โ
File test operators: Time-based operators (
-M,-A,-C) return the difference in days as a floating-point number. - โ
File test operators: Using
_as the argument reuses the last stat result. - โ File test operators: Support stacked file test operators.
- โ
Directory operators:
readdir,opendir,closedir,telldir,seekdir,rewinddir,mkdir,rmdir,chdir. - โ
forloop variable: Theforloop variable is aliased to list elements. - โ
forloop variable: Iterate over multiple values at a time is implemented. - โ
forloop variable: You can use fully qualified global variables as the variable in a for loop. - โ
loop control operators:
next LABEL,last LABEL,redo LABELwith literal labels are implemented, including non-local control flow (jumping from subroutines to caller's loops). - โ
gotooperator:goto LABELwith literal labels andgoto EXPRwith dynamic expressions are implemented. - โ
goto &name: Tail call optimization with trampoline is implemented. - โ
goto __SUB__: Recursive tail call is implemented. - โ
loop control operators:
next EXPR,last EXPR,redo EXPRwith dynamic expressions (e.g.,$label = "OUTER"; next $label) are implemented. - โ
setting
$_inwhileloop with<>: automatic setting$_inwhileloops is implemented. - โ
do BLOCK while:doexecutes once before the conditional is evaluated. - โ
...ellipsis statement:...is supported. - โ
systemoperator:systemis implemented. - โ
execoperator:execis implemented. - โ
User/Group operators, Network info operators:
getlogin,getpwnam,getpwuid,getgrnam,getgrgid,getpwent,getgrent,setpwent,setgrent,endpwent,endgrent,gethostbyname,gethostbyaddr,getservbyname,getservbyport,getprotobyname,getprotobynumber. - โ
Network enumeration operators:
endhostent,endnetent,endprotoent,endservent,gethostent,getnetbyaddr,getnetbyname,getnetent,getprotoent,getservent,sethostent,setnetent,setprotoent,setservent. - โ
System V IPC operators:
msgctl,msgget,msgrcv,msgsnd,semctl,semget,semop,shmctl,shmget,shmread,shmwrite. - โ
formatoperator:formatandwritefunctions for report generation are implemented. - โ
formlineoperator:formlineand$^Aaccumulator variable are implemented.
I/O Operations
Basic I/O Operators
-
โ
open: File opening is implemented with support for:- 2-argument forms:
<-,-,>-,filename - 3-argument forms with explicit modes
- In-memory files
- support for pipe input and output like:
-|,|-,ls|,|sort.-
forking patterns with
my pid) {...} else { exec @cmd } my pid) { exec @cmd } ... open FH, "-|" or exec @cmd;exec:
-
- โ
file descriptor duplication modes:
<&,>&,<&=,>&=(duplicate existing file descriptors)
- 2-argument forms:
-
โ
readline: Reading lines from filehandles- โ Paragraph mode ($/ = '' - empty string)
- โ Record length mode (/ = $foo where $foo is a number)
- โ Slurp mode ($/ = undef)
- โ Multi-character string separators ($/ = "34")
-
โ
sysopen: File opening. -
โ
eof: End-of-file detection -
โ
close: Closing filehandles -
โ
unlink: File deletion -
โ
readpipe: Command output capture -
โ
fileno: File descriptor retrieval -
โ
getc: Character reading -
โ
read: Block reading with length specification -
โ
tell: Current file position -
โ
select:select(filehandle)for default output selection -
โ
select:select(undef,undef,undef,$time)for sleep function -
โ
seek: File position manipulation. -
โ
chmod: File permissions. -
โ
sysread -
โ
syswrite -
โ Tied Handles: Tied file handles are implemented. See also Tied Scalars, Tied Arrays, Tied Hashes.
-
โ
DATA:DATAfile handle is implemented. -
โ
truncate: File truncation -
โ
flock: File locking with LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB -
โ
fcntl: File control operations (stub + native via jnr-posix) -
โ
ioctl: Device control operations (stub + native via jnr-posix) -
โ
syscall: System calls (SYS_gethostname)
Socket Operations
-
โ
socket: Socket creation with domain, type, and protocol support -
โ
bind: Socket binding to addresses -
โ
listen: Socket listening for connections -
โ
accept: Connection acceptance -
โ
connect: Socket connection establishment -
โ
send: Data transmission over sockets -
โ
recv: Data reception from sockets -
โ
shutdown: Socket shutdown -
โ
setsockopt: Socket option configuration -
โ
getsockopt: Socket option retrieval -
โ
getsockname: Local socket address retrieval -
โ
getpeername: Remote socket address retrieval -
โ
socketpair: Connected socket pair creation -
โ
pipe: Internal pipe creation for inter-process communication
Unimplemented I/O Operators
I/O Layers
- โ
Layer support:
openandbinmodesupport these I/O layers::raw- Binary mode, no translation:bytes- Similar to :raw, ensures byte semantics:crlf- Convert CRLF to LF on input, LF to CRLF on output:utf8- UTF-8 encoding/decoding:unix- Unix-style line endings (LF only):encoding(ENCODING)- Specific character encoding
- โ
Layer stacking: Multiple layers can be combined (e.g.,
:raw:utf8) - โ Multibyte encoding support for
seek,tell,truncate: These operations are not yet implemented for multibyte encodings.
Supported Encodings
The :encoding() layer supports all encodings provided by Java's Charset.forName() method:
Standard Charsets (guaranteed available):
US-ASCII- Seven-bit ASCIIISO-8859-1- ISO Latin Alphabet No. 1 (Latin-1)UTF-8- Eight-bit UCS Transformation FormatUTF-16BE- Sixteen-bit UCS, big-endian byte orderUTF-16LE- Sixteen-bit UCS, little-endian byte orderUTF-16- Sixteen-bit UCS with optional byte-order mark
Common Extended Charsets (usually available):
windows-1252- Windows Western EuropeanISO-8859-2throughISO-8859-16- Various ISO Latin alphabetsShift_JIS- JapaneseEUC-JP- JapaneseGB2312,GBK,GB18030- ChineseBig5- Traditional ChineseEUC-KR- Koreanwindows-1251- Windows CyrillicKOI8-R- Russian
Namespaces and Global Variables
- โ Global variable infrastructure: Support for global variables is implemented.
- โ Namespaces: Namespace support is implemented.
- โ
Stash: Stash can be accessed as a hash, like:
$namespace::{entry}. - โ
@_and$@special variables: Special variables like@_and$@are supported. - โ
Special variables: The special variables
%ENV,@ARGV,@INC,$0,$_,$.,$],$",$\\,$,,$/,$$,$a,$b,$^O,$^V,$^Xare implemented. - โ
I/O symbols:
STDOUT,STDERR,STDIN,ARGV,ARGVOUTare implemented. - โ
Stash manipulation: Alternative ways to create constants like:
$constant::{_CAN_PCS} = \$const. - โ
reset("A-Z")resetting global variables is implemented. - โ
Single-quote as package separator: Legacy
$a'bstyle package separator is supported. - โ Thread-safe
@_,$_, and regex variables: Thread safety for global special variables is missing. - โ Compiler flags: The special variables
$^H,%^H,${^WARNING_BITS}are not implemented. - โ
calleroperator:callerreturns($package, $filename, $line).- โ Extended call stack information: extra debug information like
(caller($level))[9]is not implemented.
This means we don't include subroutine names in error messages yet.
Extra debug information:($package, $filename, $line, $subroutine, $hasargs, $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash)
- โ Extended call stack information: extra debug information like
Perl Modules, Pragmas, Features
-
โ No direct Perl-to-Java interoperability: PerlOnJava does not provide Perl-side mechanisms like
Inline::Javafor directly calling Java methods or instantiating Java objects from Perl code. You cannot write Perl code that directly accesses arbitrary Java libraries or JVM languages. -
โ Java-implemented Perl modules via XSLoader: However, Perl modules can load Java-implemented subroutines using the standard
XSLoadermechanism. This allows you to:- Write Perl module implementations in Java that expose a Perl API
- Use PerlOnJava's internal API to create Java classes that register themselves as Perl subroutines
- Load these Java implementations transparently from Perl code using
XSLoader
Example: The DBI module demonstrates this pattern:
DBI.pm- Standard Perl module that usesXSLoader::load('DBI')DBI.java- Java implementation that registers methods likeconnect,prepare,executeas Perl subroutines- From Perl's perspective, it's using a normal XS module, but the implementation is actually Java code
See XS Compatibility for a complete list of modules with Java implementations.
Pragmas
- ๐ง strict pragma:.
- โ
all
use strictmodes are implemented. - โ
no strict vars,no strict subsare implemented. - ๐ง
no strict refsis partially implemented: scalar, glob references. - โ
no strict refsworks with global variables only.myvariables can not be accessed by name.
- โ
all
- โ parent pragma
- โ base pragma
- โ constant pragma
- โ experimental pragma
- โ if pragma
- โ lib pragma
- โ mro (Method Resolution Order) pragma
- โ vars pragma
- โ version pragma
- โ subs pragma
- ๐ง utf8 pragma: utf8 is always on. Disabling utf8 might work in a future version.
- ๐ง bytes pragma
- ๐ง feature pragma
- โ
Features implemented:
fc,say,current_sub,isa,state,try,defer,bitwise,postderef,evalbytes,module_true,signatures,class,keyword_all,keyword_any. - โ Features missing:
postderef_qq,unicode_eval,unicode_strings,refaliasing.
- โ
Features implemented:
- ๐ง warnings pragma
- ๐ง attributes pragma:
MODIFY_*_ATTRIBUTES/FETCH_*_ATTRIBUTEScallbacks for subroutines and variables. - โ bignum, bigint, and bigrat pragmas
- โ encoding pragma
- โ integer pragma
- โ locale pragma
- โ ops pragma
- ๐ง re pragma for regular expression options: Implemented
is_regexp. - ๐ง vmsish pragma.
- โ subs pragma.
- ๐ง builtin pragma:
- โ
Implemented:
truefalseis_boolinfnanweakenunweakenis_weakblessedrefaddrreftypecreated_as_stringcreated_as_numberstringifyceilfloorindexedtrimis_tainted. - โ Missing:
export_lexically,load_module
- โ
Implemented:
- ๐ง overload pragma:
- โ
Implemented:
"",0+,bool,fallback,nomethod. - โ
Implemented:
!,+,-,*,/,%,int,neg,log,sqrt,cos,sin,exp,abs,atan2,**. - โ
Implemented:
@{},%{},${},&{},*{}. - โ
Implemented:
<=>,cmp,<,<=,>,>=,==,!=,lt,le,gt,ge,eq,ne. - โ
Implemented:
qr. - โ
Implemented:
+=,-=,*=,/=,%=. - โ
Implemented:
<>. - โ Missing:
++,--,=. - โ Missing:
&,|,^,~,<<,>>,&.,|.,^.,~.,x,.. - โ Missing:
**=,<<=,>>=,x=,.=,&=,|=,^=,&.=,|.=,^.=. - โ Missing:
-X. - โ Missing:
=copy constructor for mutators.
- โ
Implemented:
- โ overloading pragma
Core modules
- โ Benchmark use the same version as Perl.
- โ
Carp:
carp,cluck,croak,confess,longmess,shortmessare implemented. - โ Config module.
- โ Cwd module
- โ Data::Dumper: use the same version as Perl.
- โ DirHandle module.
- โ Dumpvalue module.
- โ Digest module
- โ Digest::MD5 module
- โ Digest::SHA module
- โ Encode module.
- โ Env module
- โ Errno module.
- โ
Exporter:
@EXPORT_OK,@EXPORT,%EXPORT_TAGSare implemented.- โ Missing: export
*glob.
- โ Missing: export
- โ ExtUtils::MakeMaker module: PerlOnJava version installs pure Perl modules directly.
- โ Fcntl module
- โ FileHandle module
- โ
Filter::Simple module:
FILTERandFILTER_ONLYfor source code filtering. - โ File::Basename use the same version as Perl.
- โ File::Find use the same version as Perl.
- โ File::Spec::Functions module.
- โ File::Spec module.
- โ Getopt::Long module.
- โ HTTP::Date module.
- โ
Internals:
Internals::SvREADONLYis implemented as a no-op. - โ IO::File module.
- โ IO::Seekable module.
- โ IO::Socket module.
- โ IO::Socket::INET module.
- โ IO::Socket::UNIX module.
- โ IO::Zlib module.
- โ List::Util: module.
- โ MIME::Base64 module
- โ MIME::QuotedPrint module
- โ Perl::OSType module.
- โ
Scalar::Util:
blessed,reftype,set_prototype,dualvarare implemented. - โ SelectSaver: module.
- โ
Storable: module. Reads and writes the native Perl Storable binary format (
pst0magic), interoperable with system perl in both directions: jperl-written files are readable by system perl and vice versa.$Storable::canonical,SX_REGEXP/SX_VSTRINGencoding, and fullSTORABLE_freezehook emission are not yet implemented (seedev/modules/storable_binary_format.md). - โ Sys::Hostname module.
- โ
Symbol:
gensym,qualifyandqualify_to_refare implemented. - โ Term::ANSIColor module.
- โ Test module.
- โ Test::More module.
- โ Text::Balanced use the same version as Perl.
- โ Tie::Array module.
- โ Tie::Handle module.
- โ Tie::Hash module.
- โ Tie::Scalar module.
- โ Time::HiRes module.
- โ Time::Local module.
- โ
UNIVERSAL:
isa,can,DOES,VERSIONare implemented.isaoperator is implemented. - โ URI::Escape module.
- โ
Socket module: socket constants and functions (
pack_sockaddr_in,unpack_sockaddr_in,sockaddr_in,inet_aton,inet_ntoa,gethostbyname). - โ Unicode::UCD module.
- โ XSLoader module.
- ๐ง DynaLoader placeholder module.
- ๐ง HTTP::Tiny some features untested: proxy settings.
- ๐ง POSIX module.
- ๐ง Unicode::Normalize
normalize,NFC,NFD,NFKC,NFKD. - โ Archive::Tar module.
- โ Archive::Zip module.
- โ IPC::Open2 module.
- โ IPC::Open3 module.
- โ Net::FTP module.
- โ Net::Cmd module.
- โ Safe module.
Non-core modules
- โ HTTP::CookieJar module.
- โ JSON module.
- โ
Cpanel::JSON::XS module (JSON::PP-backed shim; same bundled encoder/decoder stack as
JSON). - โ Text::CSV module.
- โ TOML module.
- โ XML::Parser module backed by JDK SAX (replaces native libexpat XS).
- โ YAML::PP module.
- โ YAML module.
- โ
IO::Socket::SSL module backed by Java
javax.net.sslSSLEngine. - โ Net::SSLeay module backed by Java security APIs (2327 CPAN tests pass).
- โ Plack::Handler::Netty PSGI web server with HTTP/HTTPS, streaming, 32k+ req/sec. See Web Server Guide.
DBI module
JDBC Integration
The DBI module provides seamless integration with JDBC drivers:
- Configure JDBC drivers: See Adding JDBC Drivers
- Connect to databases: See Database Connection Examples
Implemented Methods
connect,prepare,executefetchrow_arrayref,fetchrow_array,fetchrow_hashref,selectrow_array,selectrow_arrayref,selectrow_hashreffetchall_arrayref,selectall_arrayref,fetchall_hashref,selectall_hashrefrows,disconnect,err,errstr,state,do,finish,last_insert_idbegin_work,commit,rollbackbind_param,bind_param_inout,bind_col,bind_columnstable_info,column_info,primary_key_info,foreign_key_info,type_infoclone,ping,trace,trace_msgavailable_drivers,data_sources,get_infoprepare_cached,connect_cached
Database Handle Attributes
RaiseError,PrintError,Username,Password,Name,Active,Type,ReadOnly,Executed,AutoCommit
Statement Handle Attributes
NAME,NAME_lc,NAME_uc,NUM_OF_FIELDS,NUM_OF_PARAMS,Database
Features Incompatible with JVM
- โ
forkoperator:forkis not implemented. Callingforkwill always fail and returnundef. - โ
DESTROY: Implemented with selective reference counting on top of JVM GC. Supports cascading destruction, closure capture tracking,weaken/isweak/unweaken, global destruction phase, andInternals::SvREFCNTintrospection. - โ Perl
XScode: XS code interfacing with C is not supported on the JVM. - โ Auto-close files: File auto-close depends on handling of object destruction, may be incompatible with JVM garbage collection. All files are closed before the program ends.
- โ Keywords related to the control flow of the Perl program:
dumpoperator. - โ DBM file support:
dbmclose,dbmopenare not implemented. - โ Calling a class name
package Test; Test->()givesUndefined subroutine &Test::Test called.
Optimizations
- โ Cached string/numeric conversions: Numification caching is implemented.
- โ Java segment size limitation: A workaround is implemented to Java 64k bytes segment limit.
- โ Inline "constant" subroutines optimization: Optimization for inline constants is not yet implemented.
- โ Overload optimization: Preprocessing in overload should be cached.
- โ I/O optimization: Use low-level readline to optimize input.
- โ I/O optimization: Extract I/O buffering code (StandardIO.java) into a new layer, and add it at the top before other layers.