Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Programming Languages > Perl Programming
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-19-2005, 09:05 PM
ShaSha ShaSha is offline
Junior Member
 
Join Date: Sep 2005
Posts: 3 ShaSha is on a distinguished road
Default XML File

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...
Reply With Quote
  #2  
Old 11-05-2005, 07:27 PM
jazz_snob jazz_snob is offline
Junior Member
 
Join Date: Nov 2005
Location: California
Posts: 1 jazz_snob is on a distinguished road
Default

Have you tried XML::Simple? I like it. http://search.cpan.org/~grantm/XML-...b/XML/Simple.pm
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 11:12 PM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.