Are there actually variables earlier in the script?

$school_id = "SKOOL ID";
$school_name = "SKOOL NM";
$school_address = "SKOOL AD";

Print "ID - $school_id \n NM - $school_name \n AD - $school_address \n";

Run that then the code you have now and see what you get.
Also print "\$f = $f = .$$f." may be better as -$$f- instead of .$$f. just incase it's 
trying to use a var named $f. instead of $f.

Dan
-----Original Message-----
From: Joe Mecklin [mailto:[EMAIL PROTECTED]] 
Sent: Monday, January 13, 2003 11:44 AM
To: [EMAIL PROTECTED]
Subject: RE: reference problem (i think)


thanks Dan, but no go.  here is the current incarnation, based on your
suggestion:

sub clear_input
{

    no strict 'refs';

    my %options =   @_; 
    my $fields  =   $options{FIELDS};
    my (@field) =   split /, /, $fields;

    print "\$fields = $fields <br />";
    print "\@field = @field <br />";
    foreach $f (@field)
    {
        print "\$f = $f = .$$f. <br />";
    }
}

and this is the current output:

$fields = school_id, school_name, school_address
@field = school_id school_name school_address
$f = school_id = ..
$f = school_name = ..
$f = school_address = .. 

i still don't get the value of $school_id, etc.  yet if i pass $school_id as an 
argument i do get the current value of that var, only like this (changing only 
school_id to $school_id):

$fields = 135, school_name, school_address
@field = 135 school_name school_address
$f = 135 = ..
$f = school_name = ..
$f = school_address = .. 

any other suggestions/insights/directions, please?




On Mon, 2003-01-13 at 11:07, Dan Muey wrote:

> foreach $f(@fields) {
> 
>       $$f = ""; # or use undef, whatever
> }
> 
> If strict refs is in use this won't work unless you turn them off do 
> the $$f = ""; bit then turn them back on if stricy refs was in use
> 
> So actually ( or somehting like it, I'm in a hurry and may have been 
> sloppy )...
> 
> foreach $f(@fields) {
> 
>       no strict 'refs';
>       $$f = "";
>       if(strict refs were on before) { use strict 'refs'; }
> }
> 
> ...Would be better, not sure exactly how to tell if 'strict refs were 
> on before' but I'm sure there's a way.
> 
> Dan
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to