|
#1
|
|||
|
|||
|
Hi All,
Need help on Perl for I am very new to this. The current application will send a fixed variables from browser to the Perl program. This Perl program will get all these values and store it in a directory. So now I need to make the program to accept unlimited variables. Actually the variables comes from an XML file. Example: Need to send send ABC.XML to http://qwerty/cgi-bin/test.pl using post method: This is the current Perl program: &ReadParse; $logfile = "/xyzroot/log/123log.txt"; $allowed_ip = ""; $remote_ip = $ENV{'REMOTE_IP'}; ##$targetDirectory = "http://qwerty/plm/recv"; $targetDirectory = "/xyzroot/plm/recv"; $backupDirectory = "/main/BACKUP"; $Sender = $in{'Sender'}; * $Receiver = $in{'Receiver'}; * $TrackId = $in{'TrackId'}; * $Message = $in{'XMLMessage'}; * $targetFile = $targetDirectory . "/$Sender-" . $TrackId . ".xml"; $backupFile = $backupDirectory . "/$Sender-" . $TrackId . ".xml"; ## $targetInfo = $targetDirectory . "/$Sender-" . $TrackId . ".xrf"; $timestamp = ctime(); open(LOGF, ">>$logfile") || die "\nError opening $logfile\n"; printf LOGF "\n************************************************ \n"; printf LOGF "Sender : $Sender\n"; printf LOGF "Receiver : $Receiver\n"; printf LOGF "Track ID : $TrackId\n"; printf LOGF "TimeStamp : $timestamp\n"; printf LOGF "Main Directory Filename : $targetFile\n"; close(LOGF); ##open(INFFILE, ">$targetInfo") || die "\nError opening $targetInfo\n"; ##print INFFILE "$Sender\n"; ##print INFFILE "$Receiver\n"; ##print INFFILE "$TrackId\n"; ##print INFFILE "$targetFile\n"; ##close(INFFILE); open(EDIFILE, ">$targetFile") || die "\nError opening $targetFile\n"; print EDIFILE "$Message"; close(EDIFILE); open(EDIFILE, ">$backupFile") || die "\nError opening $backupFile\n"; print EDIFILE "$EDIMessage"; close(EDIFILE); print "Content-Type: text/html", "\n\n"; print "Message number : $TrackId has been submitted to PLM"; 1; sub ReadParse { local (*in) = @_ if @_; local ($i, $key, $val); if ( $ENV{'REQUEST_METHOD'} eq "GET" ) { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } else { # Added for command line debugging # Supply name/value form data as a command line argument # Format: name1=value1\&name2=value2\&... # (need to escape & for shell) # Find the first argument that's not a switch (-) $in = ( grep( !/^-/, @ARGV )) [0]; $in =~ s/\\&/&/g; } @in = split(/&/,$in); p/s: I need to make the $Message = $in{'XMLMessage'} to accept more than one value. At the moment, i can only assign one XML Message : <Test>hello hello everyone</Test>. Or how can i accept one XML file in Perl? Hope someone can help me out in this...Thanks... ![]() |
|
#2
|
|||
|
|||
|
Have you tried XML::Simple? I like it. http://search.cpan.org/~grantm/XML-...b/XML/Simple.pm
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|