Re: Replace pattern with a variable num of spaces

2009-06-17 Thread John W. Krahn
Steve Bertrand wrote: John W. Krahn wrote: Steve Bertrand wrote: [ snip ] In the third line of the following code, I want the replacement pattern to be (whitespace * $_[1]). I'll deal with the undef issue after I figure out how to use {$num} on essentially nothing. I haven't been able to make

Re: Replace pattern with a variable num of spaces

2009-06-17 Thread Steve Bertrand
John W. Krahn wrote: > Steve Bertrand wrote: [ snip ] >> In the third line of the following code, I want the replacement pattern >> to be (whitespace * $_[1]). I'll deal with the undef issue after I >> figure out how to use {$num} on essentially nothing. I haven't been able >> to make it work with

Re: Replace pattern with a variable num of spaces

2009-06-17 Thread John W. Krahn
Steve Bertrand wrote: I'm attempting to write a patch for a module that I feel I can use within one of my own modules, and I've run into something that I can't solve (I can't come up with the proper query in Google). Perhaps code will help here. First, I know 'word' does not include whitespace,

Replace pattern with a variable num of spaces

2009-06-17 Thread Steve Bertrand
I'm attempting to write a patch for a module that I feel I can use within one of my own modules, and I've run into something that I can't solve (I can't come up with the proper query in Google). Perhaps code will help here. First, I know 'word' does not include whitespace, and I know that one shou

RE: CGI query

2009-06-17 Thread David Christensen
Rajini Naidu wrote: > I am new to CGI scripting. Get this book and work your way through it (I prefer Debian GNU/Linux): http://www.wiley.com/legacy/compbooks/stein/ HTH, David -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@p

Re: Exception error in perl code

2009-06-17 Thread Jim Gibson
On 6/16/09 Tue Jun 16, 2009 9:14 PM, "Rajini Naidu" scribbled: > Hi, > > > I have the following code in my program. > > use strict; > use warnings; > use diagnostics; > use Time::Local; > > my @match_list; > my $days1 = ""; > my $days2 = ""; > my $day = ""; > > > > if ($failtag eq "Compi

Re: file handle in perl

2009-06-17 Thread Telemachus
On Wed Jun 17 2009 @ 3:42, Ajay Kumar wrote: > Hi Irfan > You can do all four task like below > > 1: open FILE ,">filename.txt" or die$!; > 2: my @lines= > 3: do changes through sed > Like sed -e 's/original pattern/new pattern/p' filename > 4:if you did changes it automatically get saved

Re: regular expression help

2009-06-17 Thread John W. Krahn
Irfan Sayed wrote: Hi All, Hello, need help on regular expression. i have string like this "ProductName" = "8:EXFO RTU System 1.2.42" now i want regular expression in such a way that it will change the line to : "ProductName" = "8:EXFO RTU System 1.2.43" $ perl -le' $_ = q["ProductNa

Re: AW: AW: file handle in perl

2009-06-17 Thread Aimee Cardenas
There's actually even a perl function called "rename" that does just this. Here's some good reading for you. Maybe from there you can look up other stuff when you have questions. http://perldoc.perl.org/functions/rename.html Aimee Mostella Cardena

AW: AW: file handle in perl

2009-06-17 Thread Thomas Bätzler
Irfan Sayed wrote: > OK. fine > now i am able to write in a temp. file > > after this now i want to overwrite the contents of original file with the > contents of temp. file. > why i want the original file because i want to use this original file > with changes in temp. file in my further build s

Re: AW: file handle in perl

2009-06-17 Thread Irfan Sayed
OK. fine now i am able to write in a temp. file after this now i want to overwrite the contents of original file with the contents of temp. file. why i want the original file because i want to use this original file with changes in temp. file in my further build steps please advice Regards I

POD, and coding techniqes

2009-06-17 Thread Steve Bertrand
Hi all, One of the things that came out of my last thread was my lack of documentation, so now I'm keeping the documentation up-to-date as I make code changes. I'm trying to come up with a decent layout for this. Tentatively, it looks like [1]. Does this appear to be acceptable? Could you recomme

AW: file handle in perl

2009-06-17 Thread Thomas Bätzler
Irfan Sayed asked: > i am still not able to modify existing lines in the existing file. > here is my code > plz help It doesn't work that way. Once you open the file for writing, it's truncated and you can't read the old contents from it anymore. Why don't you use a temporary new file for the o

regular expression help

2009-06-17 Thread Ajay Kumar
It works for all Just get any no after two (.) dot For that regex would be My $line="\"ProductName\" = \"8:EXFO RTU System 1.2.42\""; my ($lastvalue)=$line=~ m/\d+.\d+.(\d+)\"/; $lastvalue will give you value after two dot Increment it by one and then replace it by old value from the line It wor

Re: file handle in perl

2009-06-17 Thread Irfan Sayed
hi all, i am still not able to modify existing lines in the existing file. here is my code plz help use strict; use warnings; use Cwd; my $chver; my $fina; my @lines; &chversion(); sub chversion {   print STDERR "Current directory is " . cwd() . "\n";   print "Reading version file\n"; open (VER, "

Re: regular expression help

2009-06-17 Thread Irfan Sayed
it is not just 1.2.43 it may be anything it may be like 2.3.56 or 2.0.12 and so on... plz advice From: Ajay Kumar To: Irfan Sayed Cc: "beginners@perl.org" Sent: Wednesday, June 17, 2009 5:01:41 PM Subject: RE: regular expression help Hi Irfan This code sol

RE: regular expression help

2009-06-17 Thread Ajay Kumar
Hi Irfan This code solve your problem my $p="\"ProductName\" = \"8:EXFO RTU System 1.2.42\""; my ($val)=$p=~ m/\d+.\d+.(\d+)\"/; my $inval=$val+1; $p=~s/$val/$inval/; print"===$p\n"; thanks Ajay -Original Message- From: Irfan Sayed [mailto:irfan_sayed2...@yahoo.com] Sent: Wednesday, June

CGI query

2009-06-17 Thread Rajini Naidu
Hi , I am new to CGI scripting. I have a below query. I have one form say "xyz" with checkbox, where I am supposed to select certain options using these checkboxes. I have another form say "abc" where I am required to display the selected options from form "xyz". I have one perl module which act

regular expression help

2009-06-17 Thread Irfan Sayed
Hi All, need help on regular expression. i have string like this  "ProductName" = "8:EXFO RTU System 1.2.42"   now i want regular expression in such a way that it will change the line to :  "ProductName" = "8:EXFO RTU System 1.2.43"   i tried in the following way.     $_ =~ s/:(.*)\s(.*)\s(.*)\

Re: file handle in perl

2009-06-17 Thread Irfan Sayed
thanks all From: Ajay Kumar To: Irfan Sayed Cc: "beginners@perl.org" Sent: Wednesday, June 17, 2009 3:42:41 PM Subject: RE: file handle in perl Hi Irfan You can do all four task like below 1: open FILE ,">filename.txt" or die$!; 2: my @lines= 3: do changes

RE: file handle in perl

2009-06-17 Thread Ajay Kumar
Hi Irfan You can do all four task like below 1: open FILE ,">filename.txt" or die$!; 2: my @lines= 3: do changes through sed Like sed -e 's/original pattern/new pattern/p' filename 4:if you did changes it automatically get saved 5: close(FILE); Thanks Ajay -Original Message- Fr

Re: file handle in perl

2009-06-17 Thread Raymond Wan
Hi Irfan, Irfan Sayed wrote: I am struggling with file handling in perl. i want to do following operation . 1: open the file 2: read the file 3: do the changes in specific lines 4: save the file 5: close the file Does this FAQ help? Q: How do I change, delete, or insert a line in a file,

file handle in perl

2009-06-17 Thread Irfan Sayed
Hi All, I am struggling with file handling in perl. i want to do following operation . 1: open the file 2: read the file 3: do the changes in specific lines 4: save the file 5: close the file i am not getting which operand i should use to do this operation . i tried all operands like >, >>, <,