Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

request translation of perl code line

Posted on 2013-12-12
2
Medium Priority
?
282 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 2000 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

730 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