Search and Replace

S

subha

Hi,

I wrote Perl Scripting for Alignment.

I had a Text file in which data was unaligned and with my 2 lines
coding i aligned the data.
data was something like this:

FirstName LastName Email1
--->Email2 Date Time Timetype

Output should be in one line

Name(first & Last) Email1 Email2 Date Time
Timetype

I used the code

$replace_file =~ s/\n\-\-\-\> /\t/g;
$replace_file =~ s/\s\s+/\t/g;

to get above output, but the problem comes when the user has middle
name even

if there is middle name i am getting output like

Name(first,middle, Last)Email1 Email2 date time
timetype

Can anyone help me out with this.

thanks in advance
subha
 
B

Ben Bullock

subha said:
Hi,

I wrote Perl Scripting for Alignment.

I had a Text file in which data was unaligned and with my 2 lines
coding i aligned the data.
data was something like this:

FirstName LastName Email1
--->Email2 Date Time Timetype

Output should be in one line

Name(first & Last) Email1 Email2 Date Time
Timetype

I used the code

$replace_file =~ s/\n\-\-\-\> /\t/g;
$replace_file =~ s/\s\s+/\t/g;

to get above output, but the problem comes when the user has middle
name even

if there is middle name i am getting output like

Name(first,middle, Last)Email1 Email2 date time
timetype

Can anyone help me out with this.

I'm not sure I understand the problem; isn't it just a line wrap on the
terminal? Or could it be that there is only one space after the "time" or
something? Maybe you need to write s/\s+/\t/g;.
 
D

David Squire

subha said:
If i use s/\s+/\t/g;. i am getting Entire data in one row

Please read the posting guidelines for this group (they are posted here
regularly). In particular, please quite context when you reply, so that
people can have some idea what you are talking about. (This is a Usenet
group. Most participants are *not* using Google Groups).

Also, please post a small, complete script, including data, that
illustrates your problem (i.e. show us the actual and desired output).

DS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top