- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl CGI: Source html-page
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 07:01 PM
11-03-2003 07:01 PM
I have a CGI-script that needs to print an html-page containing variables dependent on the choise you make.
Right now I do this using :
#!/opt/per/bin/perl
if ($submit) {
open(FH, "< $htmlfile");
my @contents=
close(FH);
print "Content type text/html; \n\n";
print "Contents";
This does print my html-page, but does not interpeted the variables($value) as :
Is there a way to source the html-file inside the perl/cgi script, so the $variables are interpeted correct?
Thanks a lot for your help in advance !!!
Regs David
The reason for this is that other people should be able to create html-pages and only need to use specific "names" and a form action should be taken. I will only do the perly thing than.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 07:09 PM
11-03-2003 07:09 PM
Re: Perl CGI: Source html-page
Something like this
while($line=
$line =~ s/\$([\w\]\[\$]+)/insertvar($1)/eg;
print $line;
}
And then a function called insertvar that does this
$result=eval(\$$1);
return($result);
I think this is what your're after.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 07:27 PM
11-03-2003 07:27 PM
Re: Perl CGI: Source html-page
It does not work. I did what you said :
open(FF, "< $file_v");
$line =~ s/\$([\w\]\[\$]+)/insertvar($1)/eg;
print $line;
close(FF);
And I added another subroutine :
sub insertvar() {
$result=eval(\$$1);
return($result);
}
I don't seem to get it. Please help.
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 07:51 PM
11-03-2003 07:51 PM
Re: Perl CGI: Source html-page
Can we just make sure we are trying to solve the same problem.
I am assuming that within your script are some variables, already defined and that the html file contains the text $some_variable_name here and there which you want to replace with the corresponding variable already set within the perl script and then print.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 07:59 PM
11-03-2003 07:59 PM
Re: Perl CGI: Source html-page
That is a 100% true. Like the example of says.
The problem is that nothing is printed anymore. With the @contents at least something got printed :)
Regs David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 08:00 PM
11-03-2003 08:00 PM
Re: Perl CGI: Source html-page
Here is the code taht does what I think you want to do. Note the bracket has moved in the "s/etc etc etc/eg" bit and I simplified the eval.
#!/usr/bin/perl
$myvariable="HELLO THERE";
open FF,"
while($line=
$line =~ s/(\$[\w\]\[\$]+)/insertvar($1)/eg;
print "$line";
}
sub insertvar(){
return(eval($1));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 08:07 PM
11-03-2003 08:07 PM
Solution$line =~ s/(\$[\w\]\[\$]+)/eval($1)/eg;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2003 08:40 PM
11-03-2003 08:40 PM
Re: Perl CGI: Source html-page
You are wonderfull !! (ahum, am already married)
This works terrific :
open(FF, "< $file_v");
while($line=
$line =~ s/(\$[\w\]\[\$]+)/eval($1)/eg;
print $line;
}
close(FF);
Thanks a lot for your time in it!!
Regs David