Solved

request translation of perl code line

Posted on 2013-12-12
2
281 Views
Last Modified: 2013-12-13
Greetings,
I am not a perl expert by any means.
I have this line of code that reads lines in a file:

%s fs -cat %s | perl -pe 's/\t/,/g' > %s

I want to say that -pe and the string behind it talks about delimiters?

If I wanted to write this line twice, once with tab-only and once with comma-only delimiters,
how do I do it?
Thanks
0
Comment
Question by:Evan Cutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39715572
perl -MO=Deparse  -pe 's/\t/,/g'
LINE: while (defined($_ = <ARGV>)) {
    s/\t/,/g;
}
continue {
    die "-p destination: $!\n" unless print $_;
}

s/\t/,/g  Searches for tab and replaces it with , /g means match globally, i.e., find all occurrences.

If instead you want to change , to tab, you can do s/,/\t/g
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 39717551
Thanks much.
This got me where I needed to go.

Most appreciated.
0

Featured Post

Webinar: MongoDB® Index Types

Join Percona’s Senior Technical Services Engineer, Adamo Tonete as he presents “MongoDB Index Types, How, When and Where Should They be Used?” on Wednesday, July 12, 2017 at 11:00 am PDT / 2:00 pm EDT (UTC-7).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question