Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: need help to print some lines

by ww (Bishop)
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.


Comment on Re: need help to print some lines
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006104]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-08-01 07:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (257 votes), past polls