File: pm_script_arg.pl

package info (click to toggle)
gap-polymaking 0.8.8-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: xml: 682; javascript: 155; makefile: 105; perl: 24; sh: 2
file content (36 lines) | stat: -rw-r--r-- 818 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This is a compatibility hack for polymake 4.1
# See https://polymake.org/doku.php/user_guide/tutorials/release/4.1/legacy
# Copyright Joachim Zobel <jz-2017@heute-morgen.de>.
# Licensed under the same license as GAP polymaking.

my $file = shift(@ARGV);

my $rtn = 0;
$rtn = 1 if $#ARGV > 1;

sub give_from {
  my ($c, $arg) = @_;
  no strict 'refs';
  return $c->$arg;
}

my $c=load($file);
my @rtn = ();
foreach my $arg (@ARGV) {
  my @sargs = split(/\b\s+\b/, $arg);
  $rtn = 1 if $#sargs > 1;
  foreach my $sarg (@sargs) {
    my @ssargs = split('->', $sarg);
    my $given = $c;
    # We follow the arrows
    foreach my $ssarg (@ssargs) {
      $given = give_from($given, $ssarg);
    }
    # and return what the last one gave us
    push(@rtn, "$sarg\n$given\n");
  }
}
print join("\n", @rtn);

return $rtn;