Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: how to put values into $$rhash_params{'import_file'}->filename?

by jonadab (Parson)
on Sep 17, 2008 at 10:32 UTC ( [id://711954]=note: print w/replies, xml ) Need Help??


in reply to how to put values into $$rhash_params{'import_file'}->filename?

I'm not 100% sure what you're asking, at least partly because I've never used the Apache::Request module, but if all you want to do is store values in a hash, you can do that with a straightforward normal assignment operation. The fact that the hash is nested inside another data structure doesn't matter:

my %foo; my $bar = { key1 => "value 1", }; $foo{key2} = "value 2"; $$bar{key3} = "value 3"; $$bar{key4} = { key5 => "value 5", }; $$bar{key4}->{key6} = "value 6"; $$bar{key4}{key7} = "value 7"; # simpler syntax use Data::Dumper; print Dumper( \%foo, \$bar );
If there's something different going on that I've missed (e.g., a tied hash), or something more you wanted to know, you might try to clarify your question. As it stands now, this is the only answer I could come up with.
-- 
We're working on a six-year set of freely redistributable Vacation Bible School materials.
  • Comment on Re: how to put values into $$rhash_params{'import_file'}->filename?
  • Download Code

Replies are listed 'Best First'.
Re^2: how to put values into $$rhash_params{'import_file'}->filename?
by MelaOS (Beadle) on Sep 24, 2008 at 09:50 UTC
    hi man,
    actually let me try to explain what i'm doing here:
    #------------------------------------------------------ # Handle all POST, GET, multipart, and upload requests #------------------------------------------------------ my $r = Apache->request(); my $apr = Apache::Request->new($r); my @keys = $apr->param; foreach (@keys) { my @value = $apr->param($_); next unless scalar @value; if (@value>1){ $params{$_} = \@value; } else { $params{$_} = $value[0]; } } my $upload = $apr->upload; if ($upload) { $params{'import_file'} = $upload; }
    this is the default method for uploading files using modcgi page via apache. but my problem is that i'm trying to upload files directly from the server bypassing this uploading modcgi page.
    unfortunately, most of the functions in my company uses hash{param} method to store parameters, so the file handler and the file name is actually kept using this method. so i need to find a way to put in the file name and the file handle parameter to the $$rhash_params variable so i can minimize changes to the functions that i'm using.
    thanks for your answer, i try your method and using the ->filename i got this error:
    error Can't modify non-lvalue subroutine call at /script.pm line 1467.\n
    and using the {}{} method i got this error msg:
    error Not a HASH reference at /media/www/vprimary/script.pm line 1468.\n
    from using data dumper this is what i've got:
    $VAR1 = { 'file_handler' => bless( \*Apache::Upload::_GEN_2410, 'Apach +e::Upload' ), 'import_file' => bless( do{\(my $o = 447703164)}, 'Apache::U +pload' ), };
    any idea how do i put values into the import file or file handler?
    thanks & sorry for the belated reply.
    ~perlnoobian

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://711954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found