testing Non_SOAP webservices
Hi gurus, I need to test non-SOAP webservices.Can anybody tell how could i do that in perl. basically i need to send the following xml file as pay load to the url. - ?xml version='1.0' encoding='UTF-8'? ns1:getHelloResp xmlns:ns1=http://sample2/xsd; ns1:req ns1:type=samples.HelloReq ns1:nameNag/ns1:name ns1:count3/ns1:count /ns1:req /ns1:getHelloResp --- and get the response can anybody in the group help me in doing this using perl. thanks, Siva --
Re: testing Non_SOAP webservices
From: perl pra [EMAIL PROTECTED] Hi gurus, I need to test non-SOAP webservices.Can anybody tell how could i do that in perl. basically i need to send the following xml file as pay load to the url. Have a look at the LWP modules. You'll need either LWP::Simple or LWP::UserAgent. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Is this possible to override print() ?
From: Chas. Owens [EMAIL PROTECTED] On Mon, Feb 25, 2008 at 9:43 PM, Panda-X [EMAIL PROTECTED] wrote: Sorry... the email is unfinished, the reason why I need to do this is because I don't want to pollute the existed codes / context ... the original print statements would like to retain, but I can still do the translations by adding : use OverridePrint; in a common module that all existed scripts are now using. snip You can find out whether or not a core function can be overridden by calling the prototype* function with that function's name prepended with CORE::. If it returns a prototype, then you can override it, if it returns undef, then you cannot. Unfortunately for you, print can not be overriden (most likely because of its indirect object syntax file handle wonkiness); however, there is another way: source filters. You can use Filter::Simple to replace every call to print with a call to my_print. Please note that it isn't quite that simple though. No need for source filters. All you have to do is to implement whatever special behaviour you need for a tied (magical) filehandle (see perldoc perltie perldoc Tie::Handle ) and then create and select the filehandle: use OverridePrint; tie *FH, 'OverridePrint'; # plus whatever other parameters you need select(FH); Basicaly the whole point is that instead of overriding print() for all filehandles you override it just for that one filehandle ... Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Is this possible to override print() ?
On Tue, Feb 26, 2008 at 5:51 AM, Jenda Krynicky [EMAIL PROTECTED] wrote: snip No need for source filters. All you have to do is to implement whatever special behaviour you need for a tied (magical) filehandle snip That works for that file handle, but he/she is talking about replacing all print calls in a set of scripts with a custom version. That means there might be prints to stdout, stderr, and numerous files. He/she was trying to avoid editing the source for each program (of course, that is what a source filter does, but at least you only need to do it once). -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
array question
Hello All, I have two arrays contains exact no. of elements. Now what I need to do is , I want to execute certain commands to each elements of the array at a time. It means that I want take first element of first array and first element of second array and then want to execute certain commands considering these two elements. I don't know how should I achieve this in perl. Please help. Regards Irfan.
Re: array question
On Tue, Feb 26, 2008 at 10:07 AM, [EMAIL PROTECTED] wrote: Hello All, I have two arrays contains exact no. of elements. Now what I need to do is , I want to execute certain commands to each elements of the array at a time. @array1 = (1,2,3); @array2 = (4,5,6); for (my $i=0; $i scalar(@array1); $i++) { print $array1[$i], $array2[$i], \n; } is straight forward enough. Troy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: array question
On Tue, Feb 26, 2008 at 8:07 AM, [EMAIL PROTECTED] wrote: Hello All, I have two arrays contains exact no. of elements. Now what I need to do is , I want to execute certain commands to each elements of the array at a time. It means that I want take first element of first array and first element of second array and then want to execute certain commands considering these two elements. I don't know how should I achieve this in perl. Please help. Regards Irfan. A simple for statement should do it; my @array1= qw/1 2 3 4/; my @array2= qw/1 2 3 4/; for 0..$#array1 { #your code here.. print $array1[$_] + $array2[$_],\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
OO question
Hi All, I am trying to work with the CGI::FormBuilder module in a Catalyst environment. My question is more about OO programming than either of those 2 modules though. I am trying to create a method/sub that will create a form to either edit or add an entry. I am creating the initial object and depending on whether or not the entry already exists, I want to set-up some aspects of my object (making sense??). So I want to create the object, assign it to a variable and make changes to it (or not) later depending on some condition. Here's an abridged version of what I have done so far: use strict; use warnings; ...snip sub edit : Local Form { my ($self, $c, $id) = @_; # Here comes my form my $fb = $self-formbuilder-field( name = 'Users', type = 'select', options = [ map { [ $_ - id, $_-code ] } $c-model('Files::users')-all ], required = 1, #value = undef ); ... if ($id) { $fb-{value} = $some_default_val; } } So I guess the question is what sort of structure have I created initially with $fb and $self and does $fb-{value} make sense. Can I add an attribute to an object after I've created it in this way. I hope that makes sense. I am almost confusing myself here :-) Thanx. Dp.
Are comments allowed before package declarations in modules?
I seem to have a vague memory about Perl not allowing comments before program statements, but I'm not sure. I really want to add a lot of comments at the top of a rather large module, but I'm unsure if thats safe. thanks
Re: OO question
On Feb 26, 11:20 am, [EMAIL PROTECTED] (Dermot) wrote: Hi All, I am trying to work with the CGI::FormBuilder module in a Catalyst environment. My question is more about OO programming than either of those 2 modules though. I am trying to create a method/sub that will create a form to either edit or add an entry. I am creating the initial object and depending on whether or not the entry already exists, I want to set-up some aspects of my object (making sense??). So I want to create the object, assign it to a variable and make changes to it (or not) later depending on some condition. Here's an abridged version of what I have done so far: use strict; use warnings; ...snip sub edit : Local Form { my ($self, $c, $id) = @_; # Here comes my form my $fb = $self-formbuilder-field( name = 'Users', type = 'select', options = [ map { [ $_ - id, $_-code ] } $c-model('Files::users')-all ], required = 1, #value = undef ); ... if ($id) { $fb-{value} = $some_default_val; } } So I guess the question is what sort of structure have I created initially with $fb and $self and does $fb-{value} make sense. Can I add an attribute to an object after I've created it in this way. Go back to basics. An object is just a hash[1], a reference to which happens to be blessed into a specific class. But it's still just a hash. Anything you can do to a normal hash, you can do to an object. That includes adding new key/value pairs to it. So yes, it's perfectly allowed. No reason you can't. Paul Lalli [1] in this case, of course. You're equally able to make an object out of a reference to a scalar, an array, a filehandle, or pretty much anything else... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: array question
On Feb 26, 11:07 am, [EMAIL PROTECTED] (Irfan Sayed) wrote: Hello All, I have two arrays contains exact no. of elements. Now what I need to do is , I want to execute certain commands to each elements of the array at a time. It means that I want take first element of first array and first element of second array and then want to execute certain commands considering these two elements. I don't know how should I achieve this in perl. In addition to the answers already received, you could take advantage of the List::MoreUtils module from CPAN: #!/usr/bin/perl use strict; use warnings; use List::MoreUtils qw/zip natatime/; my @foo = (1, 2, 3); my @bar = qw/a b c/; my $it = natatime 2, zip(@foo, @bar); while (my ($f, $b) = $it-()) { print $f - $b; } __END__ 1 - a 2 - b 3 - c Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Are comments allowed before package declarations in modules?
Jonathan Mast wrote: I seem to have a vague memory about Perl not allowing comments before program statements, but I'm not sure. I really want to add a lot of comments at the top of a rather large module, but I'm unsure if thats safe. It's safe. Comments are simply ignored by the Perl interpreter wherever they appear. However, you may want to consider the use of POD as well. perldoc perlpod -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Why doesn't this work: matching capturing
I have a data file that looks like this: uSF1 MD1500 0092149355224510209 0101001 88722397N0720900 116759 0Block Group 1 S 1158 662+39283007-076574503 uSF1 MD1500 0092150355224510209 0101002 88722397N0720900 109338 0Block Group 2 S 842 547+39280857-076573636 uSF1 MD1500 0092151355224510209 0101003 88722397N0720900 182248135142Block Group 3 S 920 442+39279557-076574311 This is actually three lines that all start with 'uSF1'. This is the Summary File from the US 2000 Census. I want to print all the census tracts and blockgroup numbers for FIPS state code = 24 (Maryland) and FIPS county code 510 (Baltimore City) for summary level '150'. These are all fixed-length records. I tried: [EMAIL PROTECTED] UScensus]$ perl -ne '($tract, $bg) = /^.{8}150.{18}24510.{21}(.{6})(.)/; print Tract $tract BLKGRP $bg\n;' mdgeo.uf1 |head Tract BLKGRP Tract BLKGRP Tract BLKGRP snip I thought that this would: skip 8 characters and match '150' skip 19 more characters and match '24' and '510' skip 21 more characters and capture the next 6 in $tract capture the next character in $bg and print them. The first two matches work, but nothing is captured. Any ideas what I'm doing wrong? Thanks for your help and advice. -Kevin Kevin Zembower Internet Services Group manager Center for Communication Programs Bloomberg School of Public Health Johns Hopkins University 111 Market Place, Suite 310 Baltimore, Maryland 21202 410-659-6139 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
looping thru delete check boxes
I have a page that displays a list of entries with Delete Check boxes how Do I loop thru all the checked entries, re-display in a 'confirmation' page and then do the deletes? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Are comments allowed before package declarations in modules?
On Feb 26, 12:35 pm, [EMAIL PROTECTED] (Jonathan Mast) wrote: I seem to have a vague memory about Perl not allowing comments before program statements, but I'm not sure. I really want to add a lot of comments at the top of a rather large module, but I'm unsure if thats safe. what happened when you tried it? You can put all the comments you want before a `package` statement. Your misremembering is likely tied to the fact that you can't put any comments (or anything else) before the shebang in the main file. Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Are comments allowed before package declarations in modules?
On Tue, 2008-02-26 at 12:35 -0500, Jonathan Mast wrote: I seem to have a vague memory about Perl not allowing comments before program statements, but I'm not sure. I really want to add a lot of comments at the top of a rather large module, but I'm unsure if thats safe. The perl best practices book recommends that the documentation (POD) appears at the end of the module. I don't personally like this recommendation because it makes it easier for the programmer to forget to maintain the documentation. -- Ken Foskey FOSS developer -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: looping thru delete check boxes
ken uhl wrote: I have a page that displays a list of entries with Delete Check boxes how Do I loop thru all the checked entries, re-display in a 'confirmation' page and then do the deletes? Learn some about CGI. http://www.cgi.resourceindex.com/Documentation/CGI_Tutorials/ -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Why doesn't this work: matching capturing
On Feb 26, 1:19 pm, [EMAIL PROTECTED] (Kevin Zembower) wrote: I have a data file that looks like this: uSF1 MD1500 009214935522451020 9 0101001 88722397N0720900 116759 0Block Group 1 S 1158 662+39283007-076574503 uSF1 MD1500 009215035522451020 9 0101002 88722397N0720900 109338 0Block Group 2 S 842 547+39280857-076573636 uSF1 MD1500 009215135522451020 9 0101003 88722397N0720900 182248 135142Block Group 3 S 920 442+39279557-076574311 This is actually three lines that all start with 'uSF1'. This is the Summary File from the US 2000 Census. I want to print all the census tracts and blockgroup numbers for FIPS state code = 24 (Maryland) and FIPS county code 510 (Baltimore City) for summary level '150'. These are all fixed-length records. I tried: [EMAIL PROTECTED] UScensus]$ perl -ne '($tract, $bg) = /^.{8}150.{18}24510.{21}(.{6})(.)/; print Tract $tract BLKGRP $bg\n;' mdgeo.uf1 |head Tract BLKGRP Tract BLKGRP Tract BLKGRP snip I thought that this would: skip 8 characters and match '150' skip 19 more characters and match '24' and '510' skip 21 more characters and capture the next 6 in $tract capture the next character in $bg and print them. The first two matches work, but nothing is captured. Any ideas what I'm doing wrong? On what do you base your assumption that the first two matches work? Nothing in your code or output indicates that, as you are never checking the return value of the pattern match. FWIW, your code did work for me when I copy and pasted your sample text, and joined the lines as they should have been. Therefore, I think it's pretty likely that your datafile does not contain what you think it does. I think it's more likely that the one line you think you have that starts with uSF is actually broken up into a few lines. Try some debugging prints of $_ to see what you actually have, like: print Line $.: $_; Try checking the return value of your regexp: /^.{8}150.{18}24510.{21}(.{6})(.)/ and print Tract $1 BLKGRP $2\n; Try enabling warnings to see of your two variables are undefined (which they would be if the pattern didn't match) or just empty strings (which they would be if the pattern matched but nothing was captured - this, of course, isn't possible, since a six-character match can't possibly be the empty string). Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: Why doesn't this work: matching capturing
Paul, thank you very much for your helpful reply. To answer your question, I am certain that the first two matches worked because I produced the output I showed with: [EMAIL PROTECTED] UScensus]$ perl -ne 'print if /^.{8}150.{18}24510.{21}(.{6})(.)/;' mdgeo.uf1 |head -1 uSF1 MD1500 0092149355224510209 0101001 88722397N0720900 116759 0Block Group 1 S 1158 662+39283007-076574503 [EMAIL PROTECTED] UScensus]$ Sorry if I left out this information and wasted anyone's time. A person responded to me privately and suggested this modification, which seems to work fine: [EMAIL PROTECTED] UScensus]$ perl -ne 'print Tract $1 BLKGRP $2\n if /^.{8}150.{18}24510.{21}(.{6})(.)/;' mdgeo.uf1 |head -3 Tract 010100 BLKGRP 1 Tract 010100 BLKGRP 2 Tract 010100 BLKGRP 3 [EMAIL PROTECTED] UScensus]$ I've been bitten by this bug before and can never remember the solution to when variables are assigned values. I thought assigning them in a previous command would have worked, but I must have overlooked something. Thank you, again, for your help. -Kevin -Original Message- From: Paul Lalli [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 26, 2008 3:41 PM To: beginners@perl.org Subject: Re: Why doesn't this work: matching capturing On Feb 26, 1:19 pm, [EMAIL PROTECTED] (Kevin Zembower) wrote: I have a data file that looks like this: uSF1 MD1500 009214935522451020 9 0101001 88722397N0720900 116759 0Block Group 1 S 1158 662+39283007-076574503 uSF1 MD1500 009215035522451020 9 0101002 88722397N0720900 109338 0Block Group 2 S 842 547+39280857-076573636 uSF1 MD1500 009215135522451020 9 0101003 88722397N0720900 182248 135142Block Group 3 S 920 442+39279557-076574311 This is actually three lines that all start with 'uSF1'. This is the Summary File from the US 2000 Census. I want to print all the census tracts and blockgroup numbers for FIPS state code = 24 (Maryland) and FIPS county code 510 (Baltimore City) for summary level '150'. These are all fixed-length records. I tried: [EMAIL PROTECTED] UScensus]$ perl -ne '($tract, $bg) = /^.{8}150.{18}24510.{21}(.{6})(.)/; print Tract $tract BLKGRP $bg\n;' mdgeo.uf1 |head Tract BLKGRP Tract BLKGRP Tract BLKGRP snip I thought that this would: skip 8 characters and match '150' skip 19 more characters and match '24' and '510' skip 21 more characters and capture the next 6 in $tract capture the next character in $bg and print them. The first two matches work, but nothing is captured. Any ideas what I'm doing wrong? On what do you base your assumption that the first two matches work? Nothing in your code or output indicates that, as you are never checking the return value of the pattern match. FWIW, your code did work for me when I copy and pasted your sample text, and joined the lines as they should have been. Therefore, I think it's pretty likely that your datafile does not contain what you think it does. I think it's more likely that the one line you think you have that starts with uSF is actually broken up into a few lines. Try some debugging prints of $_ to see what you actually have, like: print Line $.: $_; Try checking the return value of your regexp: /^.{8}150.{18}24510.{21}(.{6})(.)/ and print Tract $1 BLKGRP $2\n; Try enabling warnings to see of your two variables are undefined (which they would be if the pattern didn't match) or just empty strings (which they would be if the pattern matched but nothing was captured - this, of course, isn't possible, since a six-character match can't possibly be the empty string). Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Is this possible to override print() ?
From: Chas. Owens [EMAIL PROTECTED] On Tue, Feb 26, 2008 at 5:51 AM, Jenda Krynicky [EMAIL PROTECTED] wrote: snip No need for source filters. All you have to do is to implement whatever special behaviour you need for a tied (magical) filehandle snip That works for that file handle, but he/she is talking about replacing all print calls in a set of scripts with a custom version. That means there might be prints to stdout, stderr, and numerous files. He/she was trying to avoid editing the source for each program (of course, that is what a source filter does, but at least you only need to do it once). The use statement can change where STDOUT and STDERR point to or select() whatever filehandle you like. Changing the behaviour of all filehandles (keep in mind that it would include sockets!) would not be a wise thing to do. If he wants to make some more filehandles magical it would be as simple as tie *FH, 'ThatPackageNameIForgotAlready', \*FH; et voila ... all prints related to FH are special. And actually this is in some sense more global and less work than source filters. Source filters are AFAIK lexicaly scoped so you'd have to add the use statement into each an every file. If on the other hand changing the STDOUT and STDERR is enough, one use statement in the main file suffices. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Check if a given function returns something
Hi All, I want to check if a sub routine that I am calling returns a value or not. This is how my code is $str = function(parameter) sub function { .. } the sub routine function in turn uses many other function. Some of these functions have a return statement and some do not. So, when i invoke the sub routine function and i pass the returned value into $str, I need to check if $str has any value assigned or not. Can you tell me how I could accomplish this? Thanks, Vijay ___ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/