Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: need help to print some lines

by ww (Archbishop)
on Nov 28, 2012 at 21:20 UTC ( #1006104=note: print w/replies, xml ) Need Help??

in reply to need help to print some lines

Rethink your notion that you can "print form (sic) a to e and then to return in line of and print f to j". You can't undo the printing of a newline in the manner you describe, any more than you can put the toothpaste back in the tube (or the genie back in the bottle, if you prefer).

Instead, consider determining the length of your array and dividing by two to derive the appropriate values in Lns 8 & 9 (which are hardcoded below and left as an exercise for the OP):

#!/usr/bin/perl use 5.014; # enable features, strict and warnings my @arr = qw(a b c d e f g h i j); my $i=0; while ( $i <=4 ) { my $j = $i+5; say "$arr[$i] \t $arr[$j]"; $i++; }

Hint: reading about the var $#, scalar(@arr) or searching for "array length" will be instructive.

Afterthought: obviously, I've understood meaning of the SOPW differently than some other Monks. Since OP provides no code, and only (IMO) an ambiguous spec, it seems plausible that the OP is trying to print a simple, 10 element array with a single letter is each element as a set of lines with the first half of the elements in column 1 and the second half in column 2.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006104]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2018-04-23 11:58 GMT
Find Nodes?
    Voting Booth?