Re: Grep question

2008-06-05 Thread Dr.Ruud
David Gilden schreef: > my $Comments = param('(Comments'); There is an extra '(' in there that you might not want. Do you use Capitalization to show that the variable is initialised with the value of a parameter? Consider $p_comments or $param_comments or $param{Comments}. -- Affijn, Ruud "Ge

Re: sprintf format question

2008-06-05 Thread April
On Jun 4, 8:00 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > April wrote: > > sprintf( "%s%$Fmt%s", ("%$Fmt=|", $TestStr, "|")) > > > This is in Perl for Dummies, 4th ed, p160. > > > I'm trying to understand this ... > > > the first part, "%s%$Fmt%s", my understanding is the format part, > > which spe

Re: any ruby programmers who are perl users?

2008-06-05 Thread Dr.Ruud
Octavian: > Yitzle: >> 1) If you are interested in learning to program for the sake of >> programming (vs getting XYZ done), Perl probably isn't the best first >> choice. (Not that its the last choice or anything, but not first.) >> I'd personally advocate C/C++ or maybe Java. Maybe make Perl a th

Re: any ruby programmers who are perl users?

2008-06-05 Thread Octavian Rasnita
- Original Message - > Whee! Inflammatory topic! > > 1) If you are interested in learning to program for the sake of > programming (vs getting XYZ done), Perl probably isn't the best first > choice. (Not that its the last choice or anything, but not first.) I'd > personally advocate C/C++

Re: pie multiline replace

2008-06-05 Thread Richard Lee
Gunnar Hjalmarsson wrote: bill lam wrote: Sorry this must be a faq but I cannot find any answer in google. Google?? If you think it's a FAQ, you'd better check the Perl FAQ. perldoc -q "insert a line" Within that basic form, add the parts that you need to insert, change, or delete lines

Re: any ruby programmers who are perl users?

2008-06-05 Thread yitzle
Whee! Inflammatory topic! 1) If you are interested in learning to program for the sake of programming (vs getting XYZ done), Perl probably isn't the best first choice. (Not that its the last choice or anything, but not first.) I'd personally advocate C/C++ or maybe Java. Maybe make Perl a third ch

any ruby programmers who are perl users?

2008-06-05 Thread Richard Lee
Most likely just out of curiosity factor, I picked up a book "Learning to program " the facets of ruby series.. While very simple in nature, book try to teach computer programming concept while giving some ruby lesson.. Even though I am still a beginner for perl, I just wanted to pick up 2nd l

Re: pie multiline replace

2008-06-05 Thread bill lam
Rob Dixon wrote: If you think the one-liner is non-trivial then all the more reason that you should use a proper script. It is a bad idea to use any code unless you understand why and how it works. The script isn't trivial (to me) either. Incidentally the same can be done in sed one-liner. se

Re: Grep question

2008-06-05 Thread John W. Krahn
Steve Bertrand wrote: David Gilden wrote: Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained i

Re: Grep question

2008-06-05 Thread Steve Bertrand
David Gilden wrote: Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained in the $Comments. In a

Re: Grep question

2008-06-05 Thread Rob Dixon
David Gilden wrote: > > my $Comments = param('(Comments'); > &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); > > This should go to &BADemail if $Comments contains either string, regardless > else is contained in the $Comments. The answer to your question is BADemail()

Grep question

2008-06-05 Thread David Gilden
Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained in the $Comments. Thanks, Dave (kora musi

Preprocessor in Perl?

2008-06-05 Thread adarsh.s85
Hello, I have this situation wherein I have to run a perl script over pre-processed files. Eg: File "A.cfg" needs to be preprocessed to say "A" and then my perl script works on it. This preprocessing is done, as of now, by command line call of " gcc -E A.cfg > A" and then a command to run the per

Re: pie multiline replace

2008-06-05 Thread Rob Dixon
bill lam wrote: > Thomas Bätzler wrote: >> perl -i -ple '$_ = "cc\n$_" if $p =~ m/aa/ && m/bb/; $p=$_' > > Thanks. looks non-trivial for me. Anyway I will copy this idiom into my cheat > sheet. > > Thank Gunnar for suggestion too. However I prefer one-liner. If you think the one-liner is non-tr

Re: pie multiline replace

2008-06-05 Thread bill lam
Thomas Bätzler wrote: perl -i -ple '$_ = "cc\n$_" if $p =~ m/aa/ && m/bb/; $p=$_' Thanks. looks non-trivial for me. Anyway I will copy this idiom into my cheat sheet. Thank Gunnar for suggestion too. However I prefer one-liner. regard, -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additi

Re: pie multiline replace

2008-06-05 Thread Gunnar Hjalmarsson
bill lam wrote: Sorry this must be a faq but I cannot find any answer in google. Google?? If you think it's a FAQ, you'd better check the Perl FAQ. perldoc -q "insert a line" Suppose I want to change 2 lines to 3 line in files as follow using perl -p -i -e command aa bb aa cc bb this

RE: about readdir call

2008-06-05 Thread Rajnikant
Thanks Thomas... :) It helped. Thanks and Best regards, ~ Rajnikant Software Engg. Persistent Sys. Ltd. Ph. +91 98222 04088 -Original Message- From: Thomas Bätzler [mailto:[EMAIL PROTECTED] Sent: Thursday, June 05, 2008 5:50 PM To: beginners@perl.org Cc: Rajnikant Su

RE: about readdir call

2008-06-05 Thread Thomas Bätzler
Rajnikant <[EMAIL PROTECTED]> asked: > I'm reading one directory using readdir call. but I'm getting > different output from that I got by running ls -l command on > same directory manually. Following is the snippet I'm using: > #!/usr/bin/perl -w $dirname = '/test_dir'; opendir ( DIR, $dirna

about readdir call

2008-06-05 Thread Rajnikant
Hello everyone, I'm reading one directory using readdir call. but I'm getting different output from that I got by running ls -l command on same directory manually. Following is the snippet I'm using: #!/usr/bin/perl -w $dirname = "/test_dir"; opendir ( DIR, $dirname ) || die "Error in opening

RE: pie multiline replace

2008-06-05 Thread Thomas Bätzler
bill lam <[EMAIL PROTECTED]> asked: > Suppose I want to change 2 lines to 3 line in files as follow > using perl -p -i -e command aa bb > > aa > cc > bb > > this doesn't work > perl -p -i -e "s/aa\nbb/aa\ncc\nbb/g;" foo.txt That won't work since you ever only see a single line of input. Since

pie multiline replace

2008-06-05 Thread bill lam
Hello, Sorry this must be a faq but I cannot find any answer in google. Suppose I want to change 2 lines to 3 line in files as follow using perl -p -i -e command aa bb aa cc bb this doesn't work perl -p -i -e "s/aa\nbb/aa\ncc\nbb/g;" foo.txt what is the correct command (I use linux). Thanks

Re: How to replace some string in file

2008-06-05 Thread Jeff Peng
On Thu, Jun 5, 2008 at 3:09 PM, ram <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-06-05 at 12:32 +0530, Santosh Reddy wrote: >> how do i do this. thanks a lot in advance >> > perl -pli -e 's/abcd/xyz/' a.txt > or use the unix command 'sed'. -- Jeff Peng - [EMAIL PROTECTED] Professional Squid sup

Re: How to replace some string in file

2008-06-05 Thread ram
On Thu, 2008-06-05 at 12:32 +0530, Santosh Reddy wrote: > Hi All, > > I have a file called a.txt which has the following lines > > abcd > efgh > ijkl > abcd123 > 12abcd > > I want to replace abcd with xyz. > > how do i do this. thanks a lot in advance > perl -pli -e 's/abcd/xyz/' a.txt --

How to replace some string in file

2008-06-05 Thread Santosh Reddy
Hi All, I have a file called a.txt which has the following lines abcd efgh ijkl abcd123 12abcd I want to replace abcd with xyz. how do i do this. thanks a lot in advance -- Thanks & Regards, Santosh Reddy.