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

Thanks that works , But I can't use the value of $row variable for future purpose even within the while loop . I tried few things , But it didn't work .
  • Comment on Re^10: Join multiple lines in a string based on regex.

Replies are listed 'Best First'.
Re^11: Join multiple lines in a string based on regex.
by NetWallah (Canon) on Dec 24, 2014 at 00:54 UTC
    "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

      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?