Jerry Preston wrote:
I am want to break down the following code that can have any number of vars
being passed:

  c_routine("name_1", 2, 3, 5, 0,9, 1, A, b, -1.5, 1.2, 100000, 0.03, 0, 0,
1, 0, m, l, var_name_1,  var_name_2,  var_name_3,  var_name_4,  var_name_5,
var_name_6);

I only want the passed vars.

           my ( $nuts, $line ) = split /\(/;
           my @passed_vars     = split /,/;

This should work (untested):

my $code = ' c_routine("name_1", 2, 3, 5, 0,9, 1, A, b, -1.5, 1.2, 100000, 0.03, 0, 0, 1, 0, m, l, var_name_1, var_name_2, var_name_3, var_name_4, var_name_5, var_name_6);';

my @passed_vars = map split( /\s*,\s*/ ), $code =~ /\w+\s*\(([^)]+)\)/;


Also is it possible to get only the vars following ", m, l, " through ");"?

my @passed_vars = map split( /\s*,\s*/ ), $code =~ /\w+\s*\([^)]*?, m, l, ([^)]+)\)/;




John
--
use Perl;
program
fulfillment

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