MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Will someone make sense of this Perl segment for an idiot?



******    message to minivend-users from mediamob <mediamob@dnaco.net>     ******


I thought I was pretty smart, and then I started trying to use minivend...

Anyway, I think that understanding this bit of code from browse1 as
supplied with sample might unlock some keys for me. I have no perl
experience, but I do have a book ("learning perl") and a desperate
persistance. I will list the lines here and a statement as to why it makes
no sense to me based upon what I can garner from the perl book. I would be
most appreciateive if anyone can offer a clue.

Here goes:
[perl arg=scratch]
	$start = tag_data('session', 'arg') || 1;

It looks like this means something like "assign to the variable $start the
value of a logical OR operation between the return value of the routine
tag_data (with arguments 'session' and 'arg') and the numeric value 1."

If Perl considers 1 to be true and 0 to be false, doesn't this always
return a true? What good does it do?

Secondly, what does tag_data() do? I found some exaple uses in the mailist
arcives, and some other reqests for help regarding it, but no definition.
A search of the docs turns up 4 references, but likewise no definition.

	$chunk = 1;

Ok, I think I get this one.

	if($start =~ /(\d+):(\d*)/) {

I get as far as this: " If the value of $start matches" and then I can't
recognise what is an operator and what is a variable. What does the : do?
does the \ indicate a literal d rather than a reserved word d?

		$start = $1;

Now the value of $start is set = the value of $1. Where did $1 come from ,
and how do we know it's value?

		$chunk = $2 || 1;
	}
Likewise $2

	$prev = $start - $chunk;
	if($prev < 1) {
		$prev = 0;
	}

I think I get this.

	$Safe{'scratch'}{'start'} = $start;
	$Safe{'scratch'}{'chunk'} = $chunk;
	$Safe{'scratch'}{'next'} = $start + $chunk;
	$Safe{'scratch'}{'prev'} = $prev;
	$Safe{'scratch'}{'not_shown'} = 1;

No clue as to what the left side does. Looks like some kind of array
handling, but I don't find a reference.

	return '';
[/perl]

Ok ,these I think I have.


TIA-

MediaMob

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: