#  Copyright (c) 1997-2006
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
#  http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-----------------------------------------------------------------------------
#  $Project: polymake $$Id: make2perl.pl,v 1.2 2006/02/23 11:26:56 gawrilow Exp $

sub make2perl {
   my ($pattern)=@_;
   $pattern =~ s/^\s+//;
   $pattern =~ s/\s+$//;
   $pattern =~ s/\./\\./g;
   $pattern =~ s/%/.*/g;
   return join('|', map { "(?:$_)" } split /\s+/, $pattern);
}

sub make2perl_filename {
   return '^' . &make2perl . '$';
}

sub process_dot_export {
   my ($srcdir)=@_;
   open X, "$srcdir/.export" or return undef;
   local $/; $_=<X>; close X;
   s/\\\n/ /sg;
   foreach my $line (split /\n/, $_) {
      (my ($var_name,$value) = $line =~ /^\s* (\w+) \s* :?= \s* (.*) $/x)==2 or next;
      $value =~ s/\$[({] (\w+) [})]/$make_vars{$1}/gx;
      $make_vars{$var_name}=$value;
   }
}

1
