RE: search

2003-11-21 Thread Mark Anderson
> From: Eric Walker [mailto:[EMAIL PROTECTED] > Sent: Friday, November 21, 2003 1:34 PM > Subject: search > > > I am trying to search a string for a "[]". I want to count the amount > of "[]" in the string. > > Any IDeas perldoc -q count gives you: How can I count the number of occurren

Re: search

2003-11-22 Thread Rob Dixon
Mark Anderson wrote: > > > From: Eric Walker [mailto:[EMAIL PROTECTED] > > Sent: Friday, November 21, 2003 1:34 PM > > Subject: search > > > > > > I am trying to search a string for a "[]". I want to count the amount > > of "[]" in the string. > > > > Any IDeas > > perldoc -q count > > gives y

Re: search

2003-11-22 Thread Douglas Lentz
Eric Walker wrote: I am trying to search a string for a "[]". I want to count the amount of "[]" in the string. Any IDeas $string = "a4r[]qy78[]x]y[114t"; $count = $string =~ s/\[]/\[]/g; print "$count\n" # $count will equal 2 Notice that this is not, (I repeat, not) the same as vari

Re: search

2003-11-22 Thread R. Joseph Newton
Eric Walker wrote: > I am trying to search a string for a "[]". I want to count the amount > of "[]" in the string. > > Any IDeas Are the brackets nested, or are they discrete. This makes a big difference in how you go about this. If they are not nested, I would recommend Rob's solution ab

Re: search

2003-11-22 Thread Douglas Lentz
Eric Walker wrote: I am trying to search a string for a "[]". I want to count the amount of "[]" in the string. Any IDeas re my first post on this, here is a better (well, Lazier) way: $string = "a4r[]qy78[]x]y[114[[|]]t"; $count = $string =~ s/(\[])/$1/g; print "$count\n"; #

Re: search

2002-03-27 Thread jbajin
How about trying something if you are going to go through a string.. grep //

RE: search

2002-03-27 Thread John Edwards
http://www.m-w.com/home.htm Oh, you mean in Perl?? Give more details. Are you looking for a word in a file? In an input string? $text = "this is a test string"; if ($text =~ /test/) { print "Found 'text' in string"; } John -Original Message- From: Allison Ogle [mailto:[EMAIL PROTE

RE: search

2002-03-27 Thread Allison Ogle
I am reading a datafile and searching for a specific word. Any help is greatly appreciated. Thanks, Allison -Original Message- From: John Edwards [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 11:15 AM To: 'Allison Ogle'; a a Subject: RE: search http://w

RE: Search Conditions

2001-06-22 Thread Govinderjit Dhinsa
> Hello everyone, I finally got my perl program running (below). What I had > to do was get certain 'data types' (fields) from a input file and out put > to a new file. > My question was; > How do I put a condition on the program, as I only want data from the > input files, which at 'field 15' ha

Re: Search Replace

2003-02-03 Thread Frank Wiles
.--[ Paul Kraus wrote (2003/02/03 at 10:29:14) ]-- | | I have an array that I want to remove every instance of '$' and all | leading and trailing white space. | My code only seems to remove '$'. I know I can split this into separate | commands but is there a way to do this all at

Re: Search Replace

2003-02-03 Thread Rob Dixon
"Paul Kraus" <[EMAIL PROTECTED]> wrote in message 005b01c2cb99$02315ee0$8afea8c0@pkraus">news:005b01c2cb99$02315ee0$8afea8c0@pkraus... > I have an array that I want to remove every instance of '$' and all > leading and trailing white space. > My code only seems to remove '$'. I know I can split th

RE: Search Replace

2003-02-03 Thread Paul Kraus
sage- From: Rob Dixon [mailto:[EMAIL PROTECTED]] Sent: Monday, February 03, 2003 10:54 AM To: [EMAIL PROTECTED] Subject: Re: Search Replace "Paul Kraus" <[EMAIL PROTECTED]> wrote in message 005b01c2cb99$02315ee0$8afea8c0@pkraus">news:005b01c2cb99$02315ee0$8afea8c0@p

Re: Search Replace

2003-02-03 Thread Rob Dixon
"Paul Kraus" <[EMAIL PROTECTED]> wrote in message 007001c2cba0$2a952ae0$8afea8c0@pkraus">news:007001c2cba0$2a952ae0$8afea8c0@pkraus... > Nope I wish. > > 3 fields. 1 is a part number, 2 is cost, 3 is list. > I am removing the '$' for 2 and 3. where as I am removing white space > from 1,2,&3. > I w

Re: Search Replace

2003-02-04 Thread Janek Schleicher
On Mon, 03 Feb 2003 10:29:14 -0500, Paul Kraus wrote: > I have an array that I want to remove every instance of '$' and all > leading and trailing white space. > My code only seems to remove '$'. I know I can split this into separate > commands but is there a way to do this all at once? Erm, I do

Re: Search Modules

2002-08-20 Thread Felix Geerinckx
on Tue, 20 Aug 2002 22:32:00 GMT, [EMAIL PROTECTED] (Rasoul Hajikhani) wrote: > Can anyone recommend a good string search module? I want to be > able to get possible combinations, permutations, sounds like, > etc... for a given string which will be someone's name. > Thanks in advance. Did you

Re: SEARCH & REPLACE

2004-05-05 Thread James Edward Gray II
On May 5, 2004, at 11:03 AM, Madhu Reddy wrote: -replace.pl--- #!/bin/perl -w # INPUT STRING my $in_str = ".import "; # REPLACE STRING my $repl = "/home/madhu/apps/toll.txt"; $_=$in_str; Why do this? # I don't want to use following, because # "TOLL_FREE" will be changed each tim

Re: SEARCH & REPLACE

2004-05-05 Thread Madhu Reddy
--- James Edward Gray II <[EMAIL PROTECTED]> wrote: > On May 5, 2004, at 11:03 AM, Madhu Reddy wrote: > > > -replace.pl--- > > #!/bin/perl -w > > > > # INPUT STRING > > my $in_str = ".import "; > > > > # REPLACE STRING > > my $repl = "/home/madhu/apps/toll.txt"; > > > > $_=$in

Re: SEARCH & REPLACE

2004-05-05 Thread James Edward Gray II
On May 5, 2004, at 12:26 PM, Madhu Reddy wrote: following is my main script, to simulate that i assigned to $_. Thanks for your solution if (!(open(FH_SRC_SCRIPT, "$src_script"))) { close(FH_SRC_SCRIPT); return 0; } Yuck. What does that say? If we ca

Re: SEARCH & REPLACE

2004-05-05 Thread Madhu Reddy
James, Thanks for correction.. for u r question regarding file open, following is correct code if (!(open(FH_SRC_SCRIPT, $src_script))) { print "(TERADATA.pl) generate_script:: File $src_script open failed --> $!\n"; return 0; } if (!(ope

Re: SEARCH & REPLACE

2004-05-05 Thread James Edward Gray II
On May 5, 2004, at 12:44 PM, Madhu Reddy wrote: James, Thanks for correction.. for u r question regarding file open, following is correct code if (!(open(FH_SRC_SCRIPT, $src_script))) { print "(TERADATA.pl) generate_script:: File $src_script open failed --> $!\n";

Re: SEARCH & REPLACE

2004-05-05 Thread James Edward Gray II
On May 5, 2004, at 2:11 PM, Madhu Reddy wrote: Then code which i sent is inside subroutine.. Then at least drop all those crazy symbols: unless (open FH_SRC_SCRIPT $src_script) { print "Whatever"; return 0; } Isn't that easier on the eyes? James -- To unsubscribe, e-mail: [EMAIL PRO

RE: search text

2004-07-15 Thread Bob Showalter
manojkumar vajram wrote: > Plz. help me . I am new to perl > I want to accept a pattern from screen > and search the pattern in my one or two text data base > and print the details > > The pattern from screen may consist spaces and special > char. line / - etc. > I use redhat linux 8.0 > I have co

Re: search text

2004-07-15 Thread Ramprasad A Padmanabhan
On Thu, 2004-07-15 at 05:04, manojkumar vajram wrote: > Plz. help me . I am new to perl > I want to accept a pattern from screen > and search the pattern in my one or two text data base > and print the details > > The pattern from screen may consist spaces and special > char. line / - etc. > I us

Re: search replace

2003-09-06 Thread perlwannabe
> Hi , > > How do I search replace text in a file from a perl script. i.e. by > opening the file in write mode and then do a search replace. > > I don't want to do a command line search replace. Use the s/// operator...as follows: $_ =~ s/oldtext/newtext/gi; this will replace all occurrences of

Re: search replace

2003-09-06 Thread Steve
perldoc perlre perldoc -f open On Sat, 2003-09-06 at 11:53, Pandey Rajeev-A19514 wrote: > Hi , > > How do I search replace text in a file from a perl script. i.e. by opening the file > in write mode and then do a search replace. > > I don't want to do a command line search replace. > > Regards

Re: search replace

2003-09-06 Thread Damon Davison
On Saturday 06 September 2003 17:53, Pandey Rajeev-A19514 wrote : : How do I search replace text in a file from a perl script. : i.e. by opening the file in write mode and then do a search : replace. You can do what you want via the regular expression substitution operator "s///" in a "while" lo

Re: Search utility

2001-11-01 Thread Etienne Marcotte
http://www.cgi-resources.com/ That's where I started to learn/ understand / like perl Now I am scripting my own, but it's a really good start and you have tons of scripts that will often do more than what you need:-) Etienne pc wrote: > I'm learning Perl so I can program CGI Web applications

Re: Search utility

2001-11-01 Thread Al Wheeler
http://www.perlfect.com/freescripts/search/ ---Original Message--- From: [EMAIL PROTECTED] Date: Thursday, November 01, 2001 12:01:51 PM To: Purshottam Chandak Cc: [EMAIL PROTECTED] Subject: Search utility I'm learning Perl so I can program CGI Web applications on a Unix box. The progra

Re: Search Keyword

2001-11-09 Thread Mark Murphy
Jason wrote: > > I have a project to retrieve a keyword from a .DAT file in perl, and i have > now managed to do this but now I need to create a HTML page where a user can > input a keyword and it will then display the results. Now all this is OK > until I try to link the keyword put into the

RE: Search Problems

2001-11-14 Thread Bob Showalter
> -Original Message- > From: Gomez [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, November 14, 2001 4:55 AM > To: [EMAIL PROTECTED] > Subject: Search Problems > > > I am having a few problems with a search on a DAT file using > perl with some > embedded HTML. I want to search for a keyw

Re: Search & Replace

2001-12-18 Thread Jonathan E. Paton
> Hi, > > I am used to work with a search and replace software > and I have a list of pattern like the one above which > I would like to translate to PERL. Need your help and > comments. > There is an example above? I'm assuming your Austrailian, since that'd mean you'd be upside down compare

re: Search And Replace

2005-01-07 Thread William Black
Hello All I'm tryiing to search and replace in both perl and korn shell. For Example: X=G1234V00 I want to replace all occurences of 'V' with 'v' in both perl and korn shell William Black -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Search And Replace

2005-01-07 Thread José Pedro Silva Pinto
Hi, do perl -pi -e 's/Old_value/new_value/g' Our_File Bye -Original Message- From: William Black [mailto:[EMAIL PROTECTED] Sent: sexta-feira, 7 de Janeiro de 2005 14:42 To: beginners@perl.org Subject: re: Search And Replace Hello All I'm tryiing to search and repla

RE: Search And Replace

2005-01-07 Thread Adamiec, Larry
> -Original Message- > From: William Black [mailto:[EMAIL PROTECTED] > Sent: Friday, January 07, 2005 08:42 > To: beginners@perl.org > Subject: re: Search And Replace > > > Hello All > > I'm tryiing to search and replace in both perl and korn shell

RE: Search And Replace

2005-01-07 Thread pablo wablo
> Sent: Friday, January 07, 2005 08:42 > > To: beginners@perl.org > > Subject: re: Search And Replace > > > > > > Hello All > > > > I'm tryiing to search and replace in both perl and > korn shell. > > > > For Example: &g

Re: Search And Replace

2005-01-07 Thread John W. Krahn
William Black wrote: Hello All Hello, I'm tryiing to search and replace in both perl and korn shell. For Example: X=G1234V00 I want to replace all occurences of 'V' with 'v' in both perl and korn shell You can use tr in both perl: perl -pe'tr/V/v/' file.in > file.out and the shell: tr V v < file.i

Re: search and replace

2001-07-23 Thread Akshay Arora
your best bet would be to just either search for or just incase there are some odd things between and [EMAIL PROTECTED] wrote: > > I have a bunch of .html files that I want to add a style sheet to. > currently, the top of the html file has this: > > > > > > > name.JPG > > > > so how

RE: search and replace

2001-07-25 Thread mark crowe (JIC)
Hi Todd You could try something like this; while (my $htmlfile = glob "*.html") { # finds all .html files, and # performs the substitution on each of them local $/ = undef; # slurp in the whole file in one go. Not generally # recomme

Re: search and replace

2001-08-04 Thread Michael Kelly
On 8/4/01 12:11 PM, Steven MysticPoet wrote: > i need to search for &member& in a textarea and replace it with the contents > of $member. how can i do this? im really quite new to this. :) > > im pretty sure that this will search it out > > $textarea =~ s/&member&/I; > > will search it out, bu

RE: Search and Replace

2003-03-11 Thread Dan Muey
First off it look s like you're opening a file then for every line of it opening another file. So if you have two files and file 1 has 100 lines in it you're opening file2 100 times! That could get messy. I'd say put file 2 in a hash Then open file 1 and do: if(exists $file1{$f} { ...# else

RE: Search and Replace

2003-03-11 Thread David Olbersen
Hi, If it's not required to have the domain commented out (meaning it can just not be there) then you could do this much more easily with a hash. If your new file can simply have: rtfm.com readitagain.com Then doing something like this would work well: my %domains = (); open( OLD, "$domainlis

Re: Search and Replace

2003-03-11 Thread Pete Emerson
Jay, Here's my solution. It doesn't use File::Slurp, as Dan suggested, but it does what you want it to do. I think that David's point is a good one ... if you don't need to preserve order, you can just use a hash. This method will preserve the order of the second file. Pete #!/usr/bin/perl -w

Re: Search and Replace

2003-03-11 Thread John W. Krahn
Jay Kidd wrote: > > Hello, Hello, > I need help trying to figure out what I'm doing wrong. > I'm working with 2 seperate text files both of which > contain domain names. What I'm attempting to do is > read the first file of domains and run a search based > on the contents of that file against t

Re: Search and Replace

2003-03-11 Thread R. Joseph Newton
Jay Kidd wrote: > Hello, > > I need help trying to figure out what I'm doing wrong. > I'm working with 2 seperate text files both of which > contain domain names. What I'm attempting to do is > read the first file of domains and run a search based > on the contents of that file against the second

RE: Search and Replace

2003-07-12 Thread Tim Johnson
In general, what you want to do is this; 1. open the file for reading 2. open a second file for writing 3. read in each line, doing the substitution (although technically using the tr/// operator might be quicker) 4. after each substitution, print the result to the second file 5. once al

Re: Search and Replace

2003-07-12 Thread Steve Grazzini
On Sat, Jul 12, 2003 at 02:43:18PM -0500, Mike Flannigan wrote: > OK, I'm a real newbie, but even I am ashamed to be asking this. > I want to search for a vertical mark ( | ) and replace it with > something else (h). That's all - nothing fancy. What am I doing > wrong here: > > use strict; > use

RE: Search and Replace

2003-07-13 Thread Tim Johnson
There's one caveat to be aware of with doing a "@array = " type of file read. If you end up having to work with very large files (or you don't have a whole lot of RAM to work with), you could be slowing down your program, maybe drastically if you try to load the entire file into memory at once,

Re: Search and Replace

2003-07-13 Thread Mike Flannigan
> This should be: > > open (HANDLE, $listelem) or die "open: $listelem: $!"; > > That way if the open fails for any reason you'll get a sensible > error message. (And it avoids the race condition.) > Thank you. This is about the 6th version I have tried for this command, and I like this one

Re: Search and Replace

2003-07-13 Thread Jeff 'japhy' Pinyan
On Jul 13, Mike Flannigan said: >> s/\|/h/g foreach @filecontents; >> > >Works like a charm. I sure appreciate your help. > >It's going to take me a few years to figure out (even generally) >what all these commands are doing. Sure is an intriguing >language. Then here's another operator to le

Re: Search and Replace

2003-07-13 Thread Mike Flannigan
Tim Johnson wrote: > There's one caveat to be aware of with doing a "@array = " type > of file read. If you end up having to work with very large files (or you > don't have a whole lot of RAM to work with), you could be slowing down your > program, maybe drastically if you try to load the entir

Re: Search and Replace

2003-07-13 Thread Mike Flannigan
Jeff 'japhy' Pinyan wrote: > On Jul 13, Mike Flannigan said: > > >> s/\|/h/g foreach @filecontents; > >> > > > >Works like a charm. I sure appreciate your help. > > > >It's going to take me a few years to figure out (even generally) > >what all these commands are doing. Sure is an intriguing

Re: Search and Replace

2003-07-13 Thread Jeff 'japhy' Pinyan
On Jul 13, Mike Flannigan said: >> tr/|/h/ for @filecontents; >> >> That transliterates ALL |'s to h's, for each string in @filecontents. > >Yeah, I was trying to figure out the difference from s///. I guess it >returns the number of characters replaced (or deleted), as opposed >to the number o

RE: search and count

2003-07-16 Thread Marcos . Rebelo
call this script like perl script.pl File_name.txt perl script.pl < File_name.txt more File_name.txt | perl script.pl my $count=0; while (<>){ $count++ if /VIOLATE/; } print $count; Must work -Original Message- From: Boon Chong Ang [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16,

RE: search and count

2003-07-16 Thread Boon Chong Ang
Marcos, Thanks a lot! Best regards, ABC -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 16, 2003 4:36 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: search and count call this script like perl script.pl File_name.txt perl script.pl

Re: search and match

2003-07-25 Thread Rob Dixon
> > "Boon Chong Ang" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > ismsg03.altera.priv.altera.com... > Hi, > Just say i have a variable being assigned as follow, > > $a = abc/edf/a > > i want it to search from another file for the file that contains > exactly the same words, what

RE: search and match

2003-07-25 Thread NYIMI Jose (BMB)
I think he is missing quotes while assigning. $a = abc\/edf\/a #is wrong ! José. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Friday, July 25, 2003 1:52 PM To: [EMAIL PROTECTED] Subject: Re: search and match > > "Boon Chong Ang" <[EMAIL P

Re: search and match

2003-07-25 Thread Rob Dixon
Nyimi Jose wrote: > I think he is missing quotes while assigning. > $a = abc\/edf\/a #is wrong ! > > José. > But even without warnings enabled so he should get a division by zero error! I'm sure we'll find out... :) Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e

Re: search an replace

2004-01-22 Thread Steve Grazzini
rmck wrote: But I run this system call and it took allnight to run :( You were asking perl to rewrite the whole file for every line you wanted to change. #!/usr/bin/perl use strict; use warnings;# or just use Foo::Monkey :-) use POSIX qw(strftime); die "Usage: $0 FILES\n

Re: search an replace

2004-01-22 Thread James Edward Gray II
On Jan 22, 2004, at 10:13 AM, rmck wrote: Hi Hello. This scripts sucks in a 109mb file and i'm trying to do a search and replace on unxtime to the format from strftime. Which is working... But I run this system call and it took allnight to run :( So I killed it... Any other suggestions to rea

RE: search an replace

2004-01-22 Thread Dan Muey
> Hi > > This scripts sucks in a 109mb file and i'm trying to do a > search and replace on unxtime to the format from strftime. > Which is working... > > But I run this system call and it took allnight to run :( > > So I killed it... Any other suggestions to reach my goal. > > Yes

RE: search an replace

2004-01-22 Thread Bob Showalter
Steve Grazzini wrote: > rmck wrote: >> But I run this system call and it took allnight to run :( > > You were asking perl to rewrite the whole file for every line > you wanted to change. > > #!/usr/bin/perl > use strict; > use warnings;# or just use Foo::Monkey :-) > >

RE: Search and Replace

2004-07-26 Thread Charles K. Clarkson
Mallik <[EMAIL PROTECTED]> wrote: : I have the below string. : : $str = "iabd a bdkf a kdfkj akdfakjkf"; : : I want to replace all the 'a' s prceeded and : followed by spaces with 'A'. : : The output should be like this : : $str = "iabd Abdkf A kdfkj akdfakjkf"; : : Any easy reg exp?

RE: search and match

2003-07-27 Thread Boon Chong Ang
ECTED] Subject: Re: search and match > > "Boon Chong Ang" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > ismsg03.altera.priv.altera.com... > Hi, > Just say i have a variable being assigned as follow, > > $a = abc/edf/a > > i wa

RE: search and match

2003-07-27 Thread simran
h it from other file and modify the content which is located on the > same line. > Such as > Mhd abc/edf > > To > Mhabcd abc/edf > > Thank you & best regards, > ABC > > > > -Original Message----- > From: Rob Dixon [mailto:[EMAIL PROTECTED

RE: Search & Replace Issue

2002-04-09 Thread Hanson, Robert
I'm sure that this can be done is less steps, but it works... #!/usr/bin/perl -w use strict; my $line = " stuff\n"; print chgSpace($line); sub chgSpace { my $line = shift; my ( $spaces ) = $line =~ /^(\s+)/; $spaces =~ s/ /_/g; $line =~ s/^\s+/$spaces/; return $line; }

Re: Search & Replace Issue

2002-04-09 Thread bob ackerman
On Tuesday, April 9, 2002, at 09:39 AM, Kristin A. I. wrote: > I am trying to indent a scroll-thru menu which has been made into a tree > using the following database query: > select dept_id, LPAD(' ',2*(Level-1))||dept_name dept_name > from depts > start with dept_id = 1 > connect by

Re: Search & Replace Issue

2002-04-09 Thread John W. Krahn
"Kristin A. I." wrote: > > I am trying to indent a scroll-thru menu which has been made > into a tree using the following database query: > select dept_id, LPAD(' ',2*(Level-1))||dept_name dept_name > from depts > start with dept_id = 1 > connect by dept_parent = PRIOR dept_id; > My probl

Re: Search matching problems

2001-10-29 Thread Andrea Holstein
Robert Thompson wrote: > ... > > for (my $i = 0; $i < @mess_order; ++$i) { > if ($mess_order[$i] =~ /^$remove$/i) { > $pos = $i; > } > } > > ... > There are about eighty e-mails that I am testing with, and all the ones that have >the problem are ones with a $ in the Message-ID

Re: search and replace

2008-11-12 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > Hi I am new to this group and to Perl. > > I am having trouble with searching and replacing a pattern in a file > and then > copying to a new file. I am trying to write an interactive program to > do this > where I input the file name for the search and replace and the

Re: search and replace

2008-11-12 Thread Chas. Owens
On Tue, Nov 11, 2008 at 09:52, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi I am new to this group and to Perl. > > I am having trouble with searching and replacing a pattern in a file > and then > copying to a new file. I am trying to write an interactive program to > do this > where I input

Re: search and replace

2008-11-12 Thread Jay Savage
On Tue, Nov 11, 2008 at 9:52 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi I am new to this group and to Perl. > [snip] > #!/usr/bin/perl -w > use strict; > If you really have warnings enabled, you should be seeing lots of warnings like "bareword found where operator expected" pointing a

Re: search and replace

2008-11-13 Thread [EMAIL PROTECTED]
On Nov 12, 6:55 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > [EMAIL PROTECTED] wrote: > > Hi I am new to this group and to Perl. > > > I am having trouble with searching and replacing a pattern in a file > > and then > > copying to a new file.  I am trying to write an interactive program to > > do th

Re: search and replace

2008-11-13 Thread Mr. Shawn H. Corey
On Wed, 2008-11-12 at 13:00 -0800, [EMAIL PROTECTED] wrote: > I think I understand most of your suggestions but I'm not very clear > in this line: > > print $out $_;# in the while loop below. > > while (<$in>) { > s/\Q$search/$replace/g; > print $out $_; > > > What is the $_ variable? Th

Re: search and replace

2008-11-13 Thread [EMAIL PROTECTED]
On Nov 12, 6:55 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > [EMAIL PROTECTED] wrote: > > Hi I am new to this group and to Perl. > > > I am having trouble with searching and replacing a pattern in a file > > and then > > copying to a new file.  I am trying to write an interactive program to > > do th

RE: Search and Replace

2007-07-11 Thread Moon, John
From: Joseph L. Casale [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 11, 2007 1:51 PM To: beginners@perl.org Subject: 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 ju

Re: Search and Replace

2007-07-11 Thread Paul Lalli
On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > 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 o

RE: Search and Replace

2007-07-11 Thread Joseph L. Casale
PM To: beginners@perl.org Subject: Re: Search and Replace On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > 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

Re: Search and Replace

2007-07-11 Thread Rob Dixon
Joseph L. Casale wrote: 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

RE: Search and Replace

2007-07-11 Thread Joseph L. Casale
hanks! jlc -Original Message- From: Paul Lalli [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 11, 2007 12:30 PM To: beginners@perl.org Subject: Re: Search and Replace On Jul 11, 1:50 pm, [EMAIL PROTECTED] (Joseph L. Casale) wrote: > Hi, > Know that I am learning perl, I am expected t

Re: Search and Replace

2007-07-11 Thread Mr. Shawn H. Corey
Joseph L. Casale wrote: Paul, Reading the perlre doc I am starting to understand this line: $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/; I have a few questions. 1. What is the tilde for? From `perldoc perlop`: Binding Operators Binary "=~" binds a scalar expression to a patte

RE: Search and Replace

2007-07-12 Thread Joseph L. Casale
: Wednesday, July 11, 2007 4:52 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Re: Search and Replace Joseph L. Casale wrote: > Paul, > Reading the perlre doc I am starting to understand this line: > $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/; > > I have a few questions. &

Re: Search and Replace

2007-07-12 Thread Rob Dixon
Joseph L. Casale wrote: How can I make this expression: $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/ Add some numerical value to the Z$3 part, so if $3 was 3.14, I want it to be Z4.14 for example by adding 1 to it. May I reply amending my original solution to your problem, which seems to me

RE: Search and Replace

2007-07-12 Thread Joseph L. Casale
Ok Rob, I'll have a look. Thanks! jlc -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Thursday, July 12, 2007 1:22 PM To: beginners@perl.org Cc: Joseph L. Casale Subject: Re: Search and Replace Joseph L. Casale wrote: > > How can I make this expression: &

Re: Search and Replace

2007-07-12 Thread Chas Owens
On 7/12/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: Hi All, How can I make this expression: $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2 Z$3/ Add some numerical value to the Z$3 part, so if $3 was 3.14, I want it to be Z4.14 for example by adding 1 to it. Use the e option to turn the replace

RE: Search and Replace

2007-07-13 Thread Joseph L. Casale
One of these scripts has a loop like this: for my $line (@lines){ my $line2 = $line; $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/; print FILEOUT $line; $line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/; print FILEOUT $line2; print FILEOUT "M98PDRILL.SUBL1\n"; print FILEOUT "G90\n"; print FILEOUT

Re: Search and Replace

2007-07-13 Thread Tom Phoenix
On 7/13/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: What would be a wise way of trapping a condition such as the line read and passed into the loop is not 3 sets of numbers and if so, skip? Use the 'next' operator. It's documented in perlfunc. Hope this helps! --Tom Phoenix Stonehenge P

Re: Search and Replace

2007-07-13 Thread Rob Dixon
Joseph L. Casale wrote: One of these scripts has a loop like this: for my $line (@lines){ my $line2 = $line; $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/; print FILEOUT $line; $line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/; print FILEOUT $line2; print FILEOUT "M98PDRILL.SUBL1\n"; print FILEOU

Re: Search and Replace

2007-07-13 Thread Rob Dixon
Joseph L. Casale wrote: One of these scripts has a loop like this: for my $line (@lines){ my $line2 = $line; $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/; print FILEOUT $line; $line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/; print FILEOUT $line2; print FILEOUT "M98PDRILL.SUBL1\n"; print FILEOU

RE: Search and Replace

2007-07-13 Thread Joseph L. Casale
$!; So using your syntax escapes me at the moment:) Thanks! jlc -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Friday, July 13, 2007 7:09 PM To: beginners@perl.org Cc: Joseph L. Casale Subject: Re: Search and Replace Joseph L. Casale wrote: > One of these scripts has a loop

Re: Search and Replace

2007-07-13 Thread Chas Owens
On 7/13/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: snip open (FILEIN, "< $ARGV[0]") or die $!; my @lines = ; snip In list context the <> operatot returns all lines, but in scalar context it returns on line at a time. This can be used with a while loop to walk over the file in pieces (a ne

Re: Search and Replace

2007-07-14 Thread Rob Dixon
Joseph L. Casale wrote: From: Rob Dixon Joseph L. Casale wrote: One of these scripts has a loop like this: for my $line (@lines){ my $line2 = $line; $line =~ s/(\S+)\s+(\S+)\s+(\S+)/X$1 Y$2/; print FILEOUT $line; $line2 =~ s/(\S+)\s+(\S+)\s+(\S+)/Z[$3+DPad]/; print FILEOUT $line2; prin

Re: Search and Replace

2007-07-14 Thread Dr.Ruud
"Chas Owens" schreef: > print $out > "X$x Y$y\n", > "Z[$z+DPad]\n", > "M98PDRILL.SUBL1\n", > "G90\n", > "G00 Z[CPlane]\n"; > > Never use multiple print statements when you can use just one. In general that's true, but because of the "Never" I have to ob

Re: Search and Replace

2007-07-14 Thread Mr. Shawn H. Corey
Joseph L. Casale wrote: OK, I saw your example and noted it. I intended on using next time as I know there will be:) But now I am convinced, as the lack of error checking in my script worries me. I'll take yours and fit it in! I do need to read up on what you're doing as I am not clear on its

Re: Search and Replace

2007-07-14 Thread Chas Owens
On 7/14/07, Dr.Ruud <[EMAIL PROTECTED]> wrote: snip > Never use multiple print statements when you can use just one. In general that's true, but because of the "Never" I have to object. :) Sometimes multiple print statements look like only one, I am thinking of the "print for LIST" construct.

Re: Search and Replace

2007-07-14 Thread Mr. Shawn H. Corey
Chas Owens wrote: By the way, an easier way to write the join version is print map { "$_\n" } @list; BTW, that's not the same. Join inserts its string between each element, map (in this case) appends it to the end. A subtle difference that may lead to confusion and errors. -- Just my 0

Re: Search and Replace

2007-07-14 Thread Chas Owens
On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Chas Owens wrote: > By the way, an easier way to write the join version is > > print map { "$_\n" } @list; > BTW, that's not the same. Join inserts its string between each element, map (in this case) appends it to the end. A subtle diff

Re: Search and Replace

2007-07-14 Thread Mr. Shawn H. Corey
Chas Owens wrote: The code I am referring to is print +(join "\n", @LIST), "\n" ; Which does the same thing as print map { "$_\n" } @list; The only difference between them is if $, is set. True, in this case they are. But the way you stated your preferences implied they are the same, or a

Re: Search and Replace

2007-07-14 Thread Rob Dixon
Chas Owens wrote: On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Chas Owens wrote: By the way, an easier way to write the join version is print map { "$_\n" } @list; BTW, that's not the same. Join inserts its string between each element, map (in this case) appends it to the e

Re: Search and Replace

2007-07-14 Thread Rob Dixon
Rob Dixon wrote: Chas Owens wrote: On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: Chas Owens wrote: By the way, an easier way to write the join version is print map { "$_\n" } @list; BTW, that's not the same. Join inserts its string between each element, map (in this case)

Re: Search and Replace

2007-07-14 Thread Chas Owens
On 7/14/07, Rob Dixon <[EMAIL PROTECTED]> wrote: Chas Owens wrote: > > On 7/14/07, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote: >> >> Chas Owens wrote: >>> >>> By the way, an easier way to write the join version is >>> >>> print map { "$_\n" } @list; >>> >> >> BTW, that's not the same. Join ins

  1   2   3   4   >