gringocharlie has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Help with Image Magic
by AnomalousMonk (Archbishop) on Oct 09, 2008 at 22:12 UTC
    It doesn't involve a regex, which would seem inappropriate for this problem, but either of the following two approaches should work:
    >perl -wMstrict -le "my @raw_files = qw{ 12.png 06.png 06.png 03.png 07.png 07.png }; my $blank_png = 'blank.png'; my @blanked_files = interleave_blanks($blank_png, @raw_files); print qq{@blanked_files}; sub interleave_blanks { my $blank_file = shift; my $prev_file = ''; map { my $repeat = $_ eq $prev_file; $prev_file = $_; $repeat ? ($blank_file, $_) : ($_); } @_ ; } " 12.png 06.png blank.png 06.png 03.png 07.png blank.png 07.png >perl -wMstrict -le "my @raw_files = qw{ 12.png 06.png 06.png 03.png 07.png 07.png }; my $blank_png = 'blank.png'; my @blanked_files = do { my $prev_file = ''; map { my $repeat = $_ eq $prev_file; $prev_file = $_; $repeat ? ($blank_png, $_) : ($_); } @raw_files ; }; print qq{@blanked_files}; " 12.png 06.png blank.png 06.png 03.png 07.png blank.png 07.png
    Update:

    In case the animation sequence is a continuous loop and thus requires a blank .png inserted after the last .png in the array if the last .png is the same as the first .png, this should do the trick (although it might be a little more elegant without a bunch of reverses scattered all over the place):

    >perl -wMstrict -le "my $blank_png = 'blank.png'; print qq{\noutput:}; for (@ARGV) { print qq{ in: $_}; my @raw_files = split; my @blanked_files = interleave_blanks($blank_png, @raw_files); print qq{out: @blanked_files}; } sub interleave_blanks { my $blank_file = shift; my $prev_file = $_[0]; reverse map { my $repeat = $_ eq $prev_file; $prev_file = $_; $repeat ? ($blank_file, $_) : ($_); } reverse @_ ; } " "12.png 06.png 06.png 03.png 07.png 07.png" "07.png 12.png 06.png 06.png 03.png 07.png 07.png" output: in: 12.png 06.png 06.png 03.png 07.png 07.png out: 12.png 06.png blank.png 06.png 03.png 07.png blank.png 07.png in: 07.png 12.png 06.png 06.png 03.png 07.png 07.png out: 07.png 12.png 06.png blank.png 06.png 03.png 07.png blank.png 07. +png blank.png
Re: Help with Image Magic
by AnomalousMonk (Archbishop) on Oct 09, 2008 at 23:38 UTC
    Whoa!!! Where did the original post go? An answer doesn't mean very much without a question.
      Whoa!!! Where did the original post go? An answer doesn't mean very much without a question.

      I personally believe, incidentally, that this is a good reason to include some quote from the nodes I reply to, when I do reply. This is a habit I got from usenet, actually, and it has been often debated here, with good arguments both in favour of doing so and against. To be fair, at least as of late, I generally don't follow it myself, when commenting such short nodes as yours here or when it's clear that I'm replying to the whole node anyway, whereas I more closely stick to it when I want to stress the single points I'm addressing.

      --
      If you can't understand the incipit, then please check the IPB Campaign.
Re: Help with Image Magic
by missingthepoint (Friar) on Oct 10, 2008 at 07:43 UTC

    gringocharlie, please re-update your post to include what you posted originally. As it stands your post is useless to people having the same problem.

    For future reference, a good convention is to add any updates to the end of the post (without deleting the original content!) and prefix the update with the word 'update:' in bold.


    email: perl -e 'print reverse map { chr( ord($_)-1 ) } split //, "\x0bufo/hojsfufqAofc";'