Rasoul Hajikhani wrote:
>
> Hello folks,
Hello,
> I am trying not to re-invent the wheels. So I was wondering whether
> there is a little program that you good people might know of the would
> do the following for me:
>
> Here's an example:
>
> input: 1,2,3,4,5,6,17-25,32-101:4
> output:
> 1 6 1
> 17 25 1
> 32 100 4
>
> output is "start end increment"
>
> also, frames can be duplicated:
>
> input: 1,2,3,4,5,6,17-25,32-101:4,1,2,3,5
> output:
> 1 6 1
> 17 25 1
> 32 100 4
> 1 3 1
> 5 5 1
>
> On top of that, I may, at times, want to have up to 10,000 command line
> values. I know it sounds very strange, but it is for a movie studio with
> very peculiar requirements.
This might be what you need:
for ( split/(\d+-\d+(?::\d+)?),?/ ) {
next unless /\d/;
@x = /(\d+)/g;
if ( /-/ ) {
print "@x", @x == 2 ? " 1\n" : "\n";
}
else {
do {
@y = ();
unshift @y, pop @x until $#x == $x[-1] - $x[0];
print "$x[0] $x[-1] 1\n";
} while ( @x = @y );
}
}
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]