Re: Perl file handling

2011-09-23 Thread Uri Guttman
> "M" == Maggs writes: M> sub read_file{ M> local ($filevar) = @_; don't use local for that (or for much else). use my. local is meant now only for special cases with dynamic scoping. M> <$filevar>; M> } why do you need a whole sub to read a line? just <$filevar> does the

Re: Perl file handling

2011-09-23 Thread Maggs
On Sep 23, 1:54 am, 2teezp...@gmail.com (timothy adigun) wrote: > Hello Maggs, > > >> KS >Ken Slater wrote: > > KS>>OP was using trying to use 'open_file' to open one file handle at a > time. > KS>>Arguments were presumably the file handle variable, mode, and  file > name. > KS>>Your examp

Re: Perl file handling

2011-09-22 Thread timothy adigun
Hello Maggs, >> KS >Ken Slater wrote: KS>>OP was using trying to use 'open_file' to open one file handle at a time. KS>>Arguments were presumably the file handle variable, mode, and file name. KS>>Your example is very different. I think 'KS' got the heart of what you really want, and i

Re: Perl file handling

2011-09-22 Thread Brandon McCaig
On Thu, Sep 22, 2011 at 11:09 AM, John W. Krahn wrote: > Brandon McCaig wrote: >>       open @_ or die "Can't open '$filename': $!"; > > That won't work as the first argument to open is forced into scalar context > > $ perl -le'print prototype "CORE::open"' > *;$@ > > so if @_ contains three eleme

RE: Perl file handling

2011-09-22 Thread Ken Slater
> -Original Message- > From: timothy adigun [mailto:2teezp...@gmail.com] > Sent: Thursday, September 22, 2011 2:05 PM > To: Maggs > Cc: beginners@perl.org > Subject: Re: Perl file handling > > Hi Maggs, > > I don't know what you really wan

Re: Perl file handling

2011-09-22 Thread timothy adigun
Hi Maggs, I don't know what you really wants to achieve with your codes below: (open...) sub open_file { local $/ = undef; ($filevar, $filemode, $filename) = @_; open ($filevar, $filemode . $filename) || die ("Can't open $filename"); } everytime i run it i get the error: Can't use string ("FILE1

Re: Perl file handling

2011-09-22 Thread Leo Lapworth
On 22 September 2011 09:54, Maggs wrote: > am trying to open a file but the problem is on the third line > (open...) > > sub open_file { > local $/ = undef; > ($filevar, $filemode, $filename) = @_; > open ($filevar, $filemode . $filename) || die ("Can't open > $filename"); > } Are you ok instal

Re: Perl file handling

2011-09-22 Thread John W. Krahn
Brandon McCaig wrote: On Thu, Sep 22, 2011 at 4:54 AM, Maggs wrote: ($filevar, $filemode, $filename) = @_; open ($filevar, $filemode . $filename) || die ("Can't open $filename"); } everytime i run it i get the error: Can't use string ("FILE1") as a symbol ref while "strict refs" in use. $file

Re: Perl file handling

2011-09-22 Thread Brandon McCaig
On Thu, Sep 22, 2011 at 4:54 AM, Maggs wrote: > ($filevar, $filemode, $filename) = @_; > open ($filevar, $filemode . $filename) || die ("Can't open > $filename"); > } > everytime i run it i get the error: Can't use string ("FILE1") as a > symbol ref while "strict refs" in use. $filevar probably c