Skip to content

Commit afd641d

Browse files
committed
perl: use -e calls
1 parent 99cd93c commit afd641d

File tree

10 files changed

+31
-49
lines changed

10 files changed

+31
-49
lines changed

+stdlib/+perl/device.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function r = device(file)
22

3-
cwd = fileparts(fullfile(mfilename('fullpath')));
3+
cmd = sprintf('"%s" -e "print +(stat shift)[0]" "%s"', stdlib.perl_exe(), file);
44

5-
[r, s] = perl(cwd + "/device.pl", file);
5+
[s, r] = system(cmd);
66
if s == 0
77
r = str2double(r);
88
else

+stdlib/+perl/device.pl

Lines changed: 0 additions & 12 deletions
This file was deleted.

+stdlib/+perl/inode.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
function r = inode(file)
22

3-
cwd = fileparts(fullfile(mfilename('fullpath')));
3+
cmd = sprintf('"%s" -e "print +(stat shift)[1]" "%s"', stdlib.perl_exe(), file);
44

5-
[r, s] = perl(cwd + "/inode.pl", file);
5+
[s, r] = system(cmd);
66
if s == 0
77
r = str2double(r);
88
else

+stdlib/+perl/inode.pl

Lines changed: 0 additions & 12 deletions
This file was deleted.

+stdlib/+perl/samepath.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
function r = samepath(file1, file2)
22

3-
cwd = fileparts(fullfile(mfilename('fullpath')));
3+
cmd = sprintf('"%s" -e "(@ARGV==2) or exit 1; @s1 = stat shift or exit 1; @s2 = stat shift or exit 1; exit(($s1[0]==$s2[0] && $s1[1]==$s2[1]) ? 0 : 1)" "%s" "%s"', ...
4+
stdlib.perl_exe(), file1, file2);
5+
6+
s = system(cmd);
47

5-
[~, s] = perl([cwd filesep 'samepath.pl'], file1, file2);
68
r = s == 0;
79

810
end

+stdlib/+perl/samepath.pl

Lines changed: 0 additions & 15 deletions
This file was deleted.

+stdlib/perl_exe.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function exe = perl_exe()
2+
3+
persistent perle
4+
5+
if ~isempty(perle)
6+
exe = perle;
7+
return
8+
end
9+
10+
cwd = fileparts(mfilename("fullpath"));
11+
12+
[r, s] = perl(cwd + "/private/executable.pl");
13+
14+
if s == 0 && isfile(r)
15+
exe = r;
16+
perle = r;
17+
end
18+
19+
end

+stdlib/perl_version.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
return
1515
end
1616

17-
cwd = fileparts(fullfile(mfilename('fullpath')));
17+
cmd = sprintf('"%s" -e "print $^V"', stdlib.perl_exe());
1818

19-
[r, s] = perl([cwd filesep 'version.pl']);
19+
[s, r] = system(cmd);
2020

2121
if s == 0
22-
v = sscanf(r, 'v%d.%d.%d');
22+
v = sscanf(r, 'v%d.%d.%d').';
2323
else
2424
v = [];
2525
end

+stdlib/private/executable.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print $^X;

+stdlib/version.pl

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)