Hi Susan,
This question was not related to dbi-users, and should really have been
asked on a more generic perl support list. The answer is also in the
all the perl tutorials and even in perldoc. There are email lists
dedicated to teaching perl. That is where a question like this should
have been asked, after you are sure you have read all the relevant
tutorials.
No one mentioned this to you because the answer was so obvious it was
quicker to just give you your answer. I mention it now, just to remind
you and other possibly newer subscribers to this list that this list is
specifically for perl DBI interface questions and issude, not generic
help with perl. When the two become intertwined it is less clear, but
in this case, it was obviously a pure perl question that had nothing to
do with the DBI.
In the future, you will be better served if you consider carefully the
intent of the list on which you pose questions.
Enjoy perl. Its a wonderful language.
Lincoln
On Sun, 2005-02-27 at 06:33 -0800, susan lam wrote:
> 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
>