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 (!(open(FH_TARGET_SCRIPT,
">$target_script")))
        {
                print "(TERADATA.pl) generate_script::
File $target_script open failed --> $!\n";
                # close previously opened file
                close(FH_SRC_SCRIPT);
                return 0;
        }


here i am closing previously opened file...

if i want to open a file in write mode, we have to
specify ">$file" right ?

does >$file will work ?


I will drop if m/...
Thanks
-Madhu


--- James Edward Gray II <[EMAIL PROTECTED]>
wrote:
> 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 can't open() some
> file, close the 
> file (huh?), and return.  How about we simplify and
> pretty that up:
> 
> open FH_SRC_SCRIPT, $src_script or return 0;
> 
> That should do the exact same thing.  Note I didn't
> quote the variable, 
> as we don't need to.
> 
> > if (!(open(FH_TARGET_SCRIPT, ">$target_script")))
> >         {
> >                close(FH_TARGET_SCRIPT);
> >                 return 0;
> >         }
> 
> See above.
> 
> >  while (<FH_SRC_SCRIPT>)
> >         {
> >          $replace_count +=
> > s/<EXPORT_IFILE>/$in_out_file_path/       if
> > (m/<EXPORT_IFILE>/);
> >
> 
> if (m/.../) still isn't doing anything, as I've
> mentioned before.  Drop 
> it.  s/.../.../ only replaces IF it finds a match.
> 
> >    $replace_count += s/<([A-Z_]+)_IFILE>/$repl/ if
> > (m/<([A-Z_]+)_IFILE>/);
> 
> Again, drop the if m/.../.
> 
> >         print FH_TARGET_SCRIPT "$_";
> 
> No need to quote a variable here.
> 
> print FH_TARGET_SCRIPT $_;
> 
> > }
> 
> James
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 



        
                
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to