[Thread Prev][Thread Next][Index]
Re: How to extract the parameters passed from LASserver.pl incustomizedperl function?
Sorry, typo
$self->{props}->{'key'}
-------------------------
Here is another way which can catch some HASHes along with ARRAYs.
Put this in your custom.pl script and it should print all properties to
server/log/GenericLAS_debug.txt
then you'll know what props keys to use. Hope there's no more typos.
my $props = $self->{props};
foreach my $key ( keys ( %{$props} ) ){
if(ref($props->{$key}) eq 'ARRAY'){
debug("props: $key == array: (", join(',', @{$props->{$key}}), ")\n");
}elsif(ref($props->{$key}) eq 'HASH'){
debug("props: $key == hash: (");
while (my ($key,$value) = each %{$props->{$key}}) {
debug(", $key=$value");
}
debug(")\n");
}else{
debug("prop: $key == $props->{$key}\n");
}
}
Joe
--------------------------
Joe McLean wrote:
> Hi Ding,
> The way to access parameters is to use $self->{props}-{key}
>
> Look in las/server/Ferret.pl
>
> sub debugProps {
> my ($self, $name, $props) = @_;
> return if ! defined $props;
> #
> # Dump to debug
> foreach (keys %{$props}){
> my $obj = $props->{$_};
> if (ref($obj) eq 'ARRAY'){
> debug("$name prop array: $_ = (",
> join(',', @{$obj}), ")\n");
> } else {
> $obj = "" if ! defined($obj);
> debug("$name prop: $_ = $obj\n");
> }
> }
> }
>
> Joe
> ---------------------------------
>
> Chi Ding wrote:
>
> > Dear LAS users
> > I'm customizing a LAS site for mooring data by writing my own perl
> > function in the file custom.pl.
> > I don't know how to extract the parameters, like depth, time range, user
> > selected variables etc, passed from users' web
> > browser in my function. I need those parameters to tell my ferret script
> > to plot accordingly.
> > My site is at
> > http://palapa.ocean.dal.ca:8080/las/servlets/dataset?catitem=13. Right
> > now everything in my ferret script is fixed, like variables, time range
> > and depth. Therefore whatever you select, eventually it will draw a plot
> > with "salinity" and "temperature"measured at surface during the range
> > between 2002 Jun to 2002 Nov.
> > My custom.pl file is like below, it contains a function called
> > MooringTest.
> > package LAS::Server::Ferret;
> >
> > sub MooringTest {
> > my $self = shift;
> >
> > my @vars = @{$self->{vars}};
> > my $numVars = scalar @vars;
> >
> > use IO::File;
> > my $log_file = 'MooringTest.log';
> > my $log_fh = IO::File->new($log_file,O_WRONLY|O_APPEND|O_CREAT);
> >
> > use Carp ();
> > if ( !defined ($log_fh) ) { #if open log file fails
> > Carp::confess("File open failed!");
> > }
> >
> > print $log_fh @vars;
> > print $log_fh $numVars;
> > print $log_fh "\n";
> >
> > $self->command("go MooringTest"); # Execute the Ferret command 'go
> > MooringTest'
> > $self->genImage($self->{output_file}); # Generate the image
> > }
> > 1;
> >
> > As you can see, I print the parameter array passed into my function
> > in my log file. What I got was like this
> > LAS::Variable=HASH(0x88eff6c). I checked the perl document about
> > LAS::Variable, and it has several methods like
> > getChildren(),getDataset(), getURL(). I tried to get the axes of the
> > variable and the dataset information but failed.
> > Can anybody help me to extract the parameters? Any information will
> > be highly appreciated.
> > Cheers, Ding
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement