On Sat, Feb 18, 2012 at 12:53 AM, Shawn H Corey <shawnhco...@gmail.com> wrote:
> On 12-02-17 11:43 AM, lina wrote:
>>
>> #!/usr/bin/perl
>>
>> use warnings;
>> use strict;
>>
>> my $file = "try.xpm";
>>
>> open my $fh, "<$file" or die "could not open $file: $!\n";
>
>
> Use the three argument open, please:
>
>    open my $fh, '<', $file or die "could not open $file: $!\n";

Thanks, here  why you use '<', not "<"

>
>>
>> while (my $xpm_file = my<$fh>) {
>
>
> The second "my" causes the errors. Just remove it. And since this line is
> invalid, $xmp_file does not get declared and you get an error about it. It
> should go away when you correct the other error.

Thank, it can read the file,

I am going to proceed to the next step to read the first 4 lines into
a dictionary and translate the last line.

Best regards, thanks all

>
>
>>        print $xpm_file;
>> }
>>
>>
>> It showed me:
>>
>> $ ./translate.pl
>> syntax error at ./translate.pl line 10, near "my<$fh>"
>> Global symbol "$xpm_file" requires explicit package name at
>> ./translate.pl line 11.
>> Execution of ./translate.pl aborted due to compilation errors.
>>
>> Something is related to the strict again?
>
>
> No, it's a syntax error.
>
>
>>
>> How do you save time when you build a new script by avoiding typing the
>> Now:
>> #!/usr/bin/perl
>>
>> use warnings;
>> use strict;
>>
>> head -4 old.pl>  new.pl ?
>
>
> Create a file called template.pl with the first 4 lines. Then copy it to a
> new name for the new script.
>
> My template file is a bit more complicated since I like to use Data::Dumper
>
> #!/usr/bin/env perl
>
> use strict;
> use warnings;
>
> use Data::Dumper;
>
> # Make Data::Dumper pretty
> $Data::Dumper::Sortkeys = 1;
> $Data::Dumper::Indent   = 1;
>
> # Set maximum depth for Data::Dumper, zero means unlimited
> local $Data::Dumper::Maxdepth = 0;
>
>
>
>
> --
> Just my 0.00000002 million dollars worth,
>  Shawn
>
> Programming is as much about organization and communication
> as it is about coding.
>
> It's Mutual Aid, not fierce competition, that's the dominate
> force of evolution.  Of course, anyone who has worked in
> open source already knows this.
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to