Search and Replace



Hi,
Know that I am learning perl, I am expected to use it at work :)
Problem is I am still to green for the current problem I have. The data is always left justified and has a space between each value.

I have a text file of about ~500 lines like this:
-11.67326 23.95923 0.4617566
5.075023 24.27938 0.4484084
6.722163 -24.68986 1.399011
-11.2023 -25.0398 1.145933

I need to do the following:
Insert and X, Y and Z as one script:
X-11.67326 Y23.95923 Z0.4617566
X5.075023 Y24.27938 Z0.4484084
X6.722163 Y-24.68986 Z1.399011
X-11.2023 Y-25.0398 Z1.145933


Lastly, I'll need to make an additional copy of the program to strip out any numerical values for Z, and replace them with the following, [some_var].
X-11.67326 Y23.95923 Z[some_var]
X5.075023 Y24.27938 Z[some_var]
X6.722163 Y-24.68986 Z[some_var]
X-11.2023 Y-25.0398 Z[some_var]

Any help would be appreciated greatly, I am still just to new for this!

Thanks guys!
jlc





Relevant Pages

  • RE: Search and Replace
    ... Know that I am learning perl, I am expected to use it at work:) ... I'll need to make an additional copy of the program to strip out ... print SOMEFILE "X$x Y$y Z$newz\n"; ...
    (perl.beginners)
  • Re: prob send and NET::SMTP
    ... Thank's a lot for your help, I'm learning perl on my own ... Newsgroups: comp.lang.perl.misc ... Subject: prob send and NET::SMTP ... >> the script dies ...
    (comp.lang.perl.misc)
  • Globbing on Win32
    ... I am still learning Perl. ... I am trying to write a script to ... recursively list all the directories starting from a specified path. ... used literal paths, but in application I would obviously need to use a ...
    (comp.lang.perl.misc)
  • regex patern matching script
    ... I'm trying to extend the short regex checking script given in ... Learning Perl (Absolutely fabulous book btw! ... Highly recommend it to ... original script. ...
    (perl.beginners)
  • Re: How to store multiple value in a Hash for cookies
    ... > I have just started learning PERL and I have written a simple CGI script. ... > user click more than 1 value in each group of checkboxes, ... you will wind up storing a reference to the hash in the cookie. ...
    (comp.lang.perl.misc)