parsed.org

Tips by tag: print

Print Without Trailing Newline by cygnus on Aug 17, 2005 01:26 PM

To make print suppress its usual trailing newline, add a comma to the end of the statement:

print "Foo",
print "Foo %s" % (bar),
languagesprintprogrammingpythonsyntaxtrailing-newline
Processing An Array by xinu on Apr 02, 2008 12:34 AM

In Perl you may have an array you'd like to iterate over. This would work:

for $line (@array) {
    print "line: $line\n";
}

Or you could use this abbreviated method with map():

print map ("line: $_\n") @array;
arraymapperlprint
RSS