pattern matching

P

pavan734

hi Iam pavan . I need to run a perl script that runs on a file and does
the following.

The file may look like like this
pavan.h:

pavan_here hi how r u
pavan_there Iam fine
pavan_now typing

Search for words containing pavan(say)
In the above example it much search for pavan_here, pavan_there ,
pavan_now and modify those words such that
1.underscores must be eliminated
2. Next letter to underscore(i.e anyletter after underscore) must
become capital.


I mean to say when I run the script the file must modify to

pavanHere hi how r u
pavanThere Iam fine
pavanNow typing

Hope you understood the problem
 
J

Jürgen Exner

hi Iam pavan . I need to run a perl script

If your system is set up properly then you can run a perl script simply by
typing it's name on the command line.
If that is not your problem then we will need much more details about your
system and how exactly you are trying to run the script.
that runs on a file and
does the following.

The file may look like like this
pavan.h:

pavan_here hi how r u
pavan_there Iam fine
pavan_now typing

Search for words containing pavan(say)
In the above example it much search for pavan_here, pavan_there ,
pavan_now and modify those words

To modify text people often use the 's' (aka substitute) function
such that
1.underscores must be eliminated

This could also be done by the 'tr' function
2. Next letter to underscore(i.e anyletter after underscore) must
become capital.

The easiest way is probably to use the 'ucfirst' function.
I mean to say when I run the script the file must modify to

pavanHere hi how r u
pavanThere Iam fine
pavanNow typing

Hope you understood the problem

I understand your goal (at least I think), that was a good description.
But you didn't explain what your problem is nor did you give us enough
information to fix it. Where are you stuck? Which part of your program is
not working as expected? Where is your program to begin with?

jue
 
P

pavan734

Sorry, I have not written any script at all. I know how to run a
script. But I want a code to do that. Also tell me whether is it
possible in vim "search and replace" command.
 
A

A. Sinan Unur

(e-mail address removed) wrote in @z34g2000cwc.googlegroups.com:
Sorry, I have not written any script at all.

Please read the posting guidelines for this group, and then write a
script that attempts to accomplish what you want.

Then, come back here and ask about issues you can't solve.
I know how to run a script. But I want a code to do that.

I think the going consulting rate here is about $100. Unfortunately,
most of us have really busy schedules, which means we can't take on new
clients all the time.

This is not a "write my code for me" service.
Also tell me whether is it
possible in vim "search and replace" command.

comp.editors

Sinan
--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
P

pavan734

This is a generic question ...... A single vim command can do it. But I
dont know much abt vim.
 
A

A. Sinan Unur

(e-mail address removed) wrote in @g10g2000cwb.googlegroups.com:
This is a generic question ...... A single vim command can do it. But I
dont know much abt vim.

Then learn. On your own or with the help of the friendly people over in
comp.editors.

I won't be seeing your posts again.

Sinan

--
A. Sinan Unur <[email protected]>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
J

Jürgen Exner

(e-mail address removed) wrote:
[What are you replying to? Please quote appropriatly -as has been customary
in Usenet for 2 decades- such that people have a chance to know what your
are talking about.]
Sorry, I have not written any script at all.

No problem. Now is as good a time to start as any. I recommend "Learning
Perl", availaible in your favourite book store.
I know how to run a
script.
Good.

But I want a code to do that.

Trying to understand: you want to run your script from your code? Please see
"perldoc -f system".
Also tell me whether is it
possible in vim "search and replace" command.

Maybe you should ask in a NG that deals with vim about if it is possible to
run a script in the vim "search and replace" command.

jue
 
J

Jürgen Exner

This is a generic question ...... A single vim command can do it. But
I dont know much abt vim.

What is a generic question? I don't see any in your post.

jue
 
R

robic0

(e-mail address removed) wrote in @z34g2000cwc.googlegroups.com:


Please read the posting guidelines for this group, and then write a
script that attempts to accomplish what you want.

Then, come back here and ask about issues you can't solve.


I think the going consulting rate here is about $100. Unfortunately,
most of us have really busy schedules, which means we can't take on new
clients all the time.

HUH? 100? Per hour? Where can I get that kind of work?
 
T

Tad McClellan

Search for words containing pavan(say)
modify those words such that
1.underscores must be eliminated
2. Next letter to underscore(i.e anyletter after underscore) must
become capital.


---------------------
#!/usr/bin/perl
use warnings;
use strict;

while ( <DATA> ) {
s/pavan_(\w)/paven\U$1/g;
print;
}

__DATA__
pavan_here hi how r u
pavan_there Iam fine
pavan_now typing
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top