Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: perlform ^* variable field length

by pme (Monsignor)
on Apr 27, 2015 at 15:38 UTC ( [id://1124881]=note: print w/replies, xml ) Need Help??


in reply to perlform ^* variable field length

Hi AM,

Could you provide your perl variables to print and the required output format? You should also read perlform to understand perlform's concept.

Replies are listed 'Best First'.
Re^2: perlform ^* variable field length
by Anonymous Monk on Apr 27, 2015 at 15:54 UTC

    Hi, here's what I'm trying to do :

    my @row = ('col1 : line1 col2 : line2', 'col2', 'col3 f1 col3 f2', 'col4', 'col5:line1 col5:line2', 'coll6 : line1,line1 coll6 : line2,line2 coll6 : line3,line3 coll6 : line4,line4' ); my $f = "format = \n" . ('^*' . '|') x scalar(@row) . "~~\n" . '@row' . "\n" . ".\n"; eval($f); write;

    want desired result as :

    col1:line1|col2|col3 f1 col3 f2|col4|col5:line1|col6: line1,line1 col2:line2||||col5:line2|col6:line2,line2 |||||col6:line3,line3 |||||col6:line4,line4

    but running the code gives: Out of memory!

      I am afraid you still have not read the man. It is necessary to understand how perlform works.

      Your problem description is still rather dim. eg. what does 'col2' and 'f1' mean? Do you have 4 input lines having 6 columns each? We are unable to help you without clear problem description.

        Hi, I'm having an array that has 6 cols/fields and a col/field can have either a single line or multiple lines. So, I can say a array looks like as :

        ('col1 : line1 col2 : line2', 'col2 : line1', 'col3 : line1', 'col4 : line1', 'col5:line1 col5:line2', 'coll6 : line1 coll6 : line2 coll6 : line3 coll6 : line4' );

        and I want to print the content of array as :

        col1:line1|col2:line1|col3:line1|col4:line1|col5:line1|col6: line1 col2:line2||||col5:line2|col6:line2 |||||col6:line3 |||||col6:line4

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 05:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found