Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Split lines in file to columns

by hippo (Bishop)
on Mar 20, 2019 at 09:43 UTC ( [id://1231483]=note: print w/replies, xml ) Need Help??


in reply to Split lines in file to columns

But value for colD is not captured correctly, as string in colD has sapces in between.
my ($colA, $colB, $colC,$colD) = split( /\s+/, $line, 4);
If value for $colB = XYZ and $colD contains substring = Region , I need to replace the $colB from XYX to N/A.

There are many ways to do this. What did you try? How did it fail?

Replies are listed 'Best First'.
Re^2: Split lines in file to columns
by Magnolia25 (Sexton) on Mar 20, 2019 at 09:50 UTC

    Thanks hippo that worked

    If value for $colB = XYZ and $colD contains substring = Region , I need to replace the $colB from XYX to N/A

    Now I am going to try this out , was stuck at that part. So gave the reason why I am looking for this solution for earlier part

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-26 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found