prassi has asked for the wisdom of the Perl Monks concerning the following question:
Hi Perl Monks,
I have a string which can take of 2 forms which I have mentioned below, which is part of the code
The string can be either of 2 forms and I need to split in the first case like$def1 = "!defined(FLOAT_CODE)"; $def2 = "defined(FIXED_CODE)";
! FLOAT_CODE
and in the second case like
FIXED_CODE
but a single statement has to do it, I do not want 2 separate case for each one. Below is my perl code with different variant I have tried.
Variant:1
This gives me likem/^(!defined|defined)\((.*?)\)$/; print "$1----$2\n";
Variant 2:output case1: !defined----FLOAT_CODE output case2: defined----FIXED_CODE
m/^(\!|defined)(.*?)$/; print "$1----$2\n";
output case1: !----defined(FLOAT_CODE) output case2: defined----(FIXED_CODE)
But both are not helping me in solving the issue can you please help in solving this or any other method avaliable.
Regards,
-Prassi
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: extracting data from string
by moritz (Cardinal) on Jul 16, 2012 at 10:59 UTC | |
Re: extracting data from string
by Marshall (Canon) on Jul 16, 2012 at 13:37 UTC | |
Re: extracting data from string
by Neighbour (Friar) on Jul 16, 2012 at 14:33 UTC | |
Re: extracting data from string
by kcott (Archbishop) on Jul 17, 2012 at 06:23 UTC |
Back to
Seekers of Perl Wisdom