On Oct 5, BERTHOLD Jean said:

The part I want to extract is only composed of characters in uppercase.

To be safe (in case there are other uppercase characters) you want to get uppercase characters between '_' and '-'.

   ( $ORACLE_SID ) = ( $basename =~ /[A-Z]*/ ) ; <-- I tried that but that 
won't work ...

The reason that fails is because the '*' quantifier means "match zero or more". Even the string "this has no capital letters in it" can be matched by the regex /[A-Z]*/. You want /([A-Z]+)/. The parentheses I've added tell Perl to capture what it matched with [A-Z]+ and return it; that's how we put something in $ORACLE_SID other than '1'.

  ($ORACLE_SID) = $basename =~ /_([A-Z]+)-/;

--
Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to