in reply to powerpoint problem

FYI, your "while ($i < 5)" loop can be written more idiomatically thus:

for (my $i = 1; $i < 5; $i++) { $slide = $ppt->Slides->Add($i, ppLayoutBlank); }

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

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

    I think that loop would be even more clear this way:

    foreach my $i ( 1 .. 4 ) { $slide = $ppt->Slides->Add($i, ppLayoutBlank); }
      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?"

        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 ); }
Re^2: powerpoint problem
by Anonymous Monk on Apr 24, 2008 at 20:28 UTC
    my problem is not wid the loop, I just sent a part of my code. The main problem is I couldnt paste the ".gif" file in my PPT slide.
    $pname = 'C:\Documents and Settings\Desktop\Perl_files\file.gif'; $slide->Shapes->AddOLEObject({Left=>225, Top=>125, Width=>480, Height=>320, FileName=>$pname});
    It is just pasting a text "file.gif" instead of picture. So is there any way I can import the picture..??
      In addition to pc88mxer's advice below, you need to use the AddPicture method (instead of AddOLEObject) to add a picture from a file.

      Thank you for using <code> tags. Perhaps you could edit your original node, and add those, to assist new readers of this thread.

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