![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl Pattern Matching !!! Help | maxmave | Shell Programming and Scripting | 0 | 06-03-2008 08:05 PM |
| AWK pattern matching, first and last | smb_uk | Shell Programming and Scripting | 10 | 12-27-2007 09:03 PM |
| Perl: Pattern Matching a HASH variable | pondlife | Shell Programming and Scripting | 1 | 04-10-2006 04:31 PM |
| perl pattern matching vs. grep | junkmail426 | Shell Programming and Scripting | 0 | 09-28-2005 11:40 AM |
| pattern matching + perl question | Optimus_P | Shell Programming and Scripting | 1 | 12-05-2003 07:43 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
hi i am trying to get digits inside brackes from file , whose structure is defined below Code:
CREATE TABLE TELM
(SOC_NO CHAR (3) NOT NULL,
TXN_AMOUNT NUMBER (17,3)
SIGN_ON_TIME CHAR (8)
TELLER_APP_LIMIT NUMBER (17,3)
FIL01 CHAR (11)
CONSTRAINT TELMPK
PRIMARY KEY (SOC_NO,
TELLER_NO),
CONSTRAINT TELMUK_02
UNIQUE (SOC_NO,
TELLER_NO,
SUP_TELLER));
i want only digits inside bracket i am able to get digits from bracket (which is BOLD) if there is only one digit eg : Code:
[(SOC_NO CHAR (3) NOT NULL,] with following code Code:
if (/^.*(CHAR|NUMBER)\s*.*$/) {
$_ =~ s/ DEFAULT(.*)// ;
print "$_\n" ;
if (/^.*\((\d+)\).*$/) {
print "one:$1\n" ;
}elsif (/^.*\((\d\d),(\d)\).*$/) {
print "two :$2\n" ;
}
but i am not able to get digits if they are specified with comma in between like : Code:
TXN_AMOUNT NUMBER (17,3) for above i want 17 in 1 varaible and 3 in other but i m not able to manage it i get only digit specified after "," 3 for above case. |
|
||||
|
Hi zedex, supponing that the file you are reading is called 'temp', you can use this code to get both numbers in brackets: Code:
open(FILE, "< temp");
while ( $r = <FILE>) {
if ($r =~ /^.*\s+.*\s+\((\d+)\)/) {
print "\$1= $1\n";
}
elsif ($r =~ /^.*\s+.*\s+\((\d+),(\d+)\)/) {
print "\$1= $1\n";
print "\$2= $2\n";
}
}
Sergio |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|