Unknown function

M

Martin L.

I a trying to debug a free script that allows me to place counters on
pages throught my domain. It operates using SSI's. There are no fatal
errors. The results should be a summary of my counter logs for each
page that has a counter the no log file names or contents appear.


There is one function #### @files = ('logs/*.log'); ##### I am not
familiar with and a look through PERLFUNC did not turn up anything.

Here is the context It is found in

####begin snippet


$opt = "$ENV{ 'QUERY_STRING' }";
$count_page = "$ENV{ 'QUERY_STRING' }";

if ( $opt eq "stats" ) {
@files = ('logs/*.log');
&get_files;
&CalculateStats }

####end snippet

At this point the script should be generating a list of counter log
files so that is what I am assuming this line does. I understand the
"*.logs" portion is a wild card for all files with the "log" extension
but the preceeding "logs/" I have not seen before. It is the name of
the log directory but it has not been assigned to a FILE_HANDLE
anywhere and the only other reference is as a comparison string in an
unrelated section of the script.

The page returned from the script would indicate that the "@files"
variable contained no data.

Thanks
Martin L.
 
S

Sandman

Martin L. said:
I a trying to debug a free script that allows me to place counters on
pages throught my domain. It operates using SSI's. There are no fatal
errors. The results should be a summary of my counter logs for each
page that has a counter the no log file names or contents appear.


There is one function #### @files = ('logs/*.log'); ##### I am not
familiar with and a look through PERLFUNC did not turn up anything.

Here is the context It is found in

####begin snippet


$opt = "$ENV{ 'QUERY_STRING' }";
$count_page = "$ENV{ 'QUERY_STRING' }";

if ( $opt eq "stats" ) {
@files = ('logs/*.log');
&get_files;
&CalculateStats }

####end snippet

At this point the script should be generating a list of counter log
files so that is what I am assuming this line does. I understand the
"*.logs" portion is a wild card for all files with the "log" extension
but the preceeding "logs/" I have not seen before. It is the name of
the log directory but it has not been assigned to a FILE_HANDLE
anywhere and the only other reference is as a comparison string in an
unrelated section of the script.

The page returned from the script would indicate that the "@files"
variable contained no data.

In this snippet, @files is an array containing one entry - "logs/*.log", it's
not a function. Presumably a later function (get_files or CalculateStats
perhaps) will deal with all the items in @files.
 
T

Tad McClellan

Martin L. said:
I a trying to debug a free script


It is very likely worth less than what you paid for it...

There is one function #### @files = ('logs/*.log'); ##### I am not
familiar with and a look through PERLFUNC did not turn up anything.


It is a "list assignment".

A list on the left (stored in an array), and a list on the right
(a short list, only one element long).

A list assignment puts the 1st thing on the right into the 1st
thing on the left, the 2nd on the right into the 2nd on the left, etc.

Here is the context It is found in
@files = ('logs/*.log');


It has the same effect as this:

@files = (); # ensure everything else gets stomped on
$files[0] = 'logs/*.log';

&get_files;
&CalculateStats }


I understand the
"*.logs" portion is a wild card for all files with the "log" extension


At this point it is nothing more than a string with an asterisk in it.

The asterisk will only be interpreted as a wildcard if the string
is eventually used with glob().

Does get_files() or CalculateStats() access @files and feed it to a glob?

Communicating via globabl variables, and calling subroutines like that
are a pretty clear indication that you are working with some
very poor code...
 
J

Jürgen Exner

Martin said:
I a trying to debug a free script that allows me to place counters on
pages throught my domain.

Just on a side note: Your aware of "perldoc -q increment", aren't you?

jue
 
M

Martin L.

No, I am not aware of it, but if it makes this any easier to
understand, I sure would like to be!

:)
 
M

Michele Dondi

There is one function #### @files = ('logs/*.log'); ##### I am not
familiar with and a look through PERLFUNC did not turn up anything.

I skipped the rest of your post but somehow I strongly suspect that
the above statement should really be

@files = <'logs/*.log'>;
^ ^

are you sure you didn't mistook them for parens?


Michele
 
J

John W. Krahn

Michele said:
I skipped the rest of your post but somehow I strongly suspect that
the above statement should really be

@files = <'logs/*.log'>;
^ ^

are you sure you didn't mistook them for parens?

You do realize that the single quotes will be included as part of the
path/file name meaning that you are looking for the directory "'logs"
with files ending in ".log'"?


John
 
M

Michele Dondi

You do realize that the single quotes will be included as part of the
path/file name meaning that you are looking for the directory "'logs"
with files ending in ".log'"?

D'Oh!


Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top