Perl backward compatibility question
Hi folks, Inspired by some discussion on that list I'd like to swap my 5.004 version of Perl to a newer one. ( To be exact, perl -v returns now on our system: This is perl, version 5.004_04 built for sun4-solaris Copyright 1987-1997, Larry Wall ) The only Perl guru that we have in our company is for some reason very reluctant to help me.. He murmured something about incompatibility and told me to reconsider. So, my first question is: should I expect anything bad? The second one is: on sunfreeware.com Perl 5.6.1 for SPARC/Solaris 8 comes with a warning: Important Note - Solaris 8 comes with a slightly earlier version of perl in /usr/bin. You may wish to use this version rather than the version on sunfreeware.com. If you do install this perl and want to use it rather than the Sun one, you will need to have /usr/local/bin in your PATH before /usr/bin. Is 'slightly earlier version' 5.004? Thanks in advance, Ela
short filehandle question
Hi, Executing my program with -w option I get the following warning: 'Value of HANDLE construct can be 0; test with defined() at readData line 65535.' Surely I do not have 65535 lines in my program, but I suspect this one: #reading data open (FILEH, $filename) or die Can't open file!\n; while ($line = FILEH) { How should I rewrite it to avoid that warning? Thanks in advance, Ela
AW: short filehandle question
Hi, It is declared as my $FILEH at the beginning of the file... Could you tell me what the difference is? Ela -Ursprüngliche Nachricht- Von: Jerry Preston [mailto:[EMAIL PROTECTED]] Gesendet: Freitag, 29. Juni 2001 15:39 An: Ela Jarecka Betreff: Re: short filehandle question Ela, You need to declare FILEH: local( *FILEH ); Jerry Ela Jarecka wrote: Hi, Executing my program with -w option I get the following warning: 'Value of HANDLE construct can be 0; test with defined() at readData line 65535.' Surely I do not have 65535 lines in my program, but I suspect this one: #reading data open (FILEH, $filename) or die Can't open file!\n; while ($line = FILEH) { How should I rewrite it to avoid that warning? Thanks in advance, Ela
die / exit / style question
Hi folks, I have a couple of doubts/questions about the usage of above functions: 1. will those three always work the same ( I have troubles understanding the 'die' description in Llama book ( $!, $?8, the status of the last reaped child from a system, wait, close on a pipe, or `command`))?: if ( ( $reqrec-fillServ($ServRef) ) == undef ) { print fillRec failed! \n; exit; } if ( ( $reqrec-fillServ($ServRef) ) == undef ) { die fillRec failed! \n; } $reqrec-fillServ($ServRef) or die fillServ failed; In fillServ function, I use 'return;' upon failure and 'return 1;' if everything is OK. 2. is it a matter of style to use 'not defined(_expression_)' or (_expression_) == undef? I get warnings in the second case.. Will defined cover also an empty string? Any comments will be greatly appreciated, as it is my first bigger program in Perl and I would like it to work flawless... Ela
AW: getopt:std questions
I use it like this ( checking program options ): my $usage = $0 -s servdata -u userdata -b begtime -e endtime -f params\n; my %opts; getopts('b:e:s:u:f:', \%opts); my $servdata = $opts{s}; my $userdata = $opts{u}; my $begtime = $opts{b}; my $endtime = $opts{e}; my $reqdata = $opts{f}; Cheers, Ela -Ursprüngliche Nachricht- Von: Tyler Longren [mailto:[EMAIL PROTECTED]] Gesendet: Mittwoch, 27. Juni 2001 16:24 An: Perl Beginners Betreff: getopt:std questions Hello everyone, Here's a section of code: my %options; my $u; use strict; use Getopt::Std; getopts(dwmyau:, \%options); How can I get the value of the '-u' option and print it to the screen? I've tried this: $u = $options{u}; print $u; but that doesn't work...it doesn't print anything. Can anybody shed some light on this for me? Thanks, Tyler Longren
Data format ( time zones )
Hi, I have to check whether a given string ( '-MM-DDTHH:MI:SSTZD' - where TZD = Z|+HH:MI|-HH:MI ) contains a valid data and then convert to '-MM-DD HH:MI:SS'. I've found a module called Net::ICal::Time, but it doesn't seem to be working properly.. Writing a regex to divide the given string is not a problem, but it would be nice if I had a function that would adjust the time accordingly, given a time zone. Thanks in advance for any suggestions, Ela
AW: Problems with LWP::UserAgent and HTTP::Response
Thanks, at least I know that I am sending my XML properly.. But I still get the same error message, so if anyone has more suggestions please write.. Ela -Ursprüngliche Nachricht- Von: Tim Keefer [mailto:[EMAIL PROTECTED]] Gesendet: Montag, 18. Juni 2001 15:46 An: Ela Jarecka; Beginners list (E-Mail) Betreff: Re: Problems with LWP::UserAgent and HTTP::Response Hi Ela, The documentation for perl LWP agent seems sparse. I had a difficult time figuring out how to send multipart form-data. I'll share the code with you that some shared with me. Hope it helps. require LWP; use LWP::UserAgent; use HTTP::Request::Common; # Create a user agent object $ua = new LWP::UserAgent; $ua-agent(AgentName/0.1 . $ua-agent); # Pass request to the user agent and get a response back my $res = $ua-request (POST $URL, Content_Type = 'form-data', Content = [ login_id = $Username, login_passwd = $Password, name_auth= $Prefix, fname= [$XML_Dir\\$XML_File], operation= 'Submit Batch File', ]); # Check the outcome of the response - I guess we just file away if ($res-is_success) { print success!\n; print $res-content; if ( $res-content =~ /\QH2SUCCESS\/H2\E/i ) { print Deposit successful\n; } else { print POSTLOG Deposit FAILED.\n; } } else { print failed!\n; } Ela Jarecka wrote: Hi, I am using the following code to send and XML document ( output.xml ) to a remote server: use strict; use LWP::Debug qw(+); use LWP::UserAgent; use IO; my $resp; $resp = 'response.xml'; my $FILEH; open (FILEH, output.xml) or die Can't open file output.xml!\n; my $ua = LWP::UserAgent-new; #another version that i've tried... #my $h = new HTTP::Headers Date= '2001-05-18'; #my $req = HTTP::Request-new('POST','http://195.252.142.171:8008',$h,$FILEH); my $req = HTTP::Request-new(POST = 'http://195.252.142.171:8008'); #$req-content_type('text/xml'); $req-content($FILEH); my $res = $ua-request($req,$resp); here I've also tried plain request($req) but the result is the same if ( $res-is_success) { print OK!\n; #print $res-as_string; } else { print Failed: , $res-status_line, \n; } And that's what I get: LWP::UserAgent::new: () LWP::UserAgent::request: () LWP::UserAgent::simple_request: POST http://195.252.142.171:8008/ LWP::UserAgent::_need_proxy: (http://195.252.142.171:8008/) LWP::UserAgent::_need_proxy: Not proxied LWP::Protocol::http::request: () LWP::Protocol::http::request: POST / HTTP/1.0 Host: 195.252.142.171:8008 User-Agent: libwww-perl/5.21 LWP::Protocol::http::request: reading response LWP::UserAgent::request: Simple result: Internal Server Error Failed: 500 read timeout ### Could anyone please help me? The problem is that I am not too sure whether my request is correct in the first place. In the manuals, $content is described as 'an arbitrary amount of data'.. Is my filehandle properly interpreted? I've tried using only the name of the file, but obviously it didn't work, being interpreted as a 10 chars long string... Thanks in advance, Ela
AW: Getting to the contents of a class..
foreach my $item ( keys $reqrec-myflds ) { #line 26 ... } If, out of the constructor you showed us above, you're expecting the myflds method to automatically be created, and return your hash, it's not going to happen. You have to define a myflds method, probably something along the lines of: sub myflds { my $self = shift; return $self; } From this point on, you can now refer to %{ $reqrec-myflds }. Thanks for your advice.. Just to clarify - I was not expecting any miracles, it was simply a misunderstanding at my part. I thought that if you can call a method in that way: $myvar-myfunction(...), then you can access a variable of a class in a similar way, say: $myvar-%myhash... In my code, I finally wrote: foreach my $item ( keys %$reqrec ) { ... } Ela
[OT] AW: Getting to the contents of a class..
Sorry, but sending a message like that doesn't really help a beginner ( = a person for whom that list was created! ). Fortunately, my problem has already been solved by others ( THANKS AGAIN! ) -Ursprüngliche Nachricht- Von: gmsayloriii [mailto:[EMAIL PROTECTED]] Gesendet: Dienstag, 12. Juni 2001 14:00 An: Ela Jarecka Betreff: Re: Getting to the contents of a class.. % - Original Message - From: Ela Jarecka [EMAIL PROTECTED] To: Beginners list (E-Mail) [EMAIL PROTECTED] Sent: Monday, June 11, 2001 5:00 AM Subject: Getting to the contents of a class.. Hi, I've just defined a small class, DataReq. It contains a hash called 'myflds' and a couple of functions for writing/retrieving data. Now, in my main program, I've included the following code: my $reqrec = new DataReq; if ( ($reqrec-fillrec(@mylist)) == undef ) { die fillrec failed!\n; } foreach my $item ( keys $reqrec-myflds ) { #line 26 ... } I get an error: 'Can't locate object method myflds via package DataReq at makeReq line 26' How should I indicate that 'myflds' is a hash? I've tried putting an '%' in front of 'myflds' but it returned an error as well. Could anyone help? Thanx in advance, Ela
Getting to the contents of a class..
Hi, I've just defined a small class, DataReq. It contains a hash called 'myflds' and a couple of functions for writing/retrieving data. Now, in my main program, I've included the following code: my $reqrec = new DataReq; if ( ($reqrec-fillrec(@mylist)) == undef ) { die fillrec failed!\n; } foreach my $item ( keys $reqrec-myflds ) { #line 26 ... } I get an error: 'Can't locate object method myflds via package DataReq at makeReq line 26' How should I indicate that 'myflds' is a hash? I've tried putting an '%' in front of 'myflds' but it returned an error as well. Could anyone help? Thanx in advance, Ela
Sending XML-formatted messages over a https-Connection from a Perl programm
Hi, Could anybody help me in that subject? I am supposed to send an XML-formatted message requesting data from a third-party system.. Where should I start? Where do I find a Perl module supporting http streams? Thanks in advance, Ela
AW: Sending XML-formatted messages over a https-Connection from a Perl programm
It all depends on what the client looks like, if they have an xml parser, like zerces or JAXP for Enterprise java, then you both could agree on the location of the xml, and you'd post it and the xml parser would grab it. Otherwise, you could simply stream the file over a regular socket... Could you provide more info on the client. All I know right now is that the client is a server, a physical maschine, on which a process is running awaiting my ( appropriately formatted ) messages. Once it gets such a message it generates requested data and sends it back using scp to our proxy server. Sorry, but all I have is a documentation written by someone who is not reachable at the moment.. Do you have any examples of the second solution? E.g. for opening a https-connection by a Perl script? It may be really simple as I am completely new to the subject... Thankx in advance, Ela