GitHub - SiliconEngine/PerlToPHP: Perl to PHP code converter/translator
@a = ( 'a', 'b' );
$a = [ 'a', 'b' ];
$a = [ 'a', 'b' ];$a = [ ];$a = [];
$a = [ 'a', 'b' ];$a = [ ];$a = [];
@a = (1 + 2, 3);
$a = [1 + 2, 3];
@a = (1, 2, (3 + 4));
$a = [1, 2, (3 + 4)];
$a = [ (1, 2, (3 + 4)) ];
$a = /*check*/array_merge( [1, 2, (3 + 4)] );
$a = (1, 2, 3);
$a = (1, 2, 3);
$a = [1, 2, (3 + 4) ];
$a = [1, 2, (3 + 4) ];
$a = [@a, @b];
$a = /*check*/array_merge($a, $b);
($a, $b, $c) = (1, 2, 3);
list($a, $b, $c) = [1, 2, 3];
sub func{my ($a, $b, $c) = (1, 2, 3);}
function func(){list($a, $b, $c) = [1, 2, 3];}
foreach $a (@b) {print $a;}
foreach ($b as $a) {print $a;}
$a = $b if ($a == 1);
if ($a == 1) {$a = $b;}
if ($a or $b) {print;}
if ($a || $b) {print;}
if ($x =~ /\s+/) {print;}
if (preg_match('/\s+/', $x)) {print;}
$x =~ s/\s+/abc/;$x =~ s/\s+/ abc /;$x =~ s/ def / abc /;
$x = preg_replace('/\s+/', 'abc', $x);$x = preg_replace('/\s+/', ' abc ', $x);$x = preg_replace('/ def /', ' abc ', $x);
if ($x !~ /\s+/) {print;}
if (! (preg_match('/\s+/', $x))) {print;}
if ($name eq 'Test' and $agency->{Test} !~ /^\/LINK/) {}$z = $agency->{Test} !~ /^\/LINK/;$z = $b + $agency->{Test} =~ /^\/LINK/;
if ($name === 'Test' && ! (preg_match('/^\/LINK/', $agency['Test']))) {}$z = ! (preg_match('/^\/LINK/', $agency['Test']));$z = $b + preg_match('/^\/LINK/', $agency['Test']);
sub func{my ($a, $b, $with_under, $camelCase) = @_; print;} sub func_new{my $x = func(@_);} sub func_new_two{my ($x, $y) = func_new(@_);}
function func($a, $b, $withUnder, $camelCase){print;} function funcNew(){$x = func($fake/*check:@*/);} function funcNewTwo(){list($x, $y) = funcNew($fake/*check:@*/);}
sub func{my $a = shift;print;}
function func($a){print;}
$s = ' ' x $b;
$s = str_repeat(' ', $b);
$a = 'b'; # test
$a = 'b'; // test
local $a = 'b';
$a = 'b';
$a = qq|testtest|;
$a = <<<EOT testtestEOT;
$a = qw(a def c);$a = qw( a def c );$a = qw/ a def c /;$a = qw( a def cd e f );
$a = [ 'a', 'def', 'c' ];$a = [ 'a', 'def', 'c' ];$a = [ 'a', 'def', 'c' ];$a = [ 'a', 'def', 'c', 'd', 'e', 'f' ];
$a = lc $b;$a = lc @$b;$a = lc($b);
$a = strtolower($b);$a = strtolower($b);$a = strtolower($b);
$a = defined $test_var;$a = $b[defined $c];$a = defined $var{stuff1}{stuff2};$a = defined $var[10][20];
$a = /*check*/isset($testVar);$a = $b[/*check*/isset($c)];$a = /*check*/isset($var['stuff1']['stuff2']);$a = /*check*/isset($var[10][20]);
@a = sort @b;@a = sort(@b);@a = sort @a, @b;
$a = $fake/*check:sort($b)*/;$a = $fake/*check:sort($b)*/;$a = $fake/*check:sort($a, $b)*/;
$a = func(shift);$b = shift;
$a = func($fake/*check:shift*/);$b = $fake/*check:shift*/;
if ($a < $b) {print;} elsif ($c < $d) {print;}
if ($a < $b) {print;} elseif ($c < $d) {print;}
@x = split(':', $b . $c);
$x = explode(':', $b . $c);
use Foo::Bar;
use Foo\Bar;
goto EXIT;print;EXIT:print;
goto EXIT_LABEL;print;EXIT_LABEL:print;
if (-e ($a . $b . '.def')) {print;}
if (file_exists(($a . $b . '.def'))) {print;}
return 1;return (1);return (1, 2);
return 1;return (1);return [1, 2];
unless ($a = $b) {print;}
if (! ($a = $b)) {print;}
sub func{my $a;if ($a == $b) {print;} my (@c, @d);my @list;}
function func(){$a = null;if ($a == $b) {print;} $c = [];$d = [];$list = [];}
$a = Package::Stuff::new('abc');
$a = new Package\Stuff('abc');
print;1;
print;
$var = @$list;$var = @$with_underscore;$var = @{$list};$var = $#list;$var = $#{$list};$var = @list_var;$var = func((@list_var + 1) / 2);if (@$var) {print;}
$var = count($list);$var = count($withUnderscore);$var = count($list);$var = (count($list)-1);$var = (count($list)-1);$var = count($listVar);$var = func((count($listVar) + 1) / 2);if (count($var)) {print;}
@ISA = [ 'Exporter' ];@EXPORT = [ 'TestFile' ];
//@ISA = [ 'Exporter' ];//@EXPORT = [ 'TestFile' ];
@a = @$b;@a = @{$b};@a = @{['a', 'b', 'c']};
$a = $b;$a = $b;$a = (['a', 'b', 'c']);
func(\@b, 2);$a = \@b;$a = \%b;
func(/*check:\*/$b, 2);$a = /*check:\*/$b;$a = /*check:\*/$b;
no warnings qw(uninitialized);use warnings qw(uninitialized);
//no warnings qw(uninitialized);//use warnings qw(uninitialized);
$a = $b{hash};$a = $b{'hash'};$a = $b->{hash};$a = $b->{'hash'};$a = ($b->{'hash'} + $b{hash});
$a = $b['hash'];$a = $b['hash'];$a = $b['hash'];$a = $b['hash'];$a = ($b['hash'] + $b['hash']);
$a = $b[ $c->function ];
$a = $b[ $c->function ];
$var = uc func($a[$rq->{test}]);$var = uc func($a[$rq->{test}])[10]{'abc'};
$var = strtoupper(func($a[$rq['test']]));$var = strtoupper(func($a[$rq['test']])[10]{'abc'});
for ($i = 0; $i < 1; ++$i) {next;}for ($i = 0; $i < 1; ++$i) {next LABEL;}for ($i = 0; $i < 1; ++$i) {next if ($a == $b);}
for ($i = 0; $i < 1; ++$i) {continue;}for ($i = 0; $i < 1; ++$i) {continue /*check:LABEL*/;}for ($i = 0; $i < 1; ++$i) {if ($a == $b) {continue;}}
chop $z;chop($z);chop($b = $z);chop($b = $z + 3 * 10);chomp $z;chomp($z);chomp($b = $z);chomp($b = $z + 3 * 10);
$z = /*check:chop*/substr($z, 0, -1);$z = /*check:chop*/substr($z, 0, -1);$b = /*check:chop*/substr($b = $z, 0, -1);$b = /*check:chop*/substr($b = $z + 3 * 10, 0, -1);$z = /*check:chomp*/preg_replace('/\n$/', '', $z);$z = /*check:chomp*/preg_replace('/\n$/', '', $z);$b = /*check:chomp*/preg_replace('/\n$/', '', $b = $z);$b = /*check:chomp*/preg_replace('/\n$/', '', $b = $z + 3 * 10);
return ();return ( );
return [];return [ ];
func(1, 2, 3, );
func(1, 2, 3 );
%o = %{$match->{key}};%o = %$match;
$o = /*check:%*/$match['key'];$o = /*check:%*/$match;
@a = grep { @_ ne '' } @list;@a = grep { @_ ne ''; } @list;$a = join(' ', grep { @_ ne '' } @list);$a = join(' ', grep { @_ ne ''; } @{$abc->{def}});
$a = array_filter($list, function ($fake) { $fake/*check:@*/ !== ''; });$a = array_filter($list, function ($fake) { $fake/*check:@*/ !== ''; });$a = join(' ', array_filter($list, function ($fake) { $fake/*check:@*/ !== ''; }));$a = join(' ', array_filter($abc['def'], function ($fake) { $fake/*check:@*/ !== ''; }));
$a = 10 .. 30;$a = 4 + 5 .. 6 + 7;foreach my $rule_type (100..105) {}
$a = range(10, 30);$a = range(4 + 5, 6 + 7);foreach (/*check*/range(100, 105) as $ruleType) {}
$a = func($a, $b, ($c, $d));$a = func($a, $b, ($c+ $d));@a = ($a, $b, ($c, $d));
$a = func($a, $b, $c, $d);$a = func($a, $b, ($c+ $d));$a = [$a, $b, $c, $d];
@a = (@b, $c);foreach $b (@b, $c) {print;}
$a = array_merge($b, $c);foreach (array_merge($b, $c) as $b) {print;}
$ABC = 10;$abc_def = 10;$a = func_name(10);$a = FuncName(10);$a = FUNCNAME(10);$a = _def(10);$a = $_def;
$ABC = 10;$abcDef = 10;$a = funcName(10);$a = funcName(10);$a = FUNCNAME(10);$a = _def(10);$a = $_def;
&$a(1, 2);&{$b->{func}}(1, 2);
/*check:&*/$a(1, 2);/*check:&*/$b['func'](1, 2);
$a = [ @b ];$a = [ @b, @c ];$a = [ @b, 2 ];$a = shift @b;$a = func(shift(@b));$a = func(shift @b);$a = @a;$a = 0 + @a; # This is wrong, but hard to fix. Make sure it's markedfunc(@a, 2, 4);
$a = /*check*/array_merge( $b );$a = /*check*/array_merge( $b, $c );$a = /*check*/array_merge( $b, 2 );$a = array_shift($b);$a = func(array_shift($b));$a = func(array_shift($b));$a = count($a);$a = 0 + count($a); // This is wrong, but hard to fix. Make sure it's markedfunc(/*check*/count($a), 2, 4);