Solved

request translation of perl code line

Posted on 2013-12-12
2
275 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now