#!/usr/local/bin/perl -w

use strict;

sub g2r
{
  # my $re = $glob_pat;
  my $re = shift;
  local $_;
  for ($re) {
    s/\./\\./g;
    s/\*/.*/g;
    s/\?/./g;
    $_ = "\^$_\$";
    s/^\^\.\*//;
    s/\.\*\$$//;
  }
  return $re;
}

my @globs = qw(*.c foo.* *.* bar. biz.??? part??.shar);

foreach (@globs) {
  my $re = g2r($_);
  print "glob '$_' => re /$re/\n";
}

exit 0;
