Goksie wrote:
> Tommy Nordgren wrote:
>>On 20 okt 2006, at 21.31, Goke Aruna wrote:
>>
>>>On 10/20/06, John W. Krahn <[EMAIL PROTECTED]> wrote:
>>>>Goksie wrote:
>>>>>
>>>>>Can someone advice me on how i can open .dat file in perl script?
>>>>open my $fh, '<', '00016367.DAT' or die "Cannot open '00016367.DAT'
>>>>$!";
>>>
>>>Each time i used it that way its giving me
>>>
>>>GLOB(0x22519c)
>>>
>>    This might occur because you are trying to print the file handle
>>instead of reading FROM it.
> 
> the code is as follow
> 
> #!c:/perl/bin/perl
>  use warnings ;
>  use strict ;
>  my $fl = "c:/Perl/CDR_MSC_DAT/00016363.DAT";
>  { local ($\) = ("\n") ;
>   open my $fh, '<', $fl or die "open '$fl': $!" ;

You are opening the file READONLY (the second argument '<').


>   while (<$fh>)

This is fine, you are allowed to read from the $fh filehandle.


>   {
>     print $fh;

You can't print to the filehandle because it is READONLY.  You probably want
to print the contents of the $_ variable:

      print $_;


>   }
>       }
> 
> the output is
> perl fdmacdr.pl
> GLOB(0x225218)
> GLOB(0x225218)
> GLOB(0x225218)
> its not a music file... cos another program though proprietary has
> opened it.


John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to