Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Stumped by regex

by syphilis (Archbishop)
on Nov 10, 2008 at 11:02 UTC ( [id://722622]=perlquestion: print w/replies, xml ) Need Help??

syphilis has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
The current Inline/C/Makefile.PL (http://search.cpan.org/src/INGY/Inline-0.44/C/Makefile.PL) begins with the following code:
use strict; use ExtUtils::MakeMaker; use Config; use File::Spec; my ($cc, $exe) = @Config{'cc', '_exe'}; $cc =~ s/\s+-.+$//; #remove possible trailing options my $found = 0; my $delim = $^O eq 'MSWin32' ? ';' : ':'; if ($cc =~ m|/:\[|) { $found = -f "$cc$exe"; } else { for my $lib (split $delim, $ENV{PATH}) { $found = -f File::Spec->catfile($lib,"$cc$exe") and last; } }
I have difficulty working out how $cc will ever match |/:\[| - can someone here provide some insight into the point of that test ?

Cheers,
Rob

Replies are listed 'Best First'.
Re: Stumped by regex
by JavaFan (Canon) on Nov 10, 2008 at 11:43 UTC
    Considering that $cc comes from %Config, it could technically contain anything. For instance, it may contain "/foo/bar/:[baz]". Now, while the latter is valid in most Unix file systems, it's highly unlikely to find a C compiler in such a path. Unlike VMS. A full path in VMS consists of a device name, a directory, a file name (including extension), and a version number. The device name and the directory are separated by a colon, while the directory itself is enclosed in square brackets. Which explains not only that $cc may match this, but also why this specific match was choosen.
      Thanks guys. Let's hope I don't ever have to get involved with VMS porting issues :-)

      Cheers,
      Rob
        VMS is actively supported by people on the p5p list. They might be willing to help you if you have a VMS concern.

        I personally believe that in case you do, then you will fully understand why modules like File::Spec exist, and how useful they are.

        --
        If you can't understand the incipit, then please check the IPB Campaign.
Re: Stumped by regex
by ikegami (Patriarch) on Nov 10, 2008 at 11:17 UTC
    I bet it's related to VMS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://722622]
Approved by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-24 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found