> "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
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
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
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
> -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
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
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
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
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