--- 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 <TOLL_FREE_IFILE>";
> >
> > # REPLACE STRING
> > my $repl = "/home/madhu/apps/toll.txt";
> >
> > $_=$in_str;
>
> Why do this?
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;
}
if (!(open(FH_TARGET_SCRIPT, ">$target_script")))
{
close(FH_TARGET_SCRIPT);
return 0;
}
while (<FH_SRC_SCRIPT>)
{
$replace_count +=
s/<EXPORT_IFILE>/$in_out_file_path/ if
(m/<EXPORT_IFILE>/);
$replace_count += s/<([A-Z_]+)_IFILE>/$repl/ if
(m/<([A-Z_]+)_IFILE>/);
print FH_TARGET_SCRIPT "$_";
}
>
> > # I don't want to use following, because
> > # "TOLL_FREE" will be changed each time
> > #s/<TOLL_FREE_IFILE>/$repl/;
> >
> >
> > # FOLLOWING WILL NOT WORK
> > #s/_IFILE>/$repl/;
> >
> > # FOLLOWING WILL NOT WORK
> > s/<([A-Z]+)_IFILE>/$repl/;
> >
> > # HOW TO DO THIS ?
>
> $in_str =~ s/<([A-Z_]+)_IFILE>/$repl/;
>
> And again, using a hash will allow you to change the
> replacement based
> on the contents of $1.
>
> James
>
__________________________________
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>