Jerry Preston wrote:
>
> I know how to do this in C, but how to in Perl?  I want to chop the
> following string:
>
>    if ((bulk>0) || (sub>0)||(chuckcon>0)) conpin (smu3, bulk, sub, chuckcon,
> 0);
>
> Apart so that all is left is:
>
>    if ((bulk>0) || (sub>0)||(chuckcon>0))
>
> The key word to break on is 'conpin', but it will change in each line.

Hi Jerry.

I'm not clear exactly what you need to do, but this code should help.

Rob


my $str = 'if ((bulk>0) || (sub>0)||(chuckcon>0)) conpin (smu3, bulk, sub, chuckcon, 
0)';
$str =~ /(.*\)\))/;
print $1, "\n\n";

my @parts = split /(?<=\)\))\s+/, $str;
print map "$_\n", @parts;

**OUTPUT

if ((bulk>0) || (sub>0)||(chuckcon>0))

if ((bulk>0) || (sub>0)||(chuckcon>0))
conpin (smu3, bulk, sub, chuckcon, 0)

Tool completed successfully



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