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>