Great! Thanks for the solution and suggestion.
susan
--- Jon Lapham <[EMAIL PROTECTED]> wrote:
> Jon Lapham wrote:
> > susan lam wrote:
> >
> >> How can I modify my subroutine to parse file2 by
> >> skipping those '#'?
> >> file2:
> >> #
> >> # Usage: <variable>=<value>
> >> #
> >> userid=apps
> >> userpwd=appspwd
> >> database=mydb
> >>
> >> sub mysub {
> >> open(PFILE,$ARGV[0]) || die ("Could not
> open
> >> file");
> >> @pf=<PFILE>;
> >> foreach $param (@pf) {
> >
> >
> > next if (/^#/);
>
> Oops, of that should say:
> next if ($param =~ /^#/);
>
> >> chop($param);
> >> my
> ($pname,$pval)=split(/=/,$param);
> >> $ary{$pname}=$pval;
> >> }
> >> close(PFILE);
> >> }
>
> PS: you do not need to read the file into an array
> before working on it.
> In fact, that will read the whole file into
> memory. I guess this is
> not a problem for this example since the files are
> small...
>
> You could try this, which will process the data
> files one line at a time.
>
> sub mysub {
> open PFILE, $ARGV[0] or die "Could not open
> file";
> while (<PFILE>) {
> next if (/^#/);
> ($pname,$pval)=split(/=/,$_);
> $ary{$pname}=$pval;
> }
> close PFILE;
> }
>
> --
>
-**-*-*---*-*---*-*---*-----*-*-----*---*-*---*-----*-----*-*-----*---
> Jon Lapham <[EMAIL PROTECTED]> Rio
> de Janeiro, Brasil
> Personal: http://www.jandr.org/
>
***-*--*----*-------*------------*--------------------*---------------
>
>
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo