[EMAIL PROTECTED] wrote:
> 
> I have discovered that the number between square brackets [] won't be
> only a one-digit number, but now it can contain an un-foreseen number
> of digits, because the number inside the square brackets will grow
> from 1 to several millions
> 
> As I have just stated, with a one-digit number, the script run
> flawlessly, but now that the [number] grow of to millions, I have
> problems again
> 
> How should I change the code in order to be able to remove the
> previous mentioned characters ("cluster", {}, [], =, etc), but now
> taking into account that [number] will grow, from 1 to millions ?

All of the solutions offered to you before will handle this case as well.
Yitzle's code has a bug, and

  $line =~ /cluster\[(\d)+\] = {([\d ]+)}/ or die;

should read

  $line =~ /cluster\[(\d+)\] = {([\d ]+)}/ or die;

The program below is what I would write.

HTH,

Rob


use strict;
use warnings;

while (<DATA>) {
  next unless /^cluster\[/;
  print join ',', /\d+/g;
  print "\n";
}

__DATA__
cluster[1] = { 2 3 4 8 10 14 }
cluster[2] = { 2 3 4 8 10 14 }
...
cluster[1234567] = { 2 3 4 8 10 14 }
...
cluster[45689080] = { 2 3 4 8 10 14 }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to