Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Split lines in file to columns

by tybalt89 (Monsignor)
on Mar 20, 2019 at 16:59 UTC ( [id://1231503]=note: print w/replies, xml ) Need Help??


in reply to Split lines in file to columns

#!/usr/bin/perl # https://perlmonks.org/?node_id=1231482 use strict; use warnings; while(<DATA>) { chomp; my ($colA, $colB, $colC, $colD) = split /\s{2,}/; $colD =~ /Region/ and $colC =~ s{^XYZ\z}{N/A}; use Data::Dump 'dd'; dd $colA, $colB, $colC, $colD; } __DATA__ ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli +er ID::Region ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli +er ID::Region ValuesInColumn1 DataColumnB XYZ RowDescription|RowCode|Suppli +er ID::Region ValuesInColumn1 DataColumnB XYZ RowDescription at RowCode ValuesInColumn1 DataColumnB ABC RowDescription at RowCode

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-03-28 18:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found