in reply to Re^10: Join multiple lines in a string based on regex.
in thread Join multiple lines in a string based on regex.

"didn't work" is a very poor problem description.

If you would like help with this, please explain what you tried, what you were expecting, and what you got.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

  • Comment on Re^11: Join multiple lines in a string based on regex.

Replies are listed 'Best First'.
Re^12: Join multiple lines in a string based on regex.
by pr33 (Scribe) on Dec 24, 2014 at 01:46 UTC
    Here is what I am trying to do . Basically , I am using a list slice to extract few elements from the O/P and I wanted to assign the result to a variable within the same Open While File Handle so that I can use the result for other purpose . I am splitting the data with : and \s as delimiter and extracting few elements of the resulting array . When I use the assignment , It cannot print the value of the variables .
    if (/^array|^unassigned/){ print "$row\n" if $inarray; $row=$_; my (undef, $unit, undef, undef , undef, undef , undef, $port, +undef, undef, undef, undef, undef,undef) = split /[\s,:]+/, $row; $inarray=m/^array/; next; } next unless $inarray; $row .= " $_"; } close $fd;

      Remember this and this?

      Its easy to learn to think like a computer if you use a piece of paper to walk through the program, through each iteration of the loop, and mark the changes to variables at each step

      You should do this if you want to be able to solve this problem ... my teacher did this when he started, I did this when I started ... I think everybody does this when they start programming, otherwise they give up because its too hard when you cannot keep track of variable changes

      Do you want to do this? Or do you want me to simply post the code I wrote?

        Thanks for the suggestion . I just started with learning perl , But I am in need for this due to time crunch . I would definitely improve with my ideas in the future . If you could post me your code , That will be helpful .