Dumb question:
This line...
s/,.*$//;
finds the data from the start of the sentence up to the first "," in encounters, and disregards everything after. What if I want to do the exact same thing, but starting at the second ","?
You could also use the split() function but I am unsure what you are trying to do in the end so its hard to say which way to go, pure regexp or split().
Kevin, thanks for your help, I am definately getting closer to the answer. I apprishiate your patience with me.
Here is the raw data:
agriggs,10.160.4.148,tcmcpccma1,agriggs
tthomas,10.160.7.14,tcmcpccma1,tthomas
sturman,10.160.4.186,tcmcpccma1,sturman
Here is the expected result:
agriggs,10.160.4.148
tthomas,10.160.7.14
sturman,10.160.4.186
Here is my code:
open (IN, 'P:\CCMAAudit\tmp00.txt');
open (OUT,'>P:\CCMAAudit\tmp01.txt');
while (<IN>) {
chomp;
s/^[^,]+,[^,]+,(.*)/$1/;
print OUT $_, "\n";
}
close (IN); close (OUT);
Here is the actual result:
tcmcpccma1,agriggs
tcmcpccma1,tthomas
tcmcpccma1,sturman
I'm getting the exact opposite of what I'm after. I'm close to understanding this, but I just haven't wrapped my head around it yet.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.