----- Original Message ----- MIME-Version: 1.0

Content-Type: multipart/alternative;

boundary="----_=_NextPart_001_01C5C99A.9531A0CC"

Subject: RE: Extracting Upper case letter from a variable

Date: Wed, 5 Oct 2005 12:50:21 +0200

Message-ID: <[EMAIL PROTECTED]>

From: "BERTHOLD Jean" <[EMAIL PROTECTED]>

To: "Muthukumar" <[EMAIL PROTECTED]>

Cc: <beginners@perl.org>

------_=_NextPart_001_01C5C99A.9531A0CC

Content-Type: text/plain;

charset="iso-8859-1"

Content-Transfer-Encoding: quoted-printable

Hello Muthukumar,

=20

My problem is that I would like to extract a part of a variable (which =

is a filename stored in this variable.

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

For example if I have this file list:

=20

-rw-r--r-- 1 oracle dba 13659 Oct 5 01:04 =

rman_APPEOS-archivelog-05-10-05-0100.log

-rw-r--r-- 1 oracle dba 12778 Oct 5 01:49 =

rman_NDOS-archivelog-05-10-05-0145.log

-rw-r--r-- 1 oracle dba 26231 Oct 5 01:55 =

rman_CAREOFFICE-archivelog-05-10-05-0130.log

-rw-r--r-- 1 oracle dba 14429 Oct 5 02:07 =

rman_IXOS-archivelog-05-10-05-0200.log

-rw-r--r-- 1 oracle dba 3985 Oct 5 02:32 =

rman_TEST-archivelog-05-10-05-0230.log

-rw-r--r-- 1 oracle dba 16788 Oct 5 03:06 =

rman_ORAMGT-archivelog-05-10-05-0300.log

-rw-r--r-- 1 oracle dba 1991 Oct 5 03:32 =

rman_DIVERS-archivelog-05-10-05-0330.lo

=20

=20

For each file i want only the uppercase part. Like "APPEOS", "NDOS", =

"CAREOFFICE"...

Then I want to store this part in a variable.

=20

Below is my script:

---------------------------

my @SOURCE_FILES =3D glob "/u01/oracle/local/logs/*.log" ;

...

foreach ( @SOURCE_FILES )

{

if ( -M $_ < 1 )

{

my $name =3D $_ ;

my $basename =3D basename $name ;

my $ORACLE_SID =3D "" ;

( $ORACLE_SID ) =3D ( $basename =3D~ /[A-Z]*/ ) ; <-- I tried that =

but that won't work ...

#print "Nom du fichier: $_\n" ;

print "Nom du fichier: $basename\n" ;

print "Instance Oracle: $ORACLE_SID\n" ;

}

}

This code should do what you want

#! perl
use warnings;
use strict;

my @CAPWORDS;
while (<DATA>)
{
 chomp;
 my (@fields) = split '_', $_;
 $fields[1] =~ /^([A-Z]+)-/;
 push @CAPWORDS, $1;
}

print "@CAPWORDS\n";


__DATA__
-rw-r--r-- 1 oracle dba 13659 Oct 5 01:04 = rman_APPEOS-archivelog-05-10-05-0100.log -rw-r--r-- 1 oracle dba 12778 Oct 5 01:49 = rman_NDOS-archivelog-05-10-05-0145.log -rw-r--r-- 1 oracle dba 26231 Oct 5 01:55 = rman_CAREOFFICE-archivelog-05-10-05-0130.log -rw-r--r-- 1 oracle dba 14429 Oct 5 02:07 = rman_IXOS-archivelog-05-10-05-0200.log -rw-r--r-- 1 oracle dba 3985 Oct 5 02:32 = rman_TEST-archivelog-05-10-05-0230.log -rw-r--r-- 1 oracle dba 16788 Oct 5 03:06 = rman_ORAMGT-archivelog-05-10-05-0300.log -rw-r--r-- 1 oracle dba 1991 Oct 5 03:32 = rman_DIVERS-archivelog-05-10-05-0330.lo




--
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