in reply to postfix "for" question?

I wouldn't expect ChatGPT to generate valid Perl; it's hard enough for human beings to do that without knowing Perl.

do { CORE::say $_ for 1 .. 5 } for 1 .. 10;

You could try that. I wouldn't. But you could.

Edit: Even more convoluted: do { CORE::say $_ for 1 .. $_ } for 1 .. 10;. I guess tinkering like this helps figure out how context and loops work, if that's the goal.

Replies are listed 'Best First'.
Re^2: postfix "for" question?
by misterperl (Friar) on Sep 11, 2023 at 16:11 UTC
    well my REAL goal, if truth be told, as an APL-trained programmer, is to seek ways to produce a result in the fewest number of characters... Removing {} not only helps reach that goal, it makes things much more English-like..

    TY!

      perl -E 'say for (1 .. 5) x 10'

      This solution is brought to you without the help hindrance of ChatGPT.


      🦛

      How about

      map CORE::say, 1..5 for 1..10

      map is almost postfix and almost like a for

        Not sure which circle Dante put them but I’m sure there’s a place for those misusing map in void context . . .

        The cake is a lie.
        The cake is a lie.
        The cake is a lie.