[ic] mv_credit_card_reference

Mike Heins interchange-users@interchange.redhat.com
Wed Oct 10 17:45:00 2001


Quoting Javier Martin (martin@trymedia.com):
> > > Thanks a lot Mike. I solved it by calling:
> > >
> > >   my $cc_ref = (Vend::Order::encrypt_standard_cc($CGI, 1)) [6]
> > >
> > > from [perl], but &calc looks cleaner because I'm validating the
> > CC twice...
> > >
> >
> > Obviously you are running AllowGlobal....you should put in a
> > warning "don't
> > try this at home". 8-)
> 
> Yes, I think I will follow those guidelines from the docs about locking down
> the server. I've removed the Vend::Order::encrypt_standard_cc call, and have
> changed [perl]...[/perl] by &calc=<<EOF ... EOF.
> 
> I still have problems though, because I have a lot more of code which gets
> trapped by Safe::Hole, concretely calls to Digest::MD5 and LWP. I've moved
> all of this to globalsubs and included them from the main
> /etc/interchange.cfg file, but when I call one of the subs, I get something
> like:
> 
>   process Safe: Undefined subroutine &MVSAFE94805::calc_md5 called at (eval
> 257) line 40.
> 
> I've tried:
> 
>   &calc=<<EOF
>      ...
>      my_global_sub($something);
>   EOF
> 
> as well as:
> 
>   &calc=<<EOF
>     ...
>     ::my_global_sub($something);
>   EOF

I am working on a new programming guide, and one of the first things
it says is:

	Don't use GlobalSub.

The real method of doing this is just change your GlobalSub to a
$Tag, i.e. a global UserTag. Perhaps I should make a $Sub object...8-)

All you need to do is:

GlobalSub <<EOR
sub somesub {
	# some code
}
EOR

Change that to:

UserTag somesub Order something
UserTag somesub Routine <<EOR
sub {
	# same code
}
EOR

Then call it with $Tag->somesub($something);

It is usually nice to put an option hash at the end:

UserTag somesub addAttr

That way you can pass additional params without having to 
preposition the arguments:

UserTag somesub Order something
UserTag somesub addAttr
UserTag somesub Routine <<EOR
sub {
	my ($something, $opt) = @_;
	$opt ||= {};

	if($opt->{this}) {
		that();
	}
	# some code
}
EOR

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman