- or download this
#!/usr/bin/perl -w
@t = qw( aaaa bbbb ccccccc dddddd );
# assumes $i is undef or == 0
@n = map {$i+=5." ".$_} @t;
print map {$_."\n"} @n;
- or download this
#!/usr/bin/perl -w
@t = qw( aaaa bbbb ccccccc dddddd );
...
# the 2nd semicolon is not required, but adds clarity
@n = map {$i+=2; if ($i%5==0){$i+=2}; $i." ".$_} @t;
print map {$_."\n"} @n;
- or download this
@newwords = map {$l % 5 == 0; $l," ",$_} @words;