John W. Krahn wrote:
> 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
>   


Hello,

after i had acted as  suggested to print the right file.
I have changed my code to
#!perl
 use warnings ;
 use strict ;
 my $fl = "c:/Perl/CDR_MSC_DAT/00016363.DAT";
 { local ($\) = ("\n") ;
  open my $fh, '<', $fl or die "open '$fl': $!" ;
  while (<$fh>)
  {
    print $_ ;
 }
    }

*i have the output is as
attached*                                                                       
            


thanks all,

goksie

C:\Perl>perl cdmacdr.pl
                                                                                          
                                              00016353DAT
  ^ é:5:5☺ ç⌐75?+⌡;☻ 00016354DAT
 ¥ é:5:5☺ ╟¬75c+`H☻ 00016355DAT  ½ é:5:5¼75ê+≥·☺ 00016356DAT  
░ é:5:5☺ I¡75¿+♣ñ☺ 00016357D
AT  ▒ é:5:5☺ ë«75├+╞k☺ 00016358DAT  ╢ é:5:5☺ J░75┌+a&☺ 
00016359DAT  ╣ é:5:5☺ è▒75φ+÷↓☺ 000
,▓│  00016362DAT  ┴ é:5:5☺ L╡75↓,²y  00016363DAT  ♣☺é:5:5☺ 
£╢75!,¢u  00016364DAT  D☺é:5:5☺
 \╕75),9q  00016365DAT  O☺é:5:5☺ ¥╣751,Xc  00016366DAT  R☺é:5:5☺ 
ε║758,↨>  00016367DAT  S☺
é:5:5☺ /╝75<,╘+  00016368DAT  W☺é:5:5☺ o╜75?,╔6  00016369DAT  
Z☺é:5:5☺ ░╛75C,r'


                       LSÇ☺☻♥♦

♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 
!"#$%&'()*+,-./0123456789:;<=>[EMAIL PROTECTED] XYZ[\]^_`abcdefg
hijklmnopqrstuvwxyz{|}~⌂W   
                             P                                
                                                                                          

                                                                                          
                                          00016353DAT
  ^ é:5:5☺ ç⌐75?+⌡;☻ 00016354DAT  ¥ é
:5:5☺ ╟¬75c+`H☻ 00016355DAT  ½ é:5:5¼75ê+≥·☺ 00016356DAT  ░ 
é:5:5☺ I¡75¿+♣ñ☺ 00016357DAT
▒ é:5:5☺ ë«75├+╞k☺ 00016358DAT  ╢ é:5:5☺ J░75┌+a&☺ 
00016359DAT  ╣ é:5:5☺ è▒75φ+÷↓☺ 0001636
,▓│  00016362DAT  ┴ é:5:5☺ L╡75↓,²y  00016363DAT  ♣☺é:5:5☺ 
£╢75!,¢u  00016364DAT  D☺é:5:5☺
 \╕75),9q  00016365DAT  O☺é:5:5☺ ¥╣751,Xc  00016366DAT  R☺é:5:5☺ 
ε║758,↨>  00016367DAT  S☺
é:5:5☺ /╝75<,╘+  00016368DAT  W☺é:5:5☺ o╜75?,╔6  00016369DAT  
Z☺é:5:5☺ ░╛75C,r'
              
                                                         

                                                                                          
                                                                                          
                                                                                          
                       LSÇ☺☻♥♦

♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ 
!"#$%&'()*+,-./0123456789:;<=>[EMAIL PROTECTED] XYZ[\]^_`abcdefg
hijklmnopqrstuvwxyz{|}~⌂W   
                             P                                
-- 
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