in reply to Re^2: Problems calling a second perl script from the first
in thread Problems calling a second perl script from the first

So $cgi->param("toping") contains the target file name. So that means you need to open the target file and input it. Mimicking the behavior of the original source material, you might do something like:
sub UPLOAD { $wfile = $cgi->param("toping"); open(my $wfin, '<', $wfile) or die "Error opening $wfile: $!"; $wfname = 'toping'; open (my $datin,">", "/home/deruytja/webserver/rifucgi/temp_ul/$wf +name") or die 'Error processing file INPUT: ',$!; binmode $wfin; binmode $datin; while (read $wfin, my($data), 1024) { print $datin $data } #Upload Teil des Scripts }
With regard to reading material, there's a fair amount you could learn from Ovid's CGI Course - Resurrected and Updated! about good practice. He discusses taint and other security issues. It's worth noting that people generally don't use CGI directly any more. Specifically, the docs for CGI itself say
The rationale for this decision is that CGI.pm is no longer considered good practice for developing web applications, including quick prototyping and small web scripts. There are far better, cleaner, quicker, easier, safer, more scalable, more extensible, more modern alternatives available at this point in time.
Modules like Template::Toolkit (which is rolled into frameworks like Mojolicious, Dancer2 and Catalyst) allow for clean separation between your logic and layout, and can defaultly handle the character escaping.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^4: Problems calling a second perl script from the first
by deruytja (Novice) on Apr 13, 2015 at 16:40 UTC

    I've tried it now with the $cgi->upload('toping') version and also with your version, still no luck.

    To clarify what the script should do (and normally does very well), I'll explain a bit: The whole script is just a multiping utility where a user is allowed to upload a file containing IP adresses and labels, so I need to write an upload routine, process the uploaded file and ping the devices inside.

    As we've got another project I needed to take a look at the GD::Graph module. To get to know the module I wanted to implement it to the existing ping utility.

    In my understanding, the whole problem is that the subscript for plotting the graph needs to "check" all the variables in the "multiping-script" (Which I don't understand as it only uses the "our" variables) and doesn't like the empty "filehandle" with which I upload the file at first

    If the "multiping-script" is started at first (via the HTML page) the "filehandle" is filled, as their is user input, the second time the "multiping-script" is called (via the graph script) the "filehandle" is empty (which is correct as their are no parameters given)

    Is there a way to bind these 2 scripts together without the check on the variables which aren't needed?

    Tomorrow I'll take a look at the Template::Toolkit and maybe change over to this one.

      normally, in HTML, images (such as your graph) are requested separately from the "text", so it would have to be a different script, and the parameters have to come in via URL parameters, which mandates parameter checking, because anyone could call the "image script" by hand.

      It is possible to incorporate images directly with <img src="data:... (see

      So you could call your graph generator directly as a subroutine (with already checked parameters). Of course, your subroutine would have to (base64) encode the image.