in reply to Re^2: powerpoint problem
in thread powerpoint problem

Agreed. (++)

To take it to the next step, how about:

$slide = $ppt->Slides->Add($_, ppLayoutBlank) for 1..4;
and avoid the (explicit) pesky temporary variable.

However, for newbies, I'd suggest they stay with my original "C-style for loop" suggestion (to use when they actually need the index variable), until they get more comfortable with perl-style use of $_ for temp vars, and lists generated by the ".." operator.

     "How many times do I have to tell you again and again .. not to be repetitive?"

Replies are listed 'Best First'.
Re^4: powerpoint problem
by kyle (Abbot) on Apr 24, 2008 at 19:22 UTC

    I find that with a long statement like that, the modifier gets lost. A casual peruser might not notice there's a loop there at all. It's a little better if the modifier gets its own line like so:

    $slide = $ppt->Slides->Add($_, ppLayoutBlank) for 1..4;

    I like temporary variables too. Usually when $_ appears, it's a comprehension vortex. In this case, the variable ($i) is not much better, but sometimes a good name on a variable can add a lot of documentation. For example,

    foreach my $good_guy ( @ARGV ) { push @my_attr, get_attributes( $good_guy ); }