perl to flash
We currently use html tables as a template to control the layout of our online course materials. We want to replace the html tables with an alternate technology. Ideally, we would like to render our webpage by writing to a flash skin, or something similar. The skins will have up dedicated buttons and will want to pass the button text and link info to the skin using perl script. The skin will contain a text content window to house approx 1 kb text. We would like to pass a text effect variable to the skin to control the text rendering. The skin needs to generate cgi so that we can read back into perl script. Would like to hear from anybody that has done this or can direct me to a solution. Best Regards, Jeff Zanzinger RealEstateCE.com ph: 888.895.8839 fax: 866.517.1406 <http://RealEstateCE.com/> http://RealEstateCE.com/ <>
problems implementing SOAP::WSLD service.
I need some help to connect to a web service WSDL. I installed SOAP::WSLD and able to bind OK and access the service and call some methods, but having trouble passing a security token. My mission is to pass an XML request to the service and receive an acknowledgement. The script is shown below followed by the results of the script run at command prompt. Any help is greatly appreciated. #!C:\Perl\bin\perl.exe -w use strict; use lib "c:/Perl/jtest/tx_roster"; use MyElements::ValidationSoapHeader; my $element = MyElements::ValidationSoapHeader->new(-DevToken => 'xx'); print "element = $element \n\n"; use MyInterfaces::Service1::Service1Soap; my $interface = MyInterfaces::Service1::Service1Soap->new(); my $response; $response = $interface->HelloWorld(); print "response $response \n\n"; $response = $interface->ProcessRoster(); print "$response \n"; Results from Command Prompt: C:\Perl\jtest>perl jeff_1.pl element = http://www.trec.state.tx.us/ProcessRoster "/> response http://www.trec.state.tx.us/ProcessRoster";>< HelloWorldResult>Hello World http://schemas.xmlsoap.org/soap/envelope/";>soap:Server< /faultcode>Server was unable to process request. ---> Authentica tion Failed Best Regards, Jeff Zanzinger RealEstateCE.com ph: 888.895.8839 fax: 866.517.1406 http://RealEstateCE.com/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: file exists statement
unless -e '/dir/path/file'; -or- if ( not -e '/dir/path/file' ) { } -Original Message- From: Tony [mailto:[EMAIL PROTECTED]] Sent: 08 September 2002 10:24 To: [EMAIL PROTECTED] Subject: file exists statement I keeps writing this out if (-e "/dir/path/file"){}else{ #execute } To execute a statement when a file doesn't exist. Someone want to shorten this so I don't have to use an else statement. Thanks, Tony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mod Installations -- as non root
I want to install some mods on my Unix system but don't have root access. Is there a way to do a local installation (ie, under my home directory)??? Seems you have to be root since there is some linking to the system libraries. I've checked the documentation for perlmodinstall, but don't see the answer to this. Thanks in advance, Jeff __ Do you Yahoo!? Yahoo! News - Today's headlines http://news.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: sorting a hash - multiple key fields
Thanks for the response - some questions on your recommendation below: -Original Message- From: david [mailto:[EMAIL PROTECTED]] Sent: 17 September 2002 19:06 To: [EMAIL PROTECTED] Subject: Re: sorting a hash - multiple key fields > the return statment is uneccessary. try something like: > foreach my $k (sort {$h->{$a}->{taste} <=> $h->{$b}->{taste} || > $h->{$a}->{name} cmp $h->{$b}->{name}} keys %{$h}){ > print "$h->{$k}->{name} $h->{$k}->{taste}\n"; > } I had wondered about an || - lazy eval et al - would it be [better | no different] using lower precedence 'or'? Using 'return' seems to generalise better when I have a whole list of sort fields, as it can be used in a loop construct? You are the second person to suggest passing keys into the sort sub, and getting it to lookup the child-hash - it seems to me it would be way more efficient to pass in the hash values and not bother with the lookup? Thanks for the feedback, Regards Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: lots of numbers...
-Original Message- From: Janek Schleicher [mailto:[EMAIL PROTECTED]] Sent: 18 September 2002 18:32 To: [EMAIL PROTECTED] Subject: RE: lots of numbers... > You meant my $iterations = int( scalar @numbers / 3 ); > (However, the scalar cast isn't necessary) > > my $iterations = int(@numbers/3); Thanks for the correction! I miss my old 'div' operator for integer division from languages past 8-) > Or shorter > my @groups = map { [pop(@numbers), shift(@numbers)] } ( 1 .. $iterations ); also nice. > But could it be, we missed the simplest, but acceptable algorithm: > > my @number = sort {$a <=> $b} @ARGV; > > use List::Util qw/sum/; > my @group; > my $sum = sum @number; # @number is already sorted > my $avg = 3 * $sum / @number; # wanted avg for each group > while (@number >= 3) { >my $diff_to_avg = $avg - sum (my ($min,$max) = (shift @number, pop @number)); > >my $i = 0; # index of the number nearest to the missing gap for the wanted avg >foreach (1..$#number) { # perhaps a binary search or smth else will be quicker > $i = $_ if abs($diff_to_avg-$number[$_]) < abs($diff_to_avg-$number[$i]); >} > >push @group, [$min, splice(@number, $i, 1), $max]; > } > > push @group, \@number if @number; # if there are some numbers left > > foreach (@group) { >print join " ", @$_, "avg", (sum(@$_) / @$_); >print "\n"; > } mmm - looks like a more complex approach to me? The point of the first approach was to create approximate groups using the smallest and largest values in a quick first pass. The bulk of the work is easily performed. The second and final pass using the sorted partial groups and the sorted remaining values will always associate the best available value with the right partial group. I think this would also be easier to extend to groups of more than three numbers - you just extend the initial approximation pass to group more numbers from either end. It gets a little more interesting when the desired number of elements in a group is even, as you cant just blindly grab both ends. Using a sort feels simpler than calculating a target average and iterating through all remaining numbers to see which value will bring the partial group closest to the desired target. Remember that @numbers is already sorted. I would guess that the 'calc a target and search for best fit' algorithm actually does more work as coded above, consider that it creates one partial group, and then searches through all remaining numbers for the best fit. It then creates a second partial group, and searches through all remaining numbers for the best fit, etc etc etc. Nighty nite! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
passing a variable to a module
Quick question. I want to pass a variable to a non-oo module that I created. But I how do I get the module to contain the value of the variable that was created in the 'main' namespace. I think there is something easy that I am not understanding. Example code below. PROGRAM BEGIN #!/usr/bin/perl use HelloWorld; $var = 'hello world'; printStatement; exit; PROGRAM END MODULE BEGIN #!/usr/bin/perl package HelloWorld; require Exporter; our @ISA = qw(Exporter); our @EXPORT= qw(printStatement); our $VERSION = 1.00; sub printStatement { print $var; } 1; MODULE END THINGS I'VE TRIED BEGIN I've tried passing in $var to printStatement, printStatement($var) in the program I've tried using the 'main' namespace in the module print $main::var; I've tried passing a reference the $var in the module printStatement (\$var); THINGS I'VE TRIED END Executive summary: how do I define a variable in my program and have a module use that variable definition (in a non-oo module). Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: stop
you could always change your email address! Just a thought. - Original Message - From: David Kapp To: [EMAIL PROTECTED] Sent: Wednesday, January 07, 2004 14:31 Subject: stop I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail. I will now report all mail sent to me by you as SPAM Stop sending me spam. 2003 www.hushport.com <<2004.jpg>><>
Perl Script mirroring accross domains
Hello, I would like to mirror Perl scripts I have loaded in a domain #1 directory and use them in domain #2 without redirecting the web response to domain #1. I really don't want to make copies of all the scripts in domain #1 and install them in domain #2 as this will become a maintenance nightmare in configuration control. I'm looking for a solution where I don't have to run and maintain 2 copies of the same scripts to support 2 separate and independent domains. Any help is greatly appreciated. Best Regards, Jeff Zanzinger RealEstateCE.com ph: 888.895.8839 fax: 866.517.1406 http://RealEstateCE.com/
use Win32::Internet unix equivalent function?
Anyone know of a unix equivalent to win 32 function Win32::Internet Trying to capture a web page as a string i.e. $INET = new Win32::Internet(); $file = $INET->FetchURL("http://www.yahoo.com";;); Thanks, Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Killing Idle Users
Why can't you just put export TMOUT=3600 readonly TMOUT in /etc/profile ? If it doesn't work, contact the vendor (IBM for AIX) for a patch. --- "Akens, Anthony" <[EMAIL PROTECTED]> wrote: > Hello, > I'm a sys-admin on an AIX (4.3) machine, and I'm trying to work > with a vendor program that doesn't behave very nicely. Basically, > if a user's connection to the server is inappropriately severed > the application keeps right on chugging, leaving the user > logged in. By inappropriately severed I mean if our link to the > site the user is at goes down, which happens more often then > I'd like, but that's a different problem. > > Anyway, back to the question... > There are quite a few problems with these unconnected sessions > being stuck out there, not least of which is that they eat up a > user license, which are pretty limited in amount. One good power > outage or link failure at can make it so we're out of licenses. > In that event the vendor says "Kill them by hand, do NOT automate > the process" which is all fine and good except that we have > several hundred users. That's a lot of time. > > The first thought was to use a shell idle logout time, but the > program doesn't respond to the request and remains logged in. > > The previous administrator had made a shell script to check idle > times and automatically log out the users, however since I've > taken over the box the uptimes have been far greater (I don't > believe in the same "reboot often" premise that he did) and now > his script has shown a severe weakness: It's not written to > handle longer PIDs. > > Rather then trying to fix his shell script, which is rather > convoluted, I thought it would be a perfect candidate for perl, > which I am just learning. If I post the script, can I get some > pointers on re-writing it? Thanks for your time > > Tony Akens > [EMAIL PROTECTED] > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup http://fifaworldcup.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Use vs Require
I'm new to perl, but have a background in C. Can someone tell me what is the difference between 'use' and 'require'? When do you use one and not the other? Seems they both are comparable to a C header file (.h). Thanks in advance. Jeff __ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Flat File Db
I'm use flat files to manage a list containing approx 25,000 records. For updates, I write to a temp file then unlink main and rename temp file to main. I use flock for both temp and main files during update. My main file gets blown away on occasions. What gives? I can't figure out why this happens. Thanks for any help! Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Flat File Db
John, unix, sub Update_db { $main_db = $_[0]; $tmp_db = $_[1]; $update = $_[2]; open IN, "<$main_db" or print "Can't open $main_db: $!\n"; flock( IN, LOCK_EX ) or print "Unable to acquire lock: $!. Aborting"; open OUT, ">$tmp_db" or print "Can't open temporary file $tmp_db: $!\n"; flock( OUT, LOCK_EX ) or print "Unable to acquire lock: $!. Aborting"; while ( ) { ($name, $team, $location)= split(/\|/, $_); next unless $name eq $update; $new_location = "palm_bay"; $_ = join( "|", $name, $team, $new_location); } continue { print OUT $_ or print "Error writing $tmp_db: $!\n"; } close IN; close OUT; unlink $main_db; rename $tmp_db, $main_db or print "Can't rename '$tmp_db' to '$main_db': $!\n"; } -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 17, 2002 8:11 PM To: [EMAIL PROTECTED] Subject: Re: Flat File Db Jeff wrote: > > I'm use flat files to manage a list containing approx 25,000 records. For > updates, I write to a temp file then unlink main and rename temp file to > main. I use flock for both temp and main files during update. My main file > gets blown away on occasions. What gives? I can't figure out why this > happens. Thanks for any help! OS? code? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cron and Perl Script
I've never seen this syntax before: */5(from line: */5 * * * * root perl /home/sites/sa/cgi-bin/test.pl) Is that legal?! -J --- "Mike(mickako)Blezien" <[EMAIL PROTECTED]> wrote: > Remove the "root per" form the command line > > Max Hugen wrote: > > > > I have a simple perl script which I can run from the command line in the > > form: > > perl test.pl > > > > I am trying to run this from Cron every 5 minutes, but being as unfamilair > > with Cron as with Perl, I having problems - the cron job does not seem to > > run. My entry in /etc/crontab is: > > */5 * * * * root perl /home/sites/sa/cgi-bin/test.pl > > > > If anyone could suggest what I'm doing wrong, I'd most appreciate it! > > > > Thanks, Max Hugen > > Australia > > > > -- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > Mike(mickalo)Blezien > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > Thunder Rain Internet Publishing > Providing Internet Solutions that work! > http://www.thunder-rain.com > Tel: 1(985)902-8484 > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > __ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Conditional in regex
Hi all. I'm new to perl, a new programmer, and I badly need guidance. I'm trying to parse a config file with key/value pairs seperated by white space and surrounded by curly brackets. It has multiple fields that look like this: { Key value Key value } My solution has been to parse it with something simple -- while ($file_contents =~ /(\w+)\s*\{([^}]*)\}/gs) { push @new, $2; } foreach (@new){ $_ =~ /\b(\w+)\s+(.*)\s+ \b(\w+)\s+(.*)/xgs; My @next_tmp_variable = ($1, $2, etc); } -- but the config definitions contained in those curly brackets are different lengths. Some only have a four left hand values, while others have six or more. My solution isn't giving me what I really need. So I have two questions. First, I don't understand how to test this so that I parse all the values between the curly braces, regardless of how many items are there. Second, and equally important, what kind of data structure should I put the results in? I think I need a hash of hashes. What I'd like to do is assign each left hand value as the key in a hash. Then, in each set there's a left 'command' where the right hand value will always be unique, which would be perfect for use as the name of an alias for the hash or as the key to a reference to a hash of that definition. Is there a better way? What's the best method for assigning all that stuff? Thanks! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Conditional in regex
On 6/24/07 10:42 AM, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > You don't need to repeat the pattern by hand - the /g will do that for > you. > Thanks to everyone for the replies. I expected what you pointed out above, that /\b(w+)\s+(\w+)\s+/gs would match every instance of the pattern. Instead I got wildly results, with random letters in some variables and the values I wanted in a different offset every time. I cannot explain that, but the pattern works with the left hand values written as literals (/\b(word)\s+(.*)\s+/) > Are newlines significant? Or can just treat it as a list of > alternating keys and values delimited by whitespace? > This can be treated as key/values delimited by whitespace. I wonder if the unexpected results could be related to tabs or something else besides \n? How do I see what's used for white space? Shouldn't \s match any whitespace character? > Probably a list of hashes would be the most natural. > > my @LoH = map { { split } } $file_contents =~ /\{(.*?)\}/gs; Thanks. That's cool. Since this is the beginner's list, I'll just dive in and ask a(nother) dumb question. I'm not sure I understand the double curly braces around split. Would you mind showing me that in a less terse form? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Comparing numbers
This is a true beginner's question, so bear with me. I have an array of numbers. Is there a function to tell me which is larger (or smaller?) Also, how do I search with perldoc for a function when I don't know the name? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Comparing numbers
On 9/9/07 1:54 PM, "Douglas Hunter" <[EMAIL PROTECTED]> wrote: > Jeff wrote: >> This is a true beginner's question, so bear with me. I have an array of >> numbers. Is there a function to tell me which is larger (or smaller?) > > > Sure. Perl's 'sort' function is quite flexible, and supports > numerically sorting lists. `perldoc -f sort` describes what you want, I > believe. > > The short answer: Pardon the list clutter, but I have to say that this is what makes this particular list and the Perl community in general cool. Quick, helpful answers with no snark and an no bs. Thanks to everyone who answered. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
using GET and parsing content.
Hi, I'm using RedHat and it comes with LWP module called GET, POST written in PERL. What i'm trying to do is Write a loop that would take a list of names and send a GET to a URL then the retuned results i want to search for a Keyword. I do something like this: Read a list of names open(DOM, GET 'http://URL') || "unable to open website\n"; The GET here doesn't actually get the results it just dumps the main URL not the results. The URL is http://http://www.whitepages.com/find_person_results.pl?fid=n&f=&ft=b&l=$name<=b&c=&s=&x=45&y=10 I get stuck here...any pointers? Thanks Jeff
How can I send an HTML format email using send mail
Does anyone know how to send an HTML formatted email using sendmail. I can send plain text email OK. If I format the message using HTML the message shows the HTML tags. I can't find any information regarding this on cpan. Are there any other modules that have this capability? Any help is greatly appreciated. Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Automatic execute of script
Does anyone know how to get a script to execute at a predefined time without user interaction. I would like to monitor my sys clock and have the perl script execute. Thanks Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Automatic execute of script
Our business hosting service does not allow cron, they recommend checking with a third party. I write the scripts on a windows machine and upload them to the apache Unix server to test and execute them. Do you know of any perl modules that self execute? -Original Message- From: Jeff Liu [mailto:[EMAIL PROTECTED]] Sent: Friday, December 28, 2001 11:45 AM To: jeff; Beginners Subject: RE: Automatic execute of script If you are using Unix, add your script in /etc/crontab like this. 0 3 * * * root /usr/local/bin/your-script 0 means run at minute 0. 3 means run at 3:00a.m. * means every day Jeff Liu -Original Message- From: jeff [mailto:[EMAIL PROTECTED]] Sent: December 28, 2001 11:41 AM To: Beginners Subject: Automatic execute of script Does anyone know how to get a script to execute at a predefined time without user interaction. I would like to monitor my sys clock and have the perl script execute. Thanks Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Good CS Literature
I admire your philosophy! I purchased Learning Perl on win32 Systems by Schwartz, Olson & Christiansen read and worked the exercises and use it daily but now at a point where I want more. I want to get a hard copy of the perl reference, but not sure what and how to print it out. I'd like to start with the Perl Manpage, POD's (Supporting Manpages) and Perl Module Library. I can only print individual segments from perldoc.com. Does anyone know of an easier way to obtain this? There's a lot to be said for having a hard copy. Can't take my computer to bed but sure would like to fall to sleep skimming through perldoc. Jeff -Original Message- From: Michael R. Wolf [mailto:[EMAIL PROTECTED]] Sent: Saturday, December 29, 2001 12:35 AM To: [EMAIL PROTECTED] Subject: Re: Good CS Literature Luke <[EMAIL PROTECTED]> writes: > I bought the Learning Perl by Orielly but I returned it > after realizing thats its almost the same as > perldoc/manuals... "Learning Perl" is a tutorial perldoc is a reference [...] > My problem with programming is that i dont know if im > doing the right thing... It sounds like you need a tutorial to start with. The references are good once you've got a lay of the land, but a reference is different from a tutorial. The organization of a tutorial is to start at nothing, and build understanding in logical steps. The organization of a reference is for finding out the particulars of a given function or operator if you already know that's what you want. Perhaps you should reconsider working through the tutorial. It's how I got started with Perl over 5 years ago. I worked through it *once*, then never looked at it again. It's a "disposable" jump start into the reference (which is dog eared and very heavily marked and used). > Yes the program/script works but Im not sure if its > effecient or not... I, too, started programming as a senior in HS. Hard to believe that's 20+ years ago. Time flies like an arrow (but fruit flies like a bannana). One of the things I've learned in that time is that most jobs have two steps. 1. get it right 2. get it fast Most jobs don't have the luxury of getting to step 2. Apply the rule of ducks - if it looks like a duck, quacks like a duck, and possibly flies like a duck -- it's probably a duck. Translated: If it looks like it's working software, and it acts like working software -- it's working software. (i.e. who cares if it's not effecient? If you care next week, you can re-work it next week.) And, as a training exercise, you can take working software, make some changes and see what happens. If you break it, restore it and try something different. What did you learn? If it still works, what did you learn? The basic idea here is to have *working* software to muck around with. You don't learn as well with broken software. Get it to work (dirty, ugly, slow, whatever), then keep it working as your refine it into clean, pretty, fast software, and learn lots along the way. If you work with broken software, you're not sure that what you did to transmute broken software into broken software is something worth remembering. We call it playing with code, but it's really a code word for learning -- take a look at my signature file, and have fun. Computers have been a continual mental exercise, and larning adventure for me. Good luck on your adventure, Michael -- Michael R. Wolf All mammals learn by playing! [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Automatic execute of script
Thanks for all the help on my question. I picked the solution to periodically request a web page on a daily basis (using my browser) to execute my perl script. Although the "sleep x" worked great I think I will have problems because our business host server goes down for periodic maintenance. I think this would stop execution of the script. The cron is not allowed by our business host account and autosys costs money. I am still investigating the AT command. Thanks again!! Jeff -Original Message- From: Chris Spurgeon [mailto:[EMAIL PROTECTED]] Sent: Friday, December 28, 2001 1:32 PM To: 'Tom Bartos'; jeff; Beginners Subject: RE: Automatic execute of script You can sometimes get at it from the client side...if you can set up something on a machine that you control to periodically request a webpage from the server, and if that web page runs the perl script you want to fire, you can accomplish the same thing that way. Chris Spurgeon Senior Design Technologist [EMAIL PROTECTED] ELECTRONIC INK One South Broad Street 19th Floor Philadelphia, PA 19107 www.electronicink.com t 215.922.3800 x(233) f 215.922.3880 -Original Message- From: Tom Bartos [mailto:[EMAIL PROTECTED]] Sent: Friday, December 28, 2001 12:55 PM To: jeff; Beginners Subject: Re: Automatic execute of script the AT command works a lot like cron, see if you can use the AT command - Original Message - From: "jeff" <[EMAIL PROTECTED]> To: "Beginners" <[EMAIL PROTECTED]> Sent: Friday, December 28, 2001 9:37 AM Subject: RE: Automatic execute of script > Our business hosting service does not allow cron, they recommend checking > with a third party. I write the scripts on a windows machine and upload > them to the apache Unix server to test and execute them. Do you know of any > perl modules that self execute? > > -Original Message- > From: Jeff Liu [mailto:[EMAIL PROTECTED]] > Sent: Friday, December 28, 2001 11:45 AM > To: jeff; Beginners > Subject: RE: Automatic execute of script > > > > If you are using Unix, add your script in /etc/crontab like this. > > 0 3 * * * root /usr/local/bin/your-script > > 0 means run at minute 0. > 3 means run at 3:00a.m. > * means every day > > Jeff Liu > > > -Original Message- > From: jeff [mailto:[EMAIL PROTECTED]] > Sent: December 28, 2001 11:41 AM > To: Beginners > Subject: Automatic execute of script > > > Does anyone know how to get a script to execute at a predefined time without > user interaction. I would like to monitor my sys clock and have the perl > script execute. Thanks > > Jeff > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This e-mail is intended solely for the above-mentioned recipient and it may contain confidential or privileged information. If you have received it in error, please notify us immediately and delete the e-mail. You must not copy, distribute, disclose or take any action in reliance on it. In addition, the contents of an attachment to this e-mail may contain software viruses which could damage your own computer system. While Electronic Ink, Inc. has taken every reasonable precaution to minimize this risk, we cannot accept liability for any damage which you sustain as a result of software viruses. You should perform your own virus checks before opening the attachment. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: defined{ness}
Dermot : Hi All, I am unsure if the following statement is going to do what I want. I want to test if there is a value in $hash_ref{'someval'} NOT if the key is defined. I'd also like to avoid un-sightly "undefined value" errors. So which of the following is best: if (defined($hash_ref{'someval'}) {} I may think this is the better way. also you can check perldoc -f exists and find something like: print "Exists\n" if exists $hash{$key}; print "Defined\n" if defined $hash{$key}; print "True\n" if $hash{$key}; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Matching Over Multiple Lines
All, I know this has been asked many times, and I have read the documentation ("perldoc -q "matching over more than one line") and still can't make head or tails out of this. I have a problem where my pattern can be in one line, or span multiple lines. This is what I have so far (simplified): #!/bin/perl use warnings; use strict; $/ = ''; my $pat = << 'EOF'; ^ AAA (.*)? ZZZ $ EOF my $file = "./mytext"; while () { if ( /$pat/gms ) { print "vv\n"; print "FOUND: $_"; print "^^\n"; } else { print "vv\n"; print "NOT FOUND: $_"; print "^^\n"; } } __DATA__ AAAthis is the beginning of our text and it will continue over a few lines. In case you are not sure of what you see, you should check the document yourself.ZZZ This part has nothing to do whatsoever with the above text, but to be sure, you should not see this. AAABut this single line you should seeZZZ AAABut this double line, so the question is do you see itZZZ This part you will not see. I am not sure if I can use $/ to gobble up a paragraph, since we are reading and parsing XML files, which are around 10M in size. I need to do a non-greedy pattern match. Can someone tell me what I am doing wrong please? Thanks in advance, Jeff
RE: Calling subroutine every second using alarm fails
> Original Message > Subject: Calling subroutine every second using alarm fails > From: Kelly Jones > Date: Wed, April 01, 2009 5:48 am > To: beginners@perl.org > > > I want a script that constantly accepts user input, but runs a > subroutine every second to do other work. what I thought is to fork a child to do the stuff. my $child = fork; die "cant fork $!" unless defined $child; if ($child) { # in parent while(<>) { # do something } } else { # in child while( some_condition ) { # do stuff sleep 1; } exit 0; } regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: WIN32:OLE module
> Hi All, > > I have one perl script in which i am using win32:OLE perl module. Now i need > to convert script so that it can support solaris OS also. can it be possible?? > if yes what is the equivalant module of win32:OLE on unix or any other option. > I don't think it's possible.. you may run a windows virtual machine under solaris then run win32::OLE scripts in the VM. regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
default timeout for IO::Socket::INET
I checked perldoc documents but didn't find a default timeout value for IO::Socket::INET object. Who knows that? thanks. regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: default timeout for IO::Socket::INET
oh will be trying to connect to the remote host forever until it gets successed? that sounds not reasonable.thanks. > Original Message > Subject: Re: default timeout for IO::Socket::INET > From: "Chas. Owens" > Date: Thu, April 02, 2009 5:19 am > To: Jeff Pang > Cc: beginners@perl.org > > > On Thu, Apr 2, 2009 at 08:11, Jeff Pang wrote: > > I checked perldoc documents but didn't find a default timeout value for > > IO::Socket::INET object. > > Who knows that? thanks. > snip > > Based on my reading of the code it looks like it doesn't timeout by default. > > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: Strip email attachments using IMAP.
Could use Net::POP3 to fetch the whole message, then use MIME::Lite(::*) to parse it and get the attachment (given the case you know something about rfc822). regards. > Original Message > Subject: Strip email attachments using IMAP. > From: Meghanand Acharekar > Date: Sat, April 18, 2009 3:26 am > To: beginners > > > Hi, > > Is it possible to strip email attachments from a remote IMAP folders & save > or download them on local system (system on which script is running) > > I written a simple script using perl IMAPClient which connects IMAP server > and read emails from there, but found no method to strip attachments ? > > Any Ideas. > > > -- > Regards, > > Meghanand N. Acharekar > " A proud Linux User " > Reg Linux User #397975 > -- > I was born free! No Gates and Windows can restrict my Freedom !!! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: libwww-perl library
> Original Message > Subject: libwww-perl library > From: hOURS > Date: Tue, April 21, 2009 3:27 pm > To: beginners@perl.org > Can't locate LWP/Simple.pm in @INC (@INC contains: .) at testC.pl line > 1. BEGIN failed--compilation aborted at testC.pl line 1. > Simply say, you should install LWP::UserAgent in the host. Regards. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Perl module for LibFetion
Fetion is a popular mobile IM application here (it can be run at PC too). There is also a library calls LibFetion on internet, which provides API for 3rd developing (http://www.libfetion.cn/libfxAPI/). There are python modules for Fetion,but lack Perl's.I was thinking who could have that time or ability to write that a module on CPAN, will be great for us Chinese people. I can help translate the CN language during the process. Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Save html page using perl
Sarsamkar, Paryushan: Hi, I have a URL, which displays different content at different time. Now I want to save the page as html page to a particular location. How can I do that using perl? I once did the same stuff, so I share the script to you. sub get_web { my $url = shift; my $timeout = 35; chdir "/data/wget"; eval { local $SIG{ALRM} = sub {die "timeout!\n"}; alarm $timeout; system("wget -p -q $url"); alarm 0; }; if ($@) { system("killall -9 wget"); } } We use "wget -p" to get the page and its full dependency. You could also use LWP but that's complicated to fetch the page and all its dependency. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Save html page using perl
s...@z107.de: hi, On Fri, May 22, 2009 at 03:52:59AM -0400, Sarsamkar, Paryushan wrote: I have a URL, which displays different content at different time. Now I want to save the page as html page to a particular location. How can I do that using perl? use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(GET => "http://example.com";); my $res = $ua->request($req); open(FILE, ">", "/tmp/index.html"); print FILE $res->content; close(FILE); that's not helpful enough if you are accessing a rich page like news.yahoo.com. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Save html page using perl
Gunnar Hjalmarsson: Jeff Pang wrote: We use "wget -p" to get the page and its full dependency. You could also use LWP but that's complicated to fetch the page and all its dependency. I thought that the portable WWW::Mechanize was the way to go rather than wget when there is a need to follow links. yes, as I said, that's complicated since one need to analyze and scratch each linked resource in the page. use "wget -p" do anything with just one line. also installing wget is simpler than installing WWW::Mech. I have tried both ways, so I said these. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Need help with Email::Send
2009/6/22 Dennis G. Wicks : > Greetings; > > I can't seem to find the problem with the Email::Send portion of this > program. It may be that I am getting an error from the smtp server but I > haven't been able to adapt an error routine that works with Mail::Sender to > work with Email::Send. > I have seen these info on the module's page: Email::Send is going away... well, not really going away, but it's being officially marked "out of favor." It has API design problems that make it hard to usefully extend and rather than try to deprecate features and slowly ease in a new interface, we've released Email::Sender which fixes these problems and others. As of today, 2008-12-19, Email::Sender is young, but it's fairly well-tested. Please consider using it instead for any new work. So, you may consider to use Email::Sender instead. For testing of this module, you could take a look at: http://search.cpan.org/~rjbs/Email-Send-2.197/lib/Email/Send/Test.pm -- In this magical land, everywhere is in full bloom with flowers of evil. - Jeff Pang (CN) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: redirecting STDERR with IO::Tee
2009/6/23 : > I have a script which runs mostly via a cron job and sometimes interactively. > I would like STDERR to automatically print to both the console and to a > logfile simultaneously. > > Right now I've gotten as far as merging both file handles with IO::Tee but > I'm not sure if I'm heading down the right path. > my $merged_stderr = IO::Tee->new( \*STDERR, new IO::File(">>$errlog") ); > > This only works when explicitely naming the file handle in a print statement. > How can I take it to the next step, which is to have STDERR automatically > print to that file handle? > > Hi, What causes writting of STDERR? If it's due to die and warn, you could redirect them to the customized routines. Something like: $SIG{__DIE__}=\&log_die; $SIG{__WARN__}=\&log_warn; sub log_die { my $time=scalar localtime; open (HDW,">>",$err_log); my $old=select HDW;$|=1;select $old; print HDW $time," ",@_; close HDW; die @_; } sub log_warn { my $time=scalar localtime; open (HDW,">>",$err_log); my $old=select HDW;$|=1;select $old; print HDW $time," ",@_; close HDW; } -- In this magical land, everywhere is in full bloom with flowers of evil. - Jeff Pang (CN) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: how to choose a threading or forking http server module from CPAN
2009/7/6 XUFENG : > Hi, > I plan to implement a threading or forking http server to receive > client request,after handling the requested url,it gives out new urls. > What is the better module to use? A perl module or httpd module? for perl module, could use CGI.pm and look for redirect() method. for httpd module, use the powerful mod_rewrite. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: PDF generation from a database!!
?? Dan ? This is exactly what I wrote PDF::ReportWriter for. It supports grouping with headers & footers, aggregate functions, intelligent page-breaking ( can't make css do that ), images, lots of text formatting options, PDF templating, XML report definitions, etc, etc. http://entropy.homelinux.org/axis/ ( click on 'reports' at the top ). Looks cool and can be useful.Thanks for the work. -- Jeff Pang pa...@vfemail.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl's superior text parsing power
?? "Shawn H. Corey" ? Dave Tang wrote: I wanted to ask why is Perl, in comparison to other programming languages, so powerful in text processing? Undoubtedly, when it was written, Perl was the most powerful text processing language available. This is no longer the case (thanks largely to Perl :). Today's scripting languages have the same text processing abilities as Perl. You will find this true of Perl's documentation; some of it has not been updated in quite some time. I agree. No language is absolute more advanced than others in today. See this speed comparison of script languages: http://mastrodonato.info/index.php/2009/08/comparison-script-languages-for-the-fractal-geometry/?lang=en -- Jeff Pang pa...@vfemail.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: execute in another terminal
?? "Bryan R Harris" ? Not exactly a perl question, but I'd certainly like to use this with perl... Is it possible from one terminal window in linux (RH) to tell another terminal to execute a shell command, e.g. perl script, just as if you typed it there? Is it the stuff perl's system() or `` does? system(...) or `...` will run another process but it's in the same terminal. I'm not sure why you want to open another terminal for tasks. :) -- Jeff Pang pa...@vfemail.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perldoc modules
2009/9/5 Noah Garrett Wallach : > Hi there, > > this might be obvious but how can I find a list of all the perldoc modules? > All standard modules including core and non-core modules have perldoc interface. For checking core modules: http://search.cpan.org/~rgarcia/Module-CoreList-2.18/lib/Module/CoreList.pm -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hash of Hashes
2009/9/29 Shawn H Corey : > Soham Das wrote: >> >> How can I create a Hash of Hashes from two lists. Is it possible? >> >> I want the effective functionality to be served like this >> >> $ChildHash["Joe"]["21A"]="Sally" >> >> i.e Joe at 21A has a child called Sally. List1 here will be the name of >> Parents, List2 here will contain the house number. > > Hashes use {}, arrays use [] > That's in Python? :-) Perl's both hash and array use (). But anonymous hash and array use {} and []. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: get list of files sorted by date
2009/9/29 Andreas Moroder : > Hello, > > according to the man glob can only sort by name. Is there a way to get a > list of files sorted by date ? > sure. first I will use unix's ls command like ls -ltr. in perl one of the ways: my @sorted = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_,(stat $_)[9]] } glob "*"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Wants to migrate from one machine to another.
Since you know the scripts' names you may find what modules they are using: http://search.cpan.org/~elliotjs/Module-Used-v1.2.0/lib/Module/Used.pm 2009/9/29 Raheel Hassan : > Hello, > > We have one software which is installed at one machine. The software was > developed by many developers(students) as it was used in multiple projects > in the lab, all the code is written in perl. Now we want to do the backup of > that software for that we want to make one copy running on a new machine. > The problem we are facing is that we installed many CPAN modules and > different developers used different CPAN modules and non of them did the > documentation. I need your guidance that how we know that the software is > using which modules plus on a new system we wants to preinstalled all the > modules before moving the software. > > > Regards, > Raheel. > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: HI
2009/9/30 Jyoti : > Thanks for reply Rajiv. Will go through.Also can you explain me what this > error means: > Odd number of elements in anonymous hash at > /usr/lib/cgi-bin/websubroutine.pl line 18. That may mean, you passed wrong arguments to the method in a class. The method expects a hash, should have even number of elements. > > line 18 is as follows: > > print $q->header("text/html"), > Maybe you got wrong in other location. This statement has no problem for me: # perl -MCGI -e '$q=CGI->new;print $q->header("text/html")' Content-Type: text/html; charset=ISO-8859-1 Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Re: return {}->{'name'};
On Nov 15, 2009, Uri Guttman wrote: > "PK" == Parag Kalra writes: >and yes, that is declaring a constant. you can tell it is a hash as it >is initialized to a hash reference. it makes little sense to me why you >would declare such a beast as the reference can have its contents >altered and so it really isn't constant. the symbol 'cache_result' can't >have its value changed from the initial hash reference. I would say it's an anonymous hash instead of a hash reference. :) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl CGI Incremental find
This is the stuff JavaScript will do, nothing about CGI, which is a server-end implement. On Nov 17, 2009, Dave Tang wrote: Hi everybody, Is it possible to implement an incremental find* feature on a Perl CGI page? I'm running Apache2 with mod_perl on linux. For example, if I have a list of stuff (A, Aa, B, Bb, C, CA, etc. stored in a file or database) and when a user starts typing in A into the web form, 2 suggestions in a drop down menu will come up (A and Aa but not CA). Users will be able to click on this drop down menu and the web form will be filled with what they clicked on. A real life example would be Google Suggest**. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: how do i ???
Hi, seems you're in un*x shell, so ">" is a valid redirection for perl script's output. if you also want to redirect the stderr then do: perl my.pl > out.txt 2>&1 redirect STDOUT in perl script itself: open HD,">","out.txt" or die $!; open STDOUT,">&HD" or die $!; HTH. On Nov 17, 2009, Subhashini wrote: is there a possiblity how i cud run a perl script and redirect the output example my file name is my.pl Could i do perl my.pl > out.txt -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Emailing all pdf files in a directory
This module's document is very few. I think you should write with @files = to get the full path for pdf files. After that you pass the anex argument when calling the function: my $status = Mail::SendEasy::send( smtp => 'localhost' , ... anex => \...@files, ); HTH. On Nov 17, 2009, Tiffany wrote: Hello, I am not very familiar with Perl, but I am trying to use it to email all files within a directory that have a .pdf extension using the anex command within the Mail::SendEasy module. I have created an array with my filenames using @files = <*.pdf>; but I am not sure how to translate that array into email attachments using anex. Any suggestions would be appreciated! -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Re: Looking for advise on storring a complex array
For SQLite, just perl -MCPAN -e 'install DBD::SQLite', then use the general DBI to create and access SQLite database. you even don't need to install SQLite binary program. On Nov 18, 2009, Dermot wrote: 2009/11/18 Rob Coops : > On Mon, Nov 16, 2009 at 10:09 PM, Rene Schickbauer < > rene.schickba...@magnapowertrain.com> wrote: > >> Rob Coops wrote: > > Thank you for the advise, I'll certainly be using a DB should this tool ever > get upgraded to a web based one. You'd be hard pressed to find a *nix machine without SQLite pre-installed. It's often used by the package manager. It's bloody fast too. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Is unlink() supposed to provide an error message on failure?
So write the code like: unlink $file or die $!; This will throw up an error message and die. On Nov 19, 2009, David Christensen wrote: beginners: Is unlink() supposed to provide an error message on failure? The documentation does not say so: http://www.perl.com/doc/manual/html/pod/perlfunc/unlink.html Testing indicate that unlink() sets $! on failure: -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Connection pooling implementation in perl
Hi, If you're running a webprom under mod_perl, then Apache::DBI is maybe what you wanted. On Nov 26, 2009, Praveena Vittal wrote: Hi All, We would like to implement connection pooling for mysql database in Perl. Can anyone help in this? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Can I design a website using Perl
Parag Kalra: So what are the main Perl modules which I need to install and any good tutorial link would be really appreciated. For the modules, CGI and DBI is mostly what you wanted, these two modules are built-in ones in recent perl release. For documents see "perldoc CGI" and "perldoc DBI". And you may need to install the database driver, for example, you are using Mysql, then should install DBD::mysql for DBI. For other sources, try google "Ovid's CGI Course", I remember there is such a free CGI course made by Ovid. -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Eval scoping question
Anders Hartman: Hello, I which to use eval to execute subroutines dynamically. The following code snippet fails: #!/usr/bin/perl use strict; use warnings; sub asub { our $abc; print $abc; } my $abc = "abc\n"; eval "asub"; exit 0; I don't think you want an eval here. use strict; use warnings; our $abc = "abc\n"; sub asub { print $abc; } asub; Also you may want to know something about Perl's variable scope, see: http://perl.plover.com/FAQs/Namespaces.html.en -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Eval scoping question
Shlomi Fish: Regarding using string eval "" - you can do the same using UNIVERSAL::can, which would be safer in this case: <<<< __PACKAGE__->can("asub")->(@params); or define a package and use AUTOLOAD method? -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Eval scoping question
Shlomi Fish: On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote: Shlomi Fish: Regarding using string eval "" - you can do the same using UNIVERSAL::can, which would be safer in this case: <<<< __PACKAGE__->can("asub")->(@params); or define a package and use AUTOLOAD method? How will the AUTOLOAD method help you here? sub AUTOLOAD { our $AUTOLOAD; print "I see $AUTOLOAD(@_)\n"; } asub("abc"); # prints: I see main::asub("abc") > And AUTOLOAD is almost always not > a good idea. Why? Thanks. -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: passing Hash to subroutine help please
Noah: sub exiting { my ($hostname, %login) = @_; Passing arguments like this has no such problem. But you'd better pass the hash as a reference to the subroutine. exitint($hostname, \%login); sub exiting { my $hostname = shift; my %login = %{+shift}; ... } print "login: $login $hostname\n"; I don't see where you defined the variable of $login. Have you 'use strict' and 'use warnings'? -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: passing Hash to subroutine help please
John W. Krahn: Jeff Pang wrote: Noah: sub exiting { my ($hostname, %login) = @_; Passing arguments like this has no such problem. But you'd better pass the hash as a reference to the subroutine. exitint($hostname, \%login); sub exiting { my $hostname = shift; my %login = %{+shift}; What is the point of passing a reference if you are just going to copy the whole hash anyway (which is what the OP was doing)? If people want to change the hash's elements in subroutine and don't want to influence the original one, then passing a copy is right. Otherwise copy a hash is wasteful for memory, given the size is large. :) -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: assign operator
Irfan Sayed: Hi All, Can somebody please tell me what is the difference between "=" and ":=" sign in case of perl?? I never saw ":=" in any perl code. Also I checked perlop and didn't find that a symbol. http://perldoc.perl.org/perlop.html -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
force using the version of a module
Hello, The latest version of LWP::UserAgent (v5.834) has a method of "local_address", which is needed by my software. The lower version of this module (for example, v5.824) doesn't have that method. So how to force to use the latest version of LWP::UserAgent in the perl script? Thanks. Merry Holidays! Jeff. Love Spell Click here to light up your life with a love spell! http://thirdpartyoffers.netzero.net/TGL2241/c?cp=WY6rCVc8u7r0rhlGINenTgAAJ1F5p0Q5uwV0jfKaKm9vU9yEAAYAAADNRwA= -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: force using the version of a module
Peter Scott : % perldoc -f use use Module VERSION LIST use Module VERSION [...] If the VERSION argument is present between Module and LIST, then the "use" will call the VERSION method in class Module with the given version as an argument. The default VERSION method, inherited from the UNIVERSAL class, croaks if the given version is larger than the value of the variable $Module::VERSION. Thanks. That's right for me. Regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Clone an object
Uri Guttman: and i bet you really don't need this but you just think you do. why not? I did have used object clone, like a ruby one: > class Myclass > end => nil > x=Myclass.new => # > y=x.clone => # > x.object_id => -605921708 > y.object_id => -605931318 The object was cloned, they both got different object IDs. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Script to create huge sample files
Parag Kalra: I am curious to know more on UTF and understand related issues that may creep in my algorithm. Could someone please shed some light on it. Can I use following: use Encode; while(<$sample_file_fh>){ # Encoding into utf data $utf_data = encode("utf8", $_); For the line above, I may think it's not right. What you got from <$sample_file_fh> is maybe different encoding chunk, for example,iso-8859-1,gb2312 or UTF-8 etc. You want to translate them to Perl's internal utf8 format firstly,which includes a utf8 flag and the data part.After translation,utf8 flag should be on and the data part is the chunk with utf8 encoding.You do it with the decode() function from Encode module: my $internal_utf8 = decode("gb2312",$_); # given the data was gb2312 encoding originally After that,you could translate the $internal_utf8 to any encoding string you want, use the encode() function from Encode module as well: my $output = encode("utf8",$internal_utf8); # output with UTF-8 encoding HTH. $data_string = $data_string.$utf_data; } -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Script to create huge sample files
Parag Kalra: Hmmm - http://search.cpan.org/~dankogai/Encode-2.39/lib/Encode/Guess.pm It says right at the bottom that below method won't work to guess the encoding. :( Encode::Guess maybe work, but not so exactly. Because some Code Bits of an encoding are overlapped (for example,gb2312 and gbk),so you can't get the encoding style of a small string just by guess. But for large text,it maybe work rightly. Here is another guess way (not by me) you may reference to: use Encode; use LWP::Simple qw(get); use strict; my $str = get "http://www.sina.com.cn";; eval {my $str2 = $str; Encode::decode("gbk", $str2, 1)}; print "not gbk: $...@\n" if $@; eval {my $str2 = $str; Encode::decode("utf8", $str2, 1)}; print "not utf8: $...@\n" if $@; eval {my $str2 = $str; Encode::decode("big5", $str2, 1)}; print "not big5: $...@\n" if $@; HTH. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
regex optimization
Hello, Can the code (specially the regex) below be optimized to run faster? #!/usr/bin/perl for ($i=0; $i<1000; $i+=1) { open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; } close HD; } The "index.html" is got from: wget http://www.265.com/Kexue_Jishu/ I ask this because someone posted a question on ruby-talk list, shows perl's regex is much faster than ruby's. [Quote] #!/usr/bin/ruby 1000.times do File.open("index.html").each do |c| puts $1 if /href="http:\/\/(.*?)\/.*" target="_blank"/ =~ c end end time ./test.rb >/tmp/t elap 6.511 user 6.336 syst 0.136 CPU 99.40% #!/usr/bin/perl for ($i=0; $i<1000; $i+=1) { open HD,"index.html" or die $!; while() { print $1,"\n" if /href="http:\/\/(.*?)\/.*" target="_blank"/; } close HD; } time ./test.pl >/tmp/t elap 0.864 user 0.844 syst 0.020 CPU 100.04% So perl is 7 or 8 times faster here. [/Quote] But someone another optimized the ruby code and used ruby's built-in scan method, which makes the regex run a lot faster. [Quote] I get best results in Ruby with: regexp = %r{href="http://([^"/]*)/[^"]*"\s+target="_blank"} 1000.times do puts File.read('index.html').scan(regexp) end ~/ruby/bench time ruby19 regex.rb > /dev/null real 0m1.428s user 0m1.359s sys 0m0.056s ~/ruby/bench time perl5.10.0 regex.pl > /dev/null real 0m1.189s user 0m1.095s sys 0m0.084s It's still slower. Perl has regular expression magic beyond my imagination, though. I heard they take the most "rare" character in the literal part of the regex (let's say, the colon) and search for it using machine code, and then work their way backwards to the beginning of the regexp... Say what you want, but Perl rocks when it comes to text processing speed. [/Quote] So I'm asking what's Perl's optimization for that regex. I hope this doesn't disturb everyone, thanks. Regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Regarding module Mail-Box, and accessing "subject" field of a MBOX message
On, 2010-01-07 at 11:24 -0800, Shankar wrote: > Hello, > > I'm using CPAN module, Mail-Box-2.093, to parse and process my MBOX > file on Unix. > > I have a message as follows. > I have an email, when I open in PINE on Unix, it shows the header as: > [utf-8] Recommendation Letter... > > When I try to access this field using the Mail-Box module, I get a > string which looks encoded. > Something like: =?utf-8?b? > umvjb21tzw5kyxrpb24gbgv0dgvyigzvcibeci4grc4grgfz?= > That looks like an utf8 string with base64 encoded. You may reference to: perldoc Encode perldoc MIME::Base64 for details. Regards, Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perl to flash
On 五, 2010-01-08 at 14:36 -0500, Uri Guttman wrote: > > i hate to be the police on questions here but recently we seem to have > been getting a fair number of them that are not beginner level. > Before stopping anyone from posting this "NON-Begin" questions, you must be able to define "what's a begin question for perl". You may write that a FAQ on PerlFAQ or wiki then tell everybody about the urls, :) Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Basic Domain and IP Info
在 2010-01-17日的 11:16 -0600,Mike Blezien写道: > Hello, > > I've been looking for some basic domain/IP info that we can generate for > domain/IP addresses entered from a form. I've been searching CPAN without > much > luck, but maybe looking in the wrong places. What I like to do is obtain the > following information for the domain/IP address: > > Name Servers for the domain name > IPs associated with the domain > What/How many sites are using the IP > Reverse IP Lookup > HTTP Status Code > > Are there any Perl modules, toolkits, available that do these type of task? > Hi, What you want is an integrative Perl program, not just a perl module. The 1st,2nd and 4th could be done by Net::DNS module. For the 3rd item, do you mean how many virtual hosts are located in an IP? That is not easy to gather, unless you are the hostmaster of those IPs. For the 5th item, you may look at HTTP::Status following with LWP::UserAgent module if I understand for you correctly. HTH. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Geeky way to wish Happy Birthday through Perl
在 2010-01-17日的 23:34 +0530,Parag Kalra写道: > Hello All, > > I am looking for a geeky way to wish someone on his Birthday with the help > of Perl. > > Condition is - It should be one liner which I can directly execute from the > command line. > > EG: perl -e "print 'Happy Birthday Larry!!!'" > Google it with "just another perl hacker". -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Data file with records that span two lines
在 2010-01-19二的 00:09 -0500,Perl Noob写道: > I have a data file with thousands of records. The problem is that the > records in the data file span two lines for each record. I want to > write a perl script that makes each record a single line. The file > looks like this: > HI, If you are using a regex, then may want to try the /m option. see perldoc perlre for details. I give the code below, it could work for me. use strict; local $/="RECORD1FIELD5\n"; while() { my @fields = /\w+/gm; print "@fields\n"; } __DATA__ RECORD1FIELD1 RECORD1FIELD2 RECORD1FIELD3 RECORD1FIELD3 RECORD1FIELD4 RECORD1FIELD5 RECORD2FIELD1 RECORD2FIELD2 RECORD2FIELD3 RECORD2FIELD3 RECORD2FIELD4 RECORD2FIELD5 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: how to convert perl file into binary
在 2010-01-21四的 10:51 +0530,V U Maheswara rao k写道: > Hi All, > > can I convert perl file into binary file? So that my code will be secure/. > perldoc -q 'hide the source' -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Win32 version 0.27 required
> Hi, > > I'm running Perl on Windows XP, and have a script which I've run for > ages with no problems. However, I now have a message per below: > > "Win32 version 0.27 required--this is only version 0.24 at D:/Perl/lib/ > Cwd.pm line 663." > > .. .and the script quits on me. > You may want to upgrade Win32 module to the latest one: http://search.cpan.org/~jdb/Win32-0.39/Win32.pm HTH. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Archive::Zip library on Solaris
> I have a Perl Script that uses some of the Archive::Zip's methods for > reading zip entries. Works fine on Linux, BUT on Solaris, this lib is not > available in Solaris and I'm not allowed to install any lib in it. Is there > a way to load the archive::zip lib dinamically, without installing it on the > OS? You could download the module and install it by hand under your home directory. Then use lib '/path/to/module_dir' to include the directory in the scripts. HTH. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: variable scope
在 2010-02-05五的 06:27 -0800,Eric写道: > I have a program that requests many config values from an ini file > using Config::IniFiles. I import all of these values into my main:: > script but it's pretty ugly. Is there a way to import my value > definitions int variables in a sub or another module and have them > visible in the main:: scope as local variables. > I once wrote a simple document for it, see: http://home.arcor.de/pangj/share_variables_between_perl_scripts.txt HTH. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XML to RDF using O O Perl
On Thu, Feb 11, 2010 at 6:00 AM, Aravind Venkatesan wrote: > Hello, > > I am new to perl. I am trying write a Perl module to convert KGML (XML file) > to RDF format . Could anybody suggest as to how to go about this (just to > give me a start). > Hi, You may pick a book for learning some base knowledge about Perl's object stuff. The commercial book from OReilly: http://oreilly.com/catalog/9780596004781 The free book: http://www.greenteapress.com/perl/ HTH. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: How to keep script alive if my shell closes
On Wed, Feb 10, 2010 at 2:40 AM, Ariel Casas wrote: > > My question is; how do I keep my perl script from dying if my shell > window accidentally closes while my perl script is paused at the > system function portion of my script? Hi, Make a daemon process for running in the script, or use nohup: nohup perl a.pl HTH. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: prepare(SELECT ... FROM TABLE) error
On Thu, Feb 11, 2010 at 2:03 AM, Jay Savage wrote: > > $@ is also *guaranteed*--in the words of perlfunc--to be set > correctly. I believe that historically this may not have been the > case: $@ may have only been set on failure and not flushed on success, > but in recent Perls it should be reliable. I also agree. > I'm also curious under what circumstances you believe > the eval could fail but $@ not be true (i.e., when would you expect > your code to print "unknown"?). > I think Ruud didn't mean eval fail but $@ not be true. If I understand for that correctly, what he tried to explain is, under some cases the $@ is set by other eval {} call, not the current eval {} you followed. Though I don't know if there is the case it will happen... Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl CGI advise/feedback please ...
On Thu, Feb 11, 2010 at 10:18 AM, newbie01 perl wrote: > > I need some guidance if someone know of any existing set of CGI-BIN scripts > that I can just plug it and used for this purpose. > Will you run the scripts under the share hosting environment? If so you are very hard to get the application secure. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl Hiding Username/Password
On Thu, Feb 11, 2010 at 7:04 AM, newbie01 perl wrote: > The worry is someone getting access to the script and then putting in some > print commands to expose the username and password information. Could take a look at: perldoc -q 'hide the source' -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: How to keep script alive if my shell closes
On Thu, Feb 11, 2010 at 6:39 AM, Shawn H Corey wrote: > > You can do the same thing inside Perl with %SIG: > > $SIG{HUP} = 'IGNORE'; > Also "nohup" redirect all stdout and stderr to a file "nohup.out". So you have also to reopen STDOUT and STDERR to a file handle if doing it in the script. btw, Cheers Chinese New Year for all Chinese Perl users. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: PayPal API
On Tue, Feb 16, 2010 at 8:45 AM, Mike Blezien wrote: > Hello, > > we are in the process of setting up an API for Paypal's Masspay and was > looking at the module: > > Business::PayPal::API::MassPay > > Has anyone had any experience using this module? Any bugs in it? > Hi MIke, I never used this module by myself. But the module's author was active on mod_perl's mailing list IIRC. You may repost the question to that list to expect an answer. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
make an alias to function
Hi, I have a module, and I wanted to make an alias with a function in that module. package abc; { # make an alias to another function no strict 'refs'; *{__PACKAGE__::init_squid_for_reverseproxy} = \&init_reverseproxy; } But this won't work when calling it: my $obj = abc->new; $obj->init_squid_for_reverseproxy; The error says: Can't locate object method "init_squid_for_reverseproxy" via package "abc" . Why? OK I simply updated the alias definition to: *init_squid_for_reverseproxy = \&init_reverseproxy; This works as I want. Is this the suitable one? Thanks. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: make an alias to function
On Tue, Feb 16, 2010 at 3:40 PM, Uri Guttman wrote: > *{__PACKAGE__::init_squid_for_reverseproxy} = \&init_reverseproxy; > *{ __PACKAGE__ . '::init_squid_for_reverseproxy' } = \&init_reverseproxy; > Thanks Uri. I really by mistake thought those two are the same stuff. Now I got it. :) -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Copy files from one machine to another machine
On Wed, Mar 3, 2010 at 8:40 PM, Irfan Sayed wrote: > Hi all, > > I need to copy files from one machine to another machine. I need to use > Net::SCP module . > Can you please give/help me small Perl snippet which will copy the files > I was thinking this module's document has already given the examples. http://search.cpan.org/~ivan/Net-SCP-0.08/SCP.pm -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: why on while?
On Tue, Mar 9, 2010 at 12:41 PM, Bryan R Harris wrote: > > > Much to my chagrin I realized this morning that this notation: > > while() { > > evaluates as: > > while(defined($_ = )) { > > ... and NOT as: > > while(defined(local $_ = )) { > so how about while (my $line = ) instead of using $_? -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: why on while?
On Fri, Mar 12, 2010 at 2:21 AM, Uri Guttman wrote: > empty lines (a single newline) is always true. the defined case only > handles the odd trailing partial line with just '0' in it. it is the > only way a <> without defined would lose some data as it is false. > No. Even having just 0 in a line won't make the line lost without defined. $ perl -e 'print "1\n2\n3\n0"' > a.txt $ perl -e 'open FD,"a.txt"; while(my $line=) { print $line }' 1 2 3 0 -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: IOScalar with threads dose not work
2010/3/23 Shlomi Fish : > > 2. Don't use threads in Perl. They cause too many problems. > Does it still have many problems until now? I ask it just because I wrote many code with Perl threads in my work, they seem work nice. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
reutun undef
>>> "return" statement with explicit "undef" at line 185, column 9. See page >>> 199 of PBP. (Severity: 5) I got the cpan test report, it pointed out the one above. Is "return undef" not to be encouraged in current Perl? Thanks. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: reutun undef
Thanks all. for "return ()", does it mean return an empty list, or return with no argument? -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
help on a soap client
Hello, I want to post some data to a webservice which is .NET powered. The webservice's developer tell me the request should be: POST /Service/IndicatorsService.asmx HTTP/1.1 Host: 192.168.1.100 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://tempuri.org/DataUpLoad"; http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";> http://tempuri.org/";> string string string string decimal dateTime decimal string string decimal dateTime decimal string string I wrote this script for requesting it: use SOAP::Lite +trace => 'all'; my $soap = SOAP::Lite->new( proxy => 'http://192.168.1.100/Service/IndicatorsService.asmx'); $soap->default_ns('http://tempuri.org/'); $soap->on_action(sub { join '', @_ }); my $method = SOAP::Data->name('DataUpLoad') ->attr({xmlns => 'http://tempuri.org/'}); my @param = ( SOAP::Data->name('INDICATORSNUMBER')->value('1010101010101210'), SOAP::Data->name('FVALUE')->value(50), ); my $run = $soap->call($method => @param); But it run failed. Can you help on this? Thanks. Jeff. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: help on a soap client
Thanks Rob. I have enabled "trace => all" when new the object, so I have been able to look what was happened. I think what I don't know is that how to built-up that a XML request package with the format they required for posting. Jeff. On Mon, Mar 29, 2010 at 5:49 PM, Rob Coops wrote: > > > On Mon, Mar 29, 2010 at 11:36 AM, Jeff Peng wrote: >> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: help on a soap client
On Mon, Mar 29, 2010 at 5:56 PM, Shlomi Fish wrote: >1. SOAP::Lite is no longer recommended. You should use SOAP::WSDL or >XML::Compile::SOAP instead. (According to the perlbot factoid on >irc.freenode.org ) Thanks Shlomi, let me check them. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: help on a soap client
Thanks Rob so much for the sample code. I will try it following your direction, thanks. On Mon, Mar 29, 2010 at 6:42 PM, Rob Coops wrote: > Got it, I for got to indicate the arrays there. The code below will produce > the following output. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: help on a soap client
Hello, Now I'm using the code below: use strict; use SOAP::Lite +trace => 'all'; my $soap = SOAP::Lite->new( proxy => 'http://192.168.1.100/Service/IndicatorsService.asmx'); $soap->default_ns('http://tempuri.org/'); $soap->on_action(sub { join '', @_ }); my $method = SOAP::Data->name('DataUpLoad') ->attr({xmlns => 'http://tempuri.org/'}); my @param = ( SOAP::Data->name('input')->value( [ SOAP::Data->name('User')->value('demo'), SOAP::Data->name('UserIP')->value('0.0.0.0'), SOAP::Data->name('NetType')->value(0), SOAP::Data->name('OS')->value('Linux'), SOAP::Data->name('Data')->value( [ SOAP::Data->name('DataUpLoadInputData')->value( [ SOAP::Data->name('INDICATORSNUMBER')->value('1010101010101210'), SOAP::Data->name('RECORDINGTIME')->value('2010-03-29 17:00:00'), SOAP::Data->name('FVALUE')->value(50), SOAP::Data->name('Valid')->value(''), SOAP::Data->name('Info')->value(''), ]), ]), ])); my $run = $soap->call($method => @param); But sorry it can't run correctly yet. The error shows: http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xmlns:xsd="http://www.w3.org/2001/XMLSchema";>soap:ClientSystem.Web.Services.Protocols.SoapException: 服务器无法读取请求。 ---> System.InvalidOperationException: XML 文档(1, 381)中有错误。 ---> System.InvalidOperationException: 未识别指定的类型: name='Array',namespace='http://schemas.xmlsoap.org/soap/encoding/',位于 <input xmlns='http://tempuri.org/'>。 在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_DataUpLoadInput(Boolean isNullable, Boolean checkType) 在 Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read7_DataUpLoad() 在 Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader) 在 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) --- 内部异常堆栈跟踪的结尾 --- 在 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events) 在 System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle) 在 System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() --- 内部异常堆栈跟踪的结尾 --- 在 System.Web.Services.Protocols.SoapServerProtocol.ReadParameters() 在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest() Any future helps? Thanks. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Ternary operator: Am I missing something?
On Mon, Mar 29, 2010 at 10:02 PM, Jeff Soules wrote: > Hi all, > > Am I missing something? I have the following chunks of code: > > EX 1: > if ($foo == 1){ > $bar = 0; > }else{ > $bar = 1; > } > > EX 2: > ($foo == 1) ? > $bar = 0 : > $bar = 1; > > These are logically equivalent, right? No. ($foo == 1) is a list which always has a value of either 1 or 0 so it really return a true value in both cases. -- Jeff Peng Email: jeffp...@netzero.net Skype: compuperson -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Ternary operator: Am I missing something?
Hi all, Am I missing something? I have the following chunks of code: EX 1: if ($foo == 1){ $bar = 0; }else{ $bar = 1; } EX 2: ($foo == 1) ? $bar = 0 : $bar = 1; These are logically equivalent, right? But when I've run the latter, $bar always comes away with a value of 0, regardless of the value of $foo. This is particularly confusing, as the following snippet: EX 3: ($foo == 1) ? warn "Got 0\n" : warn "Got 1\n"; is producing the results I expect. Am I doing something stupid or missing something obvious? Thanks, Jeff Soules -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Ternary operator: Am I missing something?
>> Assignment has lower precedence than ?: It is done last. Aha -- I was afraid of something like that. > (I.e: put parentheses around the clauses of if statements, even though they > are not needed or I could use the ultra-low-precedence "and"/"or"/etc.) Good idea. I almost always do in if-statements, but it hadn't occurred to me that it might be a good idea to do the same thing *after* the conditional! Thanks for the help everyone. Best, Jeff On Mon, Mar 29, 2010 at 10:35 AM, Shlomi Fish wrote: > Hi Shawn! > > On Monday 29 Mar 2010 17:19:36 Shawn H Corey wrote: >> On Mon, 29 Mar 2010 10:02:15 -0400 >> >> Jeff Soules wrote: >> > ($foo == 1) ? >> > >> > $bar = 0 : >> > $bar = 1; >> > >> > Am I doing something stupid or missing something obvious? >> >> ($foo == 1) ? >> ( $bar = 0 ) : >> ( $bar = 1 ); >> >> Assignment has lower precedence than ?: It is done last. What you >> wrote above is: >> >> (($foo == 1) ? >> $bar = 0 : >> $bar ) = 1; >> >> Which assigns 1 to $bar regardless of what $foo is. > > Thanks for the clarification. I suspected something of this sort was the case. > Whenever I don't remember what the operator precedence is, I always add a few > parentheses. I still often tend to do something like: > > {{{ > if (($age > 18) && ($name eq "Catherine")) > }}} > > (I.e: put parentheses around the clauses of if statements, even though they > are not needed or I could use the ultra-low-precedence "and"/"or"/etc.) > > Regards, > > Shlomi Fish -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/