?
Solved

Perl: remove tab characters from lines

Posted on 2011-04-28
6
Medium Priority
?
419 Views
Last Modified: 2012-05-11
Ho can I remove tab characters from a line?
Thank you.
$infile = "input.txt";
open(DATA, $infile);
@lines_var = <DATA>;

for( $i = 0; $i < $#lines_var; $i++
{
     // remove tabs from every line

}

Open in new window

0
Comment
Question by:ambuli
  • 4
6 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 35485260
// remove tabs from every line
s/\1//g
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35485267
Sorry,
// remove tabs from every line
s/\t//g;
0
 
LVL 31

Expert Comment

by:farzanj
ID: 35485275
Actually

foreach (@lines_var)
{
    // remove tabs from every line
    s/\t//g;
}
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ambuli
ID: 35485299
So, is that the following that I need to do?  seems not to be working.
$infile = "input.txt";
open(DATA, $infile);
@lines_var = <DATA>;

for( $i = 0; $i < $#lines_var; $i++
{
   $lines_var[$i] = s/\t//g;
}

Open in new window

0
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 total points
ID: 35485313
lines_var[$i] =~ s/\t//g;
0
 
LVL 85

Expert Comment

by:ozo
ID: 35485696
s/\t//g for @lines_var;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Six Sigma Control Plans
Suggested Courses

864 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