Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

Search and Replace with perl


Hi,

 I have a file with entries like

=======================================
 _RWSTD_VALUE_ALLOC(test1,
                                        test5);
 _RWSTD_VALUE_ALLOC(test1,snm);
 _RWSTD_VALUE_ALLOC(xyz,
                                        789);
 _RWSTD_VALUE_ALLOC(test1,sbk);
 _RWSTD_VALUE_ALLOC(abc,
                                        123);

:
===============================

I want to put 2nd argument to  _RWSTD_VALUE_ALLOC as *this .
So my resultant file should be
=======================================
 _RWSTD_VALUE_ALLOC(test1,*this,
                                        test5);
 _RWSTD_VALUE_ALLOC(test1,snm);
 _RWSTD_VALUE_ALLOC(xyz,*this,
                                        789);
 _RWSTD_VALUE_ALLOC(test1,sbk);
 _RWSTD_VALUE_ALLOC(abc,*this,
                                        123);

:
===============================

Please help me to write this script....

In article <1181134539.470120.313@a26g2000pre.googlegroups.com>,

Which part are you having trouble with? You are more likely to get help
if you first make an attempt at solving your problem and post only the
code with which you are having trouble. You will be lucky to find
someone who wants to write your program for you.

Note: you are using Google Groups to post to a Usenet group, so many
helpful regulars in comp.lang.perl.misc will not even see your post.
Consider using a regular news reader in the future.

Now to your problem:

Why are the some of your lines split after a comma and some are not? Do
you really want to add "*this," to only those lines that are split? If
so, you can do this with a simple substitution (untested):

  if( $line =~ /_RWSTD_VALUE_ALLOC\(.*,\s*$/ ) {
    $line .= '*this,';
  }

If your cases are more varied, then you will have to use more complex
logic.

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com

In article <060620070935262574%jgib@mail.arc.nasa.gov>, Jim Gibson

<jgib@mail.arc.nasa.gov> wrote:
> If so, you can do this with a simple substitution (untested):

>   if( $line =~ /_RWSTD_VALUE_ALLOC\(.*,\s*$/ ) {
>     $line .= '*this,';
>   }

That, of course, is not a "simple substitution", it is a "string
concatenation after a regular expression match". Sigh.

--
Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
    ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------        
                http://www.usenet.com

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc