Re: accessing remote registry
Hi Jenda, I get the same error even if i remvoe the backslashes. Thanks, siva On 2/6/09, Jenda Krynicky wrote: > > From: perl pra > > Can anybody help in accessing the registry of remote windows machine and > get > > the keys in the folder *HKEY_LOCAL_MACHINE/SOFTWARE * > > ** > > I have tried using win32::Registry, but i am getting the error "cannot > open > > the registry",But the same script works if i assign $node to my local > Ip. > > > > Can somebody help me with the below script, so that this works for remote > > IPs also. > > > > please check the code below: > > > > > > -- > > > > #!/usr/bin/perl > > use strict; > > use warnings; > > > > use Win32::Registry; > > my ($node) = 'your_ip_here'; > > my $Register='SOFTWARE'; > > my ($hNode, $hKey, @key_list); > > > > $HKEY_LOCAL_MACHINE->Connect ($node, $hNode) or die "Cannot connect to > > $node"; > > I do not think there should be the backslashes there. > > Jenda > = je...@krynicky.cz === 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: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >
Re: package for reading filepro data files
David Shere wrote: > > I am writing a CGI script that needs to query a FilePro database. > FilePro stores its data in proprietary binary file formats. My company > already has code that, from Perl, will execute a FilePro program and > read that program's output from the disk. My task is to bypass that > option and read directly from the FilePro Files. I presume that I can > write code to to read the binary files and parse the results, but I'd > like to find out if there is something already written that I can use. > I have searched google/cpan and so far have no luck. > > The CGI script I'm writing will take an input string and perform actions > based on whether that input string is found in any of the records in the > FilePro database. It will also need to get the rest of the information > in the matching record. > > If there is a more appropriate forum for this request, please let me > know. FilePro is likely to support ODBC, in which case all you need is DBI and DBD::ODBC. HTH, Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
how to delay printing without over working perl
Hi, Looking at the script below, I wish to print out "line 1" first, which is after the while loop, then followed by "First loop", and then "Second loop", henceforth I have the script below. What I did was to hold on the printing of "First loop" and "Second loop" by pushing them into @printer which was then printed out after printing "line1. The problem is, if there are many iterations of the while loops, then the contents of @printer becomes very large before its printed out and this I fear may take up a lot of memory. I then wonder are there any other better ways for me to do this. Thanks scripts ### #!/usr/bin/perl use warnings; while ( 1 ){ push @printer,"First loop\n"; while ( 1 ){ push @printer,"Second loop\n"; last; } last, } print "line 1\n"; print @printer;
Re: question on 2 sub modules on the same scope
Original Message - From: "David Shere" To: "itshardtogetone" Cc: Sent: Tuesday, February 10, 2009 3:29 AM Subject: Re: question on 2 sub modules on the same scope What is an a_ctr, anyway? :) Thanks everyone for the help. ctr is a short form for counter, so $a_ctr is a counter. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: question on 2 sub modules on the same scope
On Tue, 2009-02-10 at 02:55 +0800, itshardtogetone wrote: > Hi, > Looking at the script below, can someone explain why the final output is > "Final = 1" instead of "Final = 5". > I thought at the end of the while loop, $a_ctr is 5, this value is then read > by the sub module &data() and this value of 5 is then passed on to sub > publish before its being printed out. Thanks The data() sub sets $a_ctr equal to an array containing one value. The first time, the array is (1), the second time it is (2), and so on. This is done five times, each time setting $a_ctr to an array containing one value. At the end, the array contains one value (5) but when you print that value in scalar context, you get a "1" because that's the number of elements in the array. You will achieve the results you're looking for by doing this: $a_ctr = shift(@_); or, simply: $a_ctr = shift; If you want to pass additional variables to data(), write it this way: my ($a_ctr, $b_ctr, $c_ctr) = @_; and call it like this: data($a_ctr, $b_ctr, $c_ctr); What is an a_ctr, anyway? :) Passing variables to subroutines is something that's very hard (IMHO) to get used to if you first learned how to do it in languages like Java, or in my case, Ada. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: question on 2 sub modules on the same scope
itshardtogetone wrote: Hi, Hello, Looking at the script below, can someone explain why the final output is "Final = 1" instead of "Final = 5". I thought at the end of the while loop, $a_ctr is 5, this value is then read by the sub module &data() and this value of 5 is then passed on to sub publish before its being printed out. Thanks #!/usr/bin/perl use strict; use warnings; { my $a_ctr = 0; sub data { $a_ctr = @_; When you use an array in scalar context, like above, the array returns the number of elements in the array and since you passed a single scalar to this subroutine the number 1 is assigned to $a_ctr. You need to either assign the contents of the array to a list: ( $a_ctr ) = @_; or just assign the first element of the array: $a_ctr = $_[ 0 ]; or use shift() to remove the first element and assign it: $a_ctr = shift; } sub publish{ print "Final = $a_ctr\n"; } } # my $a = 5; my $a_ctr = 0; while ($a_ctr < $a){ $a_ctr ++; Usually written as: foreach my $a_ctr ( 1 .. 5 ) { print "a_ctr = $a_ctr\n"; &data($a_ctr); } &publish(); Unless you are still using Perl version 4 (OMG!!) then you should omit the ampersand from the beginning of the subroutine call. John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
question on 2 sub modules on the same scope
Hi, Looking at the script below, can someone explain why the final output is "Final = 1" instead of "Final = 5". I thought at the end of the while loop, $a_ctr is 5, this value is then read by the sub module &data() and this value of 5 is then passed on to sub publish before its being printed out. Thanks #!/usr/bin/perl use strict; use warnings; { my $a_ctr = 0; sub data { $a_ctr = @_; } sub publish{ print "Final = $a_ctr\n"; } } # my $a = 5; my $a_ctr = 0; while ($a_ctr < $a){ $a_ctr ++; print "a_ctr = $a_ctr\n"; &data($a_ctr); } &publish();
Re: Slow connexion with Net::SSH::Perl
On Tue, 2009-02-03 at 21:38 +0100, julien collas wrote: > I use rsa key to connect and it seems to be very slow, Is it slow to connect when you initiate, or slow throughout the use of the connection? We've found that the absence of a reverse DNS record can delay initial connection times by up to two minutes. The SSH server can be configured to not do reverse DNS lookups on client machines. Of course you can only do that if you have privileges on the server. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
package for reading filepro data files
I am writing a CGI script that needs to query a FilePro database. FilePro stores its data in proprietary binary file formats. My company already has code that, from Perl, will execute a FilePro program and read that program's output from the disk. My task is to bypass that option and read directly from the FilePro Files. I presume that I can write code to to read the binary files and parse the results, but I'd like to find out if there is something already written that I can use. I have searched google/cpan and so far have no luck. The CGI script I'm writing will take an input string and perform actions based on whether that input string is found in any of the records in the FilePro database. It will also need to get the rest of the information in the matching record. If there is a more appropriate forum for this request, please let me know. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: How hard is it to learn this langauge?
On Sat, 2009-02-07 at 15:05 -0800, Blazer wrote: > I just kept reading that Perl was a very easy > language to learn. Is this true or is it propaganda??? Learning Perl wasn't any more or less difficult than any other language I've learned. Are you a new programmer? It might be more difficult for you. Writing good code, reusable code that's easy for other people to read and understand, using meaningful identifiers and simple structures, can be done well in many languages. It's certainly possible to write horrendously bad code in Perl. I've never programmed in C, but I'm told that C has similar syntax. I learned PHP after working with Perl for while, and picked up the basics pretty fast. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Converting a string to a filehandle
On Mon, Feb 09, 2009 at 12:41:07PM -, Taylor, Andrew (ASPIRE) wrote: > Hello > > I'm processing a file of test data that looks something like: > > FH1,data1,data2,data3,...etc > FH2,data1,data2,data3,...etc > FH1,data1,data2,data3,...etc > > Each line split into an array and processed. > > The first element (FH1, FH2, etc) is the name of the filehandle the > output should be printed to. > > I'm trying to do something like: > > use strict; > use warnings; > > open (FH1, ">file1"); > open (FH2, ">file2"); > > open (INPUT, " > while () > { > ...split line > ...process data > ...create output > > my $FH = $split_line[0] > > print $FH "$output\n"; > > } > > But I get the error: > "Can't use string ("FH1") as a symbol ref while "strict refs" in use at > my_script.pl line 387, line 1." You are using "strict refs", which is a good idea in general. But then you are trying to use a symbolic ref, which you explicitly said you wouldn't do. The solution therefore, is to allow symbolic refs where you are trying to use them. This can be done by placing just above your print statement. > The closest thing I've found is the following from the perldocs website: > > $fh = SOME_FH; # bareword is strict-subs hostile > $fh = "SOME_FH"; # strict-refs hostile; same package only > $fh = *SOME_FH; # typeglob > $fh = \*SOME_FH; # ref to typeglob (bless-able) > $fh = *SOME_FH{IO}; # blessed IO::Handle from *SOME_FH > typeglob > > But I don't think that answers my question (or if it does, I'm too dumb > to see that answer...) The clue is on the second line. The whole thing does seem a little fragile though, with such a tight connection between the internals of your program and the data in your file. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: AW: Converting a string to a filehandle
I've signed up for digest and keep getting individual emails. Does anyone know what the trick is to get digest form? Thanks, -Original Message- From: Jenda Krynicky [mailto:je...@krynicky.cz] Sent: Monday, February 09, 2009 8:49 AM To: beginners@perl.org Subject: Re: AW: Converting a string to a filehandle From: Thomas Bätzler > Taylor, Andrew (ASPIRE) wrote: > > I'm processing a file of test data that looks something like: > > > > FH1,data1,data2,data3,...etc > > FH2,data1,data2,data3,...etc > > FH1,data1,data2,data3,...etc > > > > Each line split into an array and processed. > > > > The first element (FH1, FH2, etc) is the name of the filehandle the > > output should be printed to. > [...] > > Try > > my %fh; > > open( $fh{'FH1'}, '>', $somefile ) or die "Can't open $somefile: $!"; > ... > > print $fh{'FH1'} "$output\n"; print {$fh{'FH1'}} "$output\n"; If the filehandle is a more complex expression than a bareword or simple variable you have to enclose it in curlies so that perl knows it's meant to the the optional filehandle and not the thing to print. Jenda = je...@krynicky.cz === 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: AW: Converting a string to a filehandle
From: Thomas Bätzler > Taylor, Andrew (ASPIRE) wrote: > > I'm processing a file of test data that looks something like: > > > > FH1,data1,data2,data3,...etc > > FH2,data1,data2,data3,...etc > > FH1,data1,data2,data3,...etc > > > > Each line split into an array and processed. > > > > The first element (FH1, FH2, etc) is the name of the filehandle the > > output should be printed to. > [...] > > Try > > my %fh; > > open( $fh{'FH1'}, '>', $somefile ) or die "Can't open $somefile: $!"; > ... > > print $fh{'FH1'} "$output\n"; print {$fh{'FH1'}} "$output\n"; If the filehandle is a more complex expression than a bareword or simple variable you have to enclose it in curlies so that perl knows it's meant to the the optional filehandle and not the thing to print. Jenda = je...@krynicky.cz === 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: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
AW: Converting a string to a filehandle
Taylor, Andrew (ASPIRE) wrote: > I'm processing a file of test data that looks something like: > > FH1,data1,data2,data3,...etc > FH2,data1,data2,data3,...etc > FH1,data1,data2,data3,...etc > > Each line split into an array and processed. > > The first element (FH1, FH2, etc) is the name of the filehandle the > output should be printed to. [...] Try my %fh; open( $fh{'FH1'}, '>', $somefile ) or die "Can't open $somefile: $!"; ... print $fh{'FH1'} "$output\n"; HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Converting a string to a filehandle
Hello I'm processing a file of test data that looks something like: FH1,data1,data2,data3,...etc FH2,data1,data2,data3,...etc FH1,data1,data2,data3,...etc Each line split into an array and processed. The first element (FH1, FH2, etc) is the name of the filehandle the output should be printed to. I'm trying to do something like: use strict; use warnings; open (FH1, ">file1"); open (FH2, ">file2"); open (INPUT, ") { ...split line ...process data ...create output my $FH = $split_line[0] print $FH "$output\n"; } But I get the error: "Can't use string ("FH1") as a symbol ref while "strict refs" in use at my_script.pl line 387, line 1." I can get round it without too much difficulty with an if statement, but I was wondering if there was a simple way to turn a string into a filehandle. I've tried various things like: my $FH = "\*$split_line[0]"; or print \*$FH "$output\n"; or changing the data to hold \*FH1 in the first field. All to no avail. The closest thing I've found is the following from the perldocs website: $fh = SOME_FH; # bareword is strict-subs hostile $fh = "SOME_FH"; # strict-refs hostile; same package only $fh = *SOME_FH; # typeglob $fh = \*SOME_FH; # ref to typeglob (bless-able) $fh = *SOME_FH{IO}; # blessed IO::Handle from *SOME_FH typeglob But I don't think that answers my question (or if it does, I'm too dumb to see that answer...) Can anyone point me in the right direction? Cheers Andy Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: How hard is it to learn this langauge?
Damien Learns Perl wrote: I have experience in C and I find that Perl would have been a much easier language to start with. You can write powerful code right away. I started to learn Perl last month and I am blogging about it at: http://damienlearnsperl.blogspot.com/ This is certainly not academic Perl but you can come chime in and say how you would have done differently. Thanks and regards, You're welcome, and ... On Usenet, and most mailing lists like this one, it is good manners to intersperse your comments or put them all at the bottom of the previous post, after you have suitably trimmed away all irrelevant and superfluous lines (like for instance the post you replied to.) I too have experience with C and several other languages and I find it much easier to write a robust and maintainable program in Perl than the equivalent in C which would also be two to ten times longer and more complex. Learning the basics of Perl is fairly easy, truly understanding Perl may take a while. ;-) Also, a note about your blog. You wrote on January 4, 2009: Side note for Linux users: Perl is present in most standard Linux distributions. In order to check the Perl version that you are using, open a terminal and type: perl -v If perl is not in your current path, typing which perl will show you which directory to add to your $PATH environment variable. The 'which' command searches through the current PATH to find the program you are looking for so if 'which' finds it the directory is already in the PATH environment variable. Oh, and my condolences on your use of Windows. :-( John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
RE: How hard is it to learn this langauge?
I came to Perl with no real programming experience (I'd looked at C and Java a bit, but never used them and messed around with simple BASIC at school). I was given the task of modifying a load of Perl code, so I went out and bought the "Learning Perl" book (By Randal L. Schwartz & Tom Christiansen) and took it from there. Taught me everything I needed to know (for the work I was doing) and I was able to start changing code within days. It wasn't much longer before I was creating new code of my own either. So, if a dullard like me with no previous experience can pick it up quickly, anyone who's done programming before should have no problems. -Original Message- From: Blazer [mailto:evanstroh...@yahoo.co.uk] Sent: 07 February 2009 23:05 To: beginners@perl.org Subject: How hard is it to learn this langauge? I have limited experience of programming in C & C++ - I cant claim to know either of these well, but i do try to keep building on what i know, when i can. I just kept reading that Perl was a very easy language to learn. Is this true or is it propaganda??? All I know is Larry Wall created it! Is it possible to get to grips with this language fast - like in two or three months? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/ Capgemini is a trading name used by the Capgemini Group of companies which includes Capgemini UK plc, a company registered in England and Wales (number 943935) whose registered office is at No. 1 Forge End, Woking, Surrey, GU21 6DB. This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/