[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] What's error "chunk 7072"?



xah@best.com, mac-perl@iis.ee.ethz.ch
Subj:	[MacPerl] What's error "chunk 7072"?

>Three beginner's easy questions:
>
>Question 1:
>Can anyone tell me what the following warning means?
>
># Use of uninitialized value, <WEBLOG> chunk 7072.
>                               ^^^^^^^^^^^^^^^^^^
>
>I've checked on-line docs, but couldn't figure out why it came up and 
>what's "chuck 7072". I was using "use stric" and "#!perl -w". Do I need to 
>declare FILEDANDLES?

You are right that the '<WEBLOG> chunk 7072' may be misleading.  I have seen 
'chunk' refer to both code refs (including evals) as well as regular 
expressions.  However, your problem is the use of an uninitialized value 
under -w.  Here is what perldiag.pod has to say about this:

    Use of uninitialized value
        (W) An undefined value was used as if it were already
        defined. It was interpreted as a "" or a 0, but maybe it was
        a mistake. To suppress this warning assign an initial value
        to your variables.

If, in your script you have a line like this:

   $foo = $bar;

where $bar had not occurred prior to that point, then the warning is telling 
you that $foo will receive a null string - which may or may not be what you 
intended.  You can get around it by saying:

   use vars qw($bar); 

or by explicitly saying:

   $bar = '';
   $foo = $bar;


>---------------------------------------------
>
>Question 2:
>
>How to write a subroutine that takes in a file name and returns true or false depending whether its extension is one of qw(m ma nb mov hqx). (I don't want a hard-wired ||...||...|| solution.)
>
>The following is my try, but didn't work.
>
>sub funct {
>	my($x);
>	$x = $_[0];
>	$x =~ s@^[^.]+\.(.+)$@$1@;
>	$x =~ m@m|ma|nb|mov|hqx@;  #this line is incorrect. I knew.
>}; 

sub funct {
	my $x = shift;
	$x =~ m@\.(m|ma|nb|mov|hqx)$@;  # note return value will be 
                                        # qw(m ma nb mov hqx) for matching 
                                        # filename, null string otherwise
}

>---------------------------------------------
>Question 3:
>
>Can anyone tell me the location of on-line doc that explains the
>
>#!perl
>
>line? I knew roughly what it is and what it does, but would like to read 
>about it. (I did grep the pod, but didn't find explainations)

perlrun.pod

Peter Prymmer


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch