Operating System - HP-UX
1752760 Members
4864 Online
108789 Solutions
New Discussion юеВ

Re: Update a word in a line

 
James R. Ferguson
Acclaimed Contributor

Re: Update a word in a line

Hi (again):

> Can you tell me what was wrong in the first code?

As I said, you never wrote to anything other than STDOUT. Remember you can 'select()' a default filehandle or explicitly use one but you did neither. The '/e' modifier in your regex whould have been '/g'. You were attempting to evaluate and execute while substituting and there was nothing legal in what you wrote.

> And secondly the number of files will be huge,maybe like 3-4lakhs.So will @ARGV have any issue?

No, this should not be an issue.

By the way, what does "lakhs" stand for? You have used that term before.

Regards!

...JRF...
pgp_acc1
Advisor

Re: Update a word in a line

I still didn't get it. :(

1 lakh = 100,000
Dennis Handly
Acclaimed Contributor

Re: Update a word in a line

>JRF: what does "lakhs" stand for?

You didn't remember when I asked that question? :-)

Basically the OP should stick with SI units or actual numbers or scientific notation.
pgp_acc1
Advisor

Re: Update a word in a line

James,
It worked after these changes, can you tell me if these are correct?

foreach $event (@files) {
my $backup=$event.".bak";
open(MYFILE,"<$backup")|| die "cant find it";;
open(MYFILE1,"<$event")|| die "cant find it";;

while () {
if (/^not/) {
($line=$_) =~ s/OCAL/OWN/e;
print MYFILE $line;
}
else { print MYFILE $_; }
}
close(MYFILE);
}
Patrol
Advisor

Re: Update a word in a line

>JRF: what does "lakhs" stand for?

>Dennis: Basically the OP should stick with SI units or actual numbers or scientific notation.

Funny, really funny.I think neither of you have read the memo, perttaining to renaming the ITRC.

...
From now on, the website formerly known as Information Technology Response Center, a.k.a., ITRC, will be renamed as

Indian Tech Rescue Center

We are hoping that, keeping the same abbreviation, will help you adapt the change faster and better.
...


A simple wikipedia search would show you the meaning of word lakh being a hundred thousand. If you have noticed the majority of the names floating around ITRC nowadays, it is expected by the original poster of the question that everyone should understand the Indian terminology, despite how prudish t expectation sounds.

Viva globalism !
James R. Ferguson
Acclaimed Contributor

Re: Update a word in a line

Hi (again):

> It worked after these changes, can you tell me if these are correct?

Yes, I know it worked --- I tested it too.

Your suggestion will _not_ work. You didn't read what I said about the '\e' modifier. You open both files for input.

If you would get in the habit of using the 'strict' and 'warnings' pragmas you will catch many stupid errors the first time you attempt to run your script:

use strict;
use warnings;

Add these and make the necessary changes.

By the way, thanks Dennis & Patrol. I should have known Dennis that you would have asked that too :-) --- You and I do think alike.

Regards!

...JRF...