in reply to print inside a loop
Updated: changed "something" to $i. Updated: Found a better unbuffered way...#!/usr/bin/perl use strict; use warnings; foreach my $i ( 1..3 ) { if ($i lt 3) { print "\nChecking $i - ", "\n"; sleep 3; print "OK\n"; } else { print "\nChecking $i - ", "\n"; sleep 3; print "Not OK\n\n"; } }
#!/usr/bin/perl use strict; use warnings; foreach my $i ( 1..3 ) { if ($i lt 3) { print "\nChecking $i - " and sleep 3 and print "OK"; } else { print "\nChecking $i - " and sleep 3 and print "Not OK\n"; } }
|
|---|