use strict / nostrict
>> #!/usr/bin/perl >> use Text::CSV; >> use DBI; >> use Data::Dumper; > > There is no "use strict;" and "use warnings;" at the beginning of the file: I see this quite a bit on this list (and elsewhere) and I think it's very good advice, so this morning I got to thinking. If these pragmas are as important as they are, why is it that they aren't turned on in Perl by default? How about if we make them the default settings in 5.16 and then add "use nostrict;" and "use nowarnings;" for when someone wants to turn them off? In the grand scheme of things I'm still relatively new to all this, but it makes total sense to me. If they should be used in most every script, why waste the time and thought of always having to remember (or remind others) to add them? Thoughts? Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
File::Find script questions
I've written a script to traverse my web server, find any files called "error_log", e-mail them to me, and then delete them. It is triggered by cron twice a day. The script works great but I'd like to get advice on how I can clean up my code, so any comments are welcome. Also, do I really need the foreach block in there? I couldn't get it to work without it, but it seems like I should be able to. =:\ Thanks, Marc #!/usr/bin/perl use strict; use warnings; use File::Find; use File::HomeDir; my $path_to_search = File::HomeDir->my_home.'/public_html'; my $file_name = 'error_log'; my $from_address = 'x...@xxx.com'; my $to_address = 'x...@xxx.com'; my $mail_app = '/usr/sbin/sendmail'; my $subject= 'An "error_log" was found'; find(\&wanted, $path_to_search); sub wanted { if ($File::Find::name =~ /$file_name/) { my $msg = "MIME-Version: 1.0\n". "Content-Type: text/plain\n". "To: $to_address\n". "From: $from_address\n". "Subject: $subject\n\n"; open (my $mail_fh, "|$mail_app -t -oi -oem") || die "Can't open sendmail!"; print {$mail_fh} "$msg"; print $msg; open (my $file_fh, '<', $File::Find::name) || die "Can't open $file_name: $!"; my (@lines) = <$file_fh>; foreach my $line (@lines) { print "$line"; } print {$mail_fh} "@lines"; close ($file_fh) || die "Can't close file"; close $mail_fh || die "Can't close mail_fh"; unlink ($File::Find::name); } } In case anyone's interested, here's the shell script it replaces: #!/bin/sh ## Variables ## FILES=`find /home/user/public_html -name error_log` ADDRESS=x...@xxx.com for file in $FILES do if [ -e "$file" ] then mail -s "$file" $ADDRESS < $file rm -r $file # delete log file fi done -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: File::Find script questions
Thanks to both Uri and John for their input. I've added your suggestions and the script is much cleaner and more concise now. I decided to keep the header info in the sub because I'm now setting the subject to the path of the error log, so at a glance I know where there's a problem. On Jul 18, 2011, at 8:50 PM, Uri Guttman wrote: > it would be much cleaner IMO to collect the paths of the files you want > and then process those paths in a sub. the rule is generally to collect > the data you need and process later and elsewhere. I'm sorry, but I'm not following you here. Could you explain a little more? > but beyond this calling sendmail directly isn't cool anymore. there are > many useful mail modules that make this easier and work with other > mailers or directly with smtp. I searched for mail modules and there seems to be a million of them. Could you recommend a couple that you like? Thanks again, Marc -- #!/usr/bin/perl use strict; use warnings; use File::Find; use File::Slurp; my $path_to_search = $ENV{HOME}.'/public_html'; my $file_name = 'error_log'; my $from_address = 'f...@me.com'; my $to_address = 't...@you.com'; my $mail_app = '/usr/sbin/sendmail'; find(\&wanted, $path_to_search); sub wanted { return if $_ ne $file_name; my $subject = substr $File::Find::name, length($path_to_search); # removes "/home/USER/public_html" from the subject my $log_text = read_file($File::Find::name); my $message = <http://learn.perl.org/
Subdirectories and use lib
I'd like to organize a project's files into subdirectories for better housekeeping. I thought that use lib "."; would also include any subdirectories, but sadly it doesn't. Is there a way to include all subdirs without having a list a mile long like this? use lib "/Applications/MAMP/cgi-bin/cart/sql/lib/Module/"; use lib "/Applications/MAMP/cgi-bin/cart/sql/lib/Params/"; use lib "/Applications/MAMP/cgi-bin/cart/sql/Business/CreditFraud/"; etc... Or am I going about it the wrong way? Thanks, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Arrow Notation vs. Colon Notation
I've noticed that the following two lines seem to be equivalent when calling a sub from a module called Lib.pm: Lib->load_config("config.dat"); Lib::load_config("config.dat"); Is this just a case of TIMTOWTDI or is there a difference in how they do what they do? Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Arrow Notation vs. Colon Notation
On Jul 20, 2011, at 4:03 PM, Uri Guttman wrote: > so don't think they are even similar as one is a sub call and the other > is a class method call. they aren't interchangeble at all Yep, you're correct. Why is everything so simple once someone explains it to you??? =;) That also cleared up a strange problem I was having with my code. Boy, am I embarrassed. On the plus side, this ordeal has helped to solidify it for me, so I guess it's O.K. to make stupid mistakes once in awhile, no? Thanks, Uri. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Subdirectories and use lib
On Jul 21, 2011, at 5:56 AM, Shlomi Fish wrote: > You can load modules from lib using "use Module::SubModule;" or "use > Params::Validate" - no need to load all subdirectories. Just use "::" for > loading stuff in sub-directories. Thanks, Shlomi. That's all it took to get it to sink in. > http://perl-begin.org/topics/modules-and-packages/ I went back and re-read chapter 10 of "Beginning Perl" and it _finally_ makes sense to me now. Thanks again, Marc BTW, I would like to thank everyone who responds to questions like these on this list. I've read "Beginning Perl" twice, "Learning Perl", and a couple of others, but sometimes things just don't sink in until someone goes out of their way to give a simple explanation, and then it's like a switch has been thrown. So, sincerely, thanks to everyone here who's willing to help. I'm sure it can be frustrating at times to put up with these questions, but it really does make a difference. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Perl modules that "phone home"
When placing test orders in my re-factored shopping cart on my MacBook Pro, Little Snitch is warning me that Perl is trying to connect to the following servers when an order is completed and the confirmation e-mail is being sent to the customer: nullmx.yourdomain.com wdfgh.com mailsrv.gh.com I don't think that this should be happening. I mean, who are these domains and what info is being sent to them? I did some digging and found out that yourdomain.com is owned by GoDaddy, wdfgh.com is owned by some Chinese company, and gh.com is owned by a company in Ghana! How can I find out which module(s) is doing this? I don't want to go live until I'm able to stop this, since I don't know how much, if any, of the customers information may be compromised. Thanks, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl modules that "phone home"
On Jul 29, 2011, at 2:49 PM, Mark Wagner wrote: > Most Perl modules are ordinary text files, so grepping around in the > modules directory for things like "mailsrv" or "wdfgh" should tell you > which modules are responsible. Mark, I was able to do that with TextWrangler, but didn't find anything. However, your other suggestions got me thinking. So I searched our test data and found the culprit domains there. Slightly embarrassing, but I'm glad to know that it's not some nefarious plan to steal credit card data! ;-) Sorry for the false alarm. Thanks for your help, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Perl modules that "phone home"
On Jul 29, 2011, at 5:34 PM, shawn wilson wrote: > Hmmm, Acme::CC::Bandit anyone? I wonder how many others fell for that one? =:\ That's not a nice trick to play on a "beginners" list, ya know. =;) -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Grabbing an element deep inside a nested hash
I'm trying to sort a shopping cart basket on the item numbers. The basket is stored in a hash. There is a hashref called %{$main::global->{cart}} that Data::Dumper prints out like so: $VAR1 = { '1' => '1 1 SL-8206 73.15 Label 8.25" x 6"0.8 73.15 ', '3' => '3 1 WR-9253 13.98 Label - 3" x 9" 0.5 13.98 ', '2' => '2 1 APT-46V 96.43 4"x6" Label, hook 1.8 96.43 ' }; I would like to grab the item numbers, i.e. SL-8206, to sort the cart on. Could someone point me to something to read up on this? What is the above actually? It looks to me like a hash of hashes of arrays(?). I thought that converting it into an array would help, like so: my $n = keys($main::global->{cart}); my @cart_lineitems = @{$main::global->{cart}}{0 .. $n}; but dumping the output: print {$tracelog_fh} Dumper($cart_lineitems[0]); print {$tracelog_fh} Dumper($cart_lineitems[1]); print {$tracelog_fh} Dumper($cart_lineitems[2]); print {$tracelog_fh} Dumper($cart_lineitems[3]); gives me this: $VAR1 = ''; $VAR1 = '1 1 SL-8206 73.15 Label 8.25" x 6"0.8 73.15 '; $VAR1 = '2 1 APT-46V 13.98 Label - 3" x 9" 1.8 13.98 '; $VAR1 = '3 1 WR-9253 96.43 4"x6" Label, hook 0.5 96.43 '; Why the first one is empty is beyond me, but that's another story. I then tried to grab just the item numbers using both: print {$tracelog_fh} Dumper($cart_lineitems[1][2]); and print {$tracelog_fh} Dumper($main::global->{cart}->{1}->{2}); but they produce these errors: Can't use string ("11 SL-8206 73.15 Label "...) as an ARRAY ref while "strict refs" in use Can't use string ("11 SL-8206 73.15 Label "...) as an HASH ref while "strict refs" in use Anyway, maybe I'm going about this the wrong way. I know enough just to be dangerous at this point. The bottom line is, how would I go about grabbing the item numbers from the original hashref so that I can sort the cart on them? I'm over my head with this one, so any pointers would be extremely helpful. I'm reading about references in the "Beginning Perl" book, but so far the light hasn't come on. Thanks, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Grabbing an element deep inside a nested hash
Jim and Rob, Thanks to both of you for your responses and for the code you supplied. That was a big help. I was able to get it to work and I've pasted my code below. > No. It is just a one-level hash. I'm glad you both pointed this out. It appears that I was over thinking it. Once I was able to see that, a lot of other things fell into place. >> my $n = keys($main::global->{cart}); > > I think this can't be what you wrote - it wouldn't compile. You probably want > > my $n = keys %{$global->{cart}}; Surprisingly, it did compile, but I like your way better. >> my @cart_lineitems = @{$main::global->{cart}}{0 .. $n}; > > That is one way of doing things, but I am surprised you happened upon it > without knowing more about Perl. "Happened upon it" is exactly how I found it. =;) Google to the rescue! http://stackoverflow.com/questions/2907270/perl-convert-hash-to-array And it worked - that's why I used it, but I didn't remember that hash keys were strings and not numbers. > Because the values of the array elements are simple strings, as I explained > above, you must find a way of splitting them into individual fields. I took Rob's advice, since the data was tab separated, merged it with Jim's code, and came up with this. Separating the sort into a sub helps, since I need to use it in multiple places. foreach my $cartitem ( sort sortby_itemid keys %{$main::global->{cart}} ) { # list the items... } sub sortby_itemid { (split /\t+/, $main::global->{cart}->{$a})[2] cmp (split /\t+/, $main::global->{cart}->{$b})[2] } Thanks again for your help, guys. I really appreciate it. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: XAMPP
Chris, > I'm thinking about testdriveing XAMPP. Does anyone have any opinions > on the product? Good or bad? I used it for awhile and I thought it was a good package for testing purposes, but on the Mac, I prefer MAMP and Perlbrew. I like being able to test my scripts with multiple versions of Perl. FYI, the Perl version included with XAMPP is 5.10.1, so if you want something newer, you'll have to install your own. If you haven't tried Perlbrew, I can't recommend it enough. Not only can you have multiple versions of Perl installed and switch between them easily, but it makes installation SO mush easier, especially with cpanm. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Hardware?
On Aug 4, 2011, at 5:05 PM, s...@missionstclare.com wrote: > I use Perl on my own machine to assemble HTML files (no networking stuff). My > current machine is a Mac running OSX Tiger. The MacOS doesn't seem friendly > to Perl, so I want to change to something that won't make me feel like > throwing it out the window. > > What hardware and OS might be best for my use? I'd prefer a laptop to a > desktop. (I once worked for Sun Microsystems, so I'm comfortable with UNIX.) But Mac OS X _is_ Unix. What exactly do you mean by "The MacOS doesn't seem friendly to Perl"? If you're messing around with the system Perl, you shouldn't be. If you're trying to install Perl somewhere else, I know that Tiger can give you some problems. If you can upgrade, Snow Leopard is much better. If you can't upgrade your OS, you should really try installing Perlbrew. That has made my programming life an order of magnitude less frustrating. Give it a try! As far as hardware goes, you don't need to upgrade it to run Perl. You don't say which Mac you have, but as long as you're not running a production server with it, whatever you have should work fine. However, if you can max out the RAM, I would at least do that. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sandboxing while I am learning
Sayth, > So basically If I want to experiment and toy with different cpan apps > and so forth I can without messing up my perl install. All you have to do is install cpanm for each version of Perl and then you don't have to worry about them stepping on each other. With cpan configured for each Perl, I have different environments depending on the version and it works great. This post may help: http://blog.fox.geek.nz/2010/09/installing-multiple-perls-with.html Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sandboxing while I am learning
Rob, > The multiple cpan installations is not bad it is dangerous in my opinion. I > have seen people go white as a sheet of paper once they realized that they > where not on the test but on the production machine and they just executed an > rm -rf on the application server directory... > The risk of such a simple mistake is even larger when all environments are on > a single machine. Therefore I would personally not advise this but that might > just be paranoid old me ;-) It's good to be paranoid in situations like this. But I wouldn't let that stop me from using perlbrew. Once you switch to a particular version of Perl, perlbrew keeps you there even through a restart of the computer. As long as you know which version you're in, you won't have any problems. Also, you can't inadvertently switch Perls without knowing it, since you have to manually enter the switch command in Terminal. Perlbrew is one of those apps that, once you start using it, you yell out "YES!!!" and scare everyone within earshot around you. If you're deleting stuff without knowing where you are, well, you deserve to lose the data. Besides, that's what backups are for. =;) Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sandboxing while I am learning
Shawn, > if you use perlbrew and local::lib you > can test different perl versions and then different environments. I haven't looked into local::lib yet. What advantage does that give you over a plain perlbrew install? Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Moose
Klaus, > checking CPAN for Moose gives me a list of about 2000 entries related > directly or indirectly to Moose. In case you're interested, there's also a Moose mailing list which would probably be of more help to you with all things Moose. moose-subscr...@perl.org Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Capitalizing Acronyms
I'm trying to capitalize 3 and 4 letter words that contain only vowels or consonants, but not both. The code I've come up with is not working correctly. Given the string 'The Kcl Group', it should return 'The KCL Group' but it is also capitalizing the word 'THE'. What am I doing wrong? Thanks, Marc use strict; use warnings; my $string = 'The Kcl Group'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3 and length $word <= 4) and ($word !~ m/[aeiouy]+/gi or $word !~ m/[bcdfghjklmnpqrstvwxz]+/gi)) { $word = uc($word); } push @new_words, $word; } $string = "@new_words"; print $string . "\n"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Capitalizing Acronyms
Jim and David, > m/^[aeiouy]+$/i I tried your suggestions but it still gives the same result: my $string = 'Off The Menu'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3 and length $word <= 4) and ! ($word =~ m/^[aeiouy]+$/i or $word =~ m/^[bcdfghjklmnpqrstvwxz]+$/i)) { $word = uc($word); } push @new_words, $word; } $string = "@new_words"; print $string . "\n"; gives me "OFF THE MENU". -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Capitalizing Acronyms
Hi Shlomi, > The problem here that /g confuses Perl and puts it in the \G anchor mode. > Removing both /g fixes the problem. Some other notes: > > 1. You don't really need to say [...]+ inside the regex. [] here would be > enough. Unfortunately, removing the /g and the + doesn't help. (Updated code below.) > 2. You may opt to use perldoc -f map instead of foreach here. I don't fully understand map yet. =:\ That's why I'm using foreach. > 3. Since the foreach aliases the variable, you can modify the array in-place. Sorry, but you've lost me here. Could you give an example? Thanks, Marc my $string = 'Off The Menu'; my @words = split(/ /, $string); my @new_words; foreach my $word (@words) { if ((length $word >= 3 and length $word <= 4) and ! ($word =~ m/^[aeiouy]$/i or $word =~ m/^[bcdfghjklmnpqrstvwxz]$/i)) { $word = uc($word); } push @new_words, $word; } $string = "@new_words"; print $string . "\n"; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Capitalizing Acronyms
On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote: > $string =~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig; Thanks to everyone who responded. I was trying to be concise but I went about it the wrong way and ended up creating more work for myself. I like the above code as it allows me to use the original string without having to split it and create new arrays just for this one feature, and it's simpler than I had hoped for. Most importantly, I understand it! =;) Thanks again, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Capitalizing Acronyms
On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote: > my $string = 'The Kcl Group'; > > $string =~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig; > > print $string, "\n"; I'd like to revisit this, if I could. I've modified the above regex so as not to capitalize ordinal numbers, however I've noticed that it produces incorrect output if the word has an apostrophe. Given: my $string = "rex's chicken on 51st st. at lkj"; $string =~ s/\b([aeiouy]{3,4}|[^aeiouy0123456789]{3,4})\b/uc($1)/eg; the output is: Rex'S Chicken on 51st ST. at LKJ It should be: Rex's Chicken on 51st St. at LKJ I Googled and tried everything I'd found, but I can't fix it. Again, that line should capitalize 3 and 4 letter words that have either all vowels or all capitals. The code I found below works great for capitalization except for that one regex which throws a wrench into it. Thanks, Marc --- # http://daringfireball.net/2008/08/title_case_update use strict; use warnings; use utf8; use open qw( :encoding(UTF-8) :std ); my @small_words = qw( (?http://learn.perl.org/
Re: Capitalizing Acronyms
On Oct 6, 2011, at 4:44 PM, Jim Gibson wrote: > You should go back to your original character class of [bcdfghjklmnpqrstvwxz] Making this change fixed the "Rex'S" problem, but it didn't capitalize LKJ because the rest of the code had capitalized the acronym as Lkj. So I changed that line to: $string =~ s~\b([aeiouyAEIOUY]{3,4}|[bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ]{3,4})\b~uc$1~eg; and now it works, even though it's a mile long. ;) Thanks for helping me to think about it differently. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Capitalizing Acronyms
On Oct 7, 2011, at 8:07 AM, Rob Dixon wrote: > Just add the /i modifer (as you had originally) and there is no need to list > both the upper and lower case alphabetics. Of course. Err... :\ > Capturing parenthese should be avoided unless the are needed This I don't understand. Since we're using $1 we need them, no? > $string =~ s/\b(?:[aeiouy]{3,4}|[bcdfghjklmnpqrstvwxz]{3,4})\b/\U$1/gi; This gave me an error of "use of uninitialized value $1 in uc". Removing the non-capturing code works though; $string =~ s/\b([aeiouy]{3,4}|[bcdfghjklmnpqrstvwxz]{3,4})\b/\U$1/ig; This now allows me to step it down to {2,4} without capitalizing the 'st' in 51st. Thanks again, Marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: 2 files, 1 package, shared constants
Stanisław T. Findeisen schrieb: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello there My application consists of several files. Some of them are to be run as CGI scripts, the others from command line. There is also a "common" file with constants and shared routines. The question is: what is the most standard way to export constants from that common file so that they could be used in the other files? The Exporter. package MyPackage; use warnings; use strict; use constant { ~MY_FIRST_CONSTANT => 'hello world!' }; *MY_SECOND_CONSTANT = [1, 3, 7]; *MY_SECOND_CONSTANT = \729; sub routine1 { ~print "Hello from routine1! $MyPackage::MY_SECOND_CONSTANT\n"; } This is scary, what is with the typegobs there? I would do something like this. package MyPackage; use warnings; use strict; use constant { MY_FIRST_CONSTANT => 'hello world!' }; use Exporter; our @EXPORT = qw/MY_FIRST_CONSTANT $MY_SECOND_CONSTANT routine1 /; #...@export_ok would be better our $MY_SECOND_CONSTANT = [1, 3, 7]; sub routine1 { print "Hello from routine1! $MY_SECOND_CONSTANT\n"; } == one.pl == use MyPackage; routine1(); print MY_FIRST_CONSTANT; print $MY_SECOND_CONSTANT; see perldoc Exporter -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Comparison of the comma versus the period in print statements
Hi, I noticed that most beginner texts will introduce and use print like this: print $moose, $squirrel, $boris, "\n"; However, when I review code from CPAN, I often (typically) see: print $bullwinkle . $rocky . $natasha . "\n"; As I recall, print is a list operator (and therefore the comma syntax is used to separate items in a list), but is catenation somehow faster/more memory efficient? Thanks, --Marc
What is the difference between: 'my $var = 1' vs. 'my ( $var ) = 1'?
At the introductory level it seems like I have often seen code like this: use strict; my $var = 1; And as I review other peoples' scripts I have often encountered code like this: use strict; my ( $this, $that, $the_other ); Which I interpreted as a mechanism to declare a number of scalar variables with a minimum of typing. But lately I've been seeing this syntax and I was wondering if it was fundamentally different (and somehow more desirable): use strict; my ( $var ) = 1; As if $var is being declared in a list context; what, if anything, do I get by including parentheses when declaring a single variable? Thanks, --Marc
Unintended behavior: Range operator inside a while loop continues to pattern match on the subsequent file
Hi, I was parsing a collection of HTML files where I wanted to extract a certain block from each file, like this: > ./script.pl *.html my $accumulator; my $capture_counter; while ( <> ) { if ( //.../labelsub/ ) { $accumulator .= $_ unless /labelsub/; if ( /labelsub/ && !$capture_counter ) { print $accumulator; $capture_counter = 1; } else { next; } } else { next; } } continue { # flush out the variables and clean up if ( eof ) { close ARGV; $accumulator = ''; $capture_counter = ''; } } The bit about the $capture_counter is because some of the files have multiple blocks of text that could be accumulated, and I only want the first block in the file. This usually works fine, until I encountered an input file that did not contain the string 'labelsub' after the first '' regex pattern match. Then the conditional if test continued to search in the incoming lines in the next file (because I am processing a whole batch using the while (<>) operator), which it eventually found, and then printed nothing, because at the end-of-file of the previous file, the script flushed the contents of the accumulator. One solution is to just run the same script individually on each file, but I was wondering if there was a way to reset the 'state' of the range operator pattern match at the end of the physical file (or at any other time for that matter)? Thanks, --Marc
Re: Unintended behavior: Range operator inside a while loop continues to pattern match on the subsequent file
Beautiful; I should've known that brian d foy would have come up with a solution--I even have a copy of that book! Thanks, --Marc On Thu, Apr 21, 2011 at 3:10 PM, Brian Fraser wrote: > http://www.effectiveperlprogramming.com/blog/314 > > Brian. > > On Thu, Apr 21, 2011 at 2:42 PM, Marc Perry wrote: > >> Hi, >> >> I was parsing a collection of HTML files where I wanted to extract a >> certain >> block from each file, like this: >> >> > ./script.pl *.html >> >> my $accumulator; >> my $capture_counter; >> >> while ( <> ) { >>if ( //.../labelsub/ ) { >>$accumulator .= $_ unless /labelsub/; >>if ( /labelsub/ && !$capture_counter ) { >>print $accumulator; >>$capture_counter = 1; >>} >>else { >>next; >>} >>} >>else { >>next; >>} >> } >> continue { # flush out the variables and clean up >> if ( eof ) { >>close ARGV; >>$accumulator = ''; >>$capture_counter = ''; >>} >> } >> >> The bit about the $capture_counter is because some of the files have >> multiple blocks of text that could be accumulated, and I only want the >> first >> block in the file. >> >> This usually works fine, until I encountered an input file that did not >> contain the string 'labelsub' after the first '' regex pattern match. >> Then the conditional if test continued to search in the incoming lines in >> the next file (because I am processing a whole batch using the while (<>) >> operator), which it eventually found, and then printed nothing, because at >> the end-of-file of the previous file, the script flushed the contents of >> the >> accumulator. >> >> One solution is to just run the same script individually on each file, but >> I >> was wondering if there was a way to reset the 'state' of the range >> operator >> pattern match at the end of the physical file (or at any other time for >> that >> matter)? >> >> Thanks, >> >> --Marc >> > >
Re: Unintended behavior: Range operator inside a while loop continues to pattern match on the subsequent file
Thanks, Paul. A very thoughtful response--I will try this out (I don't recall every encountering the ?? operator, but if it works as advertised I will likely use it a lot). --Marc On Thu, Apr 21, 2011 at 3:29 PM, Paul Johnson wrote: > On Thu, Apr 21, 2011 at 01:42:42PM -0400, Marc Perry wrote: > > Hi, > > > > I was parsing a collection of HTML files where I wanted to extract a > certain > > block from each file, like this: > > This is where everyone will tell you to use some dedicated HTML parsing > module. > > > > ./script.pl *.html > > > > my $accumulator; > > my $capture_counter; > > > > while ( <> ) { > > if ( //.../labelsub/ ) { > > $accumulator .= $_ unless /labelsub/; > > if ( /labelsub/ && !$capture_counter ) { > > print $accumulator; > > $capture_counter = 1; > > } > > else { > > next; > > } > > } > > else { > > next; > > } > > } > > continue { # flush out the variables and clean up > >if ( eof ) { > > close ARGV; > > $accumulator = ''; > > $capture_counter = ''; > > } > > } > > > > The bit about the $capture_counter is because some of the files have > > multiple blocks of text that could be accumulated, and I only want the > first > > block in the file. > > > > This usually works fine, until I encountered an input file that did not > > contain the string 'labelsub' after the first '' regex pattern match. > > Then the conditional if test continued to search in the incoming lines in > > the next file (because I am processing a whole batch using the while (<>) > > operator), which it eventually found, and then printed nothing, because > at > > the end-of-file of the previous file, the script flushed the contents of > the > > accumulator. > > > > One solution is to just run the same script individually on each file, > but I > > was wondering if there was a way to reset the 'state' of the range > operator > > pattern match at the end of the physical file (or at any other time for > that > > matter)? > > No, there isn't (unless you want to get fancy and use a closure or > something) and so you'll need to find some other way to "end" the range. > The obvious other end point is the end of file, and so you can have your > range operator as: > >if ( // ... /labelsub/ || eof ) { > > This will ensure that the range operator "ends" by the end of each file, > but you'd need to do extra work because of the logic of the rest of your > program. So let's see if we can do something about that. > > Whilst it doesn't make a difference to the logic, I prefer to jump out > of a loop early if I find it doesn't satisfy the conditions I'm looking > for. So I think that: > >next unless // .. /labelsub/ || eof; > > looks tidier than the if else conditional. > > Then there's your logic to ensure you only count the first block in each > file. Perl has the little-known ?? counterpart to // which will only > match once. So making that line: > >next unless ?? .. /labelsub/ || eof; > > Allows you to get rid of the $capture_counter variable. But you'll need > to add a reset to the continue block, to reset the ?? at the start of a > new file. > > Finally, with this change you may as well just print $accumulator in the > continue block too. So we end up with > >my $accumulator; > >while ( <> ) { >next unless ?? .. /labelsub/ || eof; >$accumulator .= $_ unless /labelsub/; > } >continue { # flush out the variables and clean up >if ( eof ) { > print $accumulator; >$accumulator = ''; >reset; >} >} > > which, I think, does what you are after. > > The docs mention that ?? is vaguely deprecated: > >This usage is vaguely deprecated, which means it just might possibly >be removed in some distant future version of Perl, perhaps somewhere >around the year 2168. > > That doesn't sound too bad, but there was some talk of an earlier > deprecation of the bare ?? syntax, so it might be safer to use m?? > instead. > > Interestingly (for me), this is the first time in over 20 years that I > have found a legitimate use for ??, and the associated reset. > > -- > Paul Johnson - p...@pjcj.net > http://www.pjcj.net >
Tips or Tricks to print out tab-separated data?
Hi, I routinely generate rows of tab-separated data like this; my @array = ( "boris", "natasha", "rocky", "bullwinkle"); print join "\t", @array, "\n"; However this code inserts an extra tab between bullwinkle and the newline character. So when it is important I do this instead: print join "\t", @array; print "\n"; I suppose you could put both statements on a single line. Is there a simpler/faster way to generate this output: boris\tnatasha\trocky\tbullwinkle\n? Thanks, -- Marc
Installing Module::Build::Tiny from CPAN fails . . . because it requires Module::Build::Tiny!?! WTF?
Has anyone else encountered this? I had to dig down deep in my testing lore and run 'prove -v t/simple.t' before I could find the STDERR that revealed this. When I reviewed the files in the Module, sure enough: use Module::Build::Tiny (which unfortunately I don't have and am trying to install). Surely this is a bug? --Marc
Re: Installing Module::Build::Tiny from CPAN fails . . . because it requires Module::Build::Tiny!?! WTF?
Hi Rob, Thanks for your reply; it led me to an insight I was lacking. I was not making a distinction between using a module that is somewhere in @INC, and a module that has been successfully installed. I think the solution for me lies in Ch. 2 of Intermediate Perl (2nd ed.), I just have to try a few variations until I get it to work. --Marc On Sat, Feb 15, 2014 at 7:13 PM, wrote: > Hi Marc, > > Version 0.034 installed ok for me on Strawberry Perl. > > The simple.t test script was unable to unlink a dll it had created and > produced a few warnings in relation to that – but the tests still passed > and the module installed. > > (Strawberry Perl ships with Module-Build-Tiny, so in order to emulate your > situation I removed it before trying to install the module using > cpan.) > > Cheers, > Rob > > *From:* Marc Perry > *Sent:* Sunday, February 16, 2014 8:34 AM > *To:* beginners@perl.org > *Subject:* Installing Module::Build::Tiny from CPAN fails . . . because > it requires Module::Build::Tiny!?! WTF? > Has anyone else encountered this? I had to dig down deep in my testing > lore and run 'prove -v t/simple.t' before I could find the STDERR that > revealed this. When I reviewed the files in the Module, sure enough: > use Module::Build::Tiny (which unfortunately I don't have and am trying to > install). Surely this is a bug? > > --Marc >
Re: Installing Module::Build::Tiny from CPAN fails . . . because it requires Module::Build::Tiny!?! WTF?
Hi Brian, Very nicely explained. I suppose Perl Beginners is not the best forum for this question. I clearly didn't understand the various ways to use prove. Thanks, --Marc On Sun, Feb 16, 2014 at 10:13 AM, Brian Fraser wrote: > On Sat, Feb 15, 2014 at 10:34 PM, Marc Perry wrote: > >> Has anyone else encountered this? I had to dig down deep in my testing >> lore and run 'prove -v t/simple.t' before I could find the STDERR that >> revealed this. When I reviewed the files in the Module, sure enough: >> use Module::Build::Tiny (which unfortunately I don't have and am trying >> to install). Surely this is a bug? >> > > Well no, it's not a bug. Step back and consider: How else is a module > going to test itself, if not by using its own functions? > > What your prove line is missing is a -b, which, after either 'make' or > './Build', will include the paths to the files the module needs in @INC. > > For what it's worth, M::B::T install fine for me on Android and OS X -- if > you can still reproduce your build issue, it'd probably be pretty helpful > to report it in the module's github page. > >
Re: Help with Perl 6 script
hello Rui, > I have this Perl 6 script from Rosetta, which I wanted to run on Perl 5 > (due to the Active Sate Perl and App version that I have). Perl6 and Perl5 are very different. you need to download a perl6 interpretor if you want to run perl6 code. please check https://rakudo.org/. regards marc -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: perl scalar
Odd. I just tried the same code snippet and it worked fine. You might try putting a space before and after your "=" signs. I don't know if that makes a difference, but it won't hurt. Marc Sacks [EMAIL PROTECTED] D. Bolliger wrote: elite elite am Montag, 25. September 2006 22:27: I not sure what i doing wroung. I'm not sure either :-) Street="Wright"; This is wrong syntax; "Street" is not a scalar variable, while "$street" would be. print "$street\n"; $street is undef here, you didn't assign anything to the $street variable. $street="Washington"; That's ok, but never used. And i get this output. Street/[EMAIL PROTECTED] ~]$ Weird, I can't explain that. Your code (is it a snippet from the actual code?) does not even compile on my box and (correctly) emits the error: Can't modify constant item in scalar assignment at - line 1, near ""Wright";" Execution of - aborted due to compilation errors. - How exactly did you invoke your code? - What is output if you run the code: #!/usr/bin/perl use strict; use warnings; my $street='Wright'; # ok, why not :-) print "$street\n"; $street='Washington'; print "$street\n"; __END__ ? Dani -- Marc Sacks, Ed.D. | Quality Assurance Manager Lextranet | 107 Union Wharf | Boston, MA 02109 http://www.lextranet.com (617) 227-4469 Extension 228 [EMAIL PROTECTED] THE INFORMATION IN THIS MESSAGE IS INTENDED ONLY FOR THE PERSONAL AND CONFIDENTIAL USE OF THE DESIGNATED RECIPIENTS NAMED ABOVE AND MAY CONTAIN LEGALLY PRIVILEGED INFORMATION. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone at 617-227-4469 Ext. 228. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: perl scalar
I guess I didn't quite use the original code. I made the mistake of typing what it should have been instead of what it was: #!/usr/bin/perl $street="Wright"; print "$street\n"; $street="Washington"; It's amazing what a dollar sign and a change of case can do. -Marc Hello Marc Odd. I just tried the same code snippet and it worked fine. Do you refer to the original code? #!/usr/bin/perl Street="Wright"; print "$street\n"; $street="Washington"; This would be very odd?!? You might try putting a space before and after your "=" signs. Yes, many people consider this better formatting style... I don't know if that makes a difference, but it won't hurt. ... but it won't change the interpretation of the code by perl :-) Dani -- Marc Sacks, Ed.D. | Quality Assurance Manager Lextranet | 107 Union Wharf | Boston, MA 02109 http://www.lextranet.com (617) 227-4469 Extension 228 [EMAIL PROTECTED] THE INFORMATION IN THIS MESSAGE IS INTENDED ONLY FOR THE PERSONAL AND CONFIDENTIAL USE OF THE DESIGNATED RECIPIENTS NAMED ABOVE AND MAY CONTAIN LEGALLY PRIVILEGED INFORMATION. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone at 617-227-4469 Ext. 228. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Re: Standard input errors
elite elite wrote: Here are my error: [EMAIL PROTECTED] ~]$ perl hello.pl String found where operator expected at hello.pl line 15, near "print "" (Might be a runaway multi-line "" string starting on line 11) (Missing semicolon on previous line?) Backslash found where operator expected at hello.pl line 15, near "print "\" (Do you need to predeclare print?) Backslash found where operator expected at hello.pl line 15, near "address\" String found where operator expected at hello.pl line 15, at end of line (Missing semicolon on previous line?) syntax error at hello.pl line 15, near "print "" Global symbol "$address" requires explicit package name at hello.pl line 11. Global symbol "$name" requires explicit package name at hello.pl line 11. Can't find string terminator '"' anywhere before EOF at hello.pl line 15. here my code.I not sure what i did wroung here. #!/usr/bin/perl use strict; use warnings; my $street='Wright'; print "$street\n"; $street='Washington'; print "$street\n"; print "One major street in madison is Washington\n"; print "enter your address"/n"; my $address $name =<>; print "\nPerl has received your address\n"; __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com I don't think this is your whole problem, but I did notice this error: print "enter your address"/n"; Along with typing a forward slash instead of a backslash, you have an extra double-quote. This means that perl reads print "enter your address" and has no idea what to with the /n. Then, it sees the following text string: "; my $address $name =<>; print " It probably takes this as a scalar and has no idea how to process it; and after that, it gets some more funny text followed by another unresolved double-quote. Marc [EMAIL PROTECTED] -- Marc Sacks, Ed.D. | Quality Assurance Manager Lextranet | 107 Union Wharf | Boston, MA 02109 http://www.lextranet.com (617) 227-4469 Extension 228 [EMAIL PROTECTED] THE INFORMATION IN THIS MESSAGE IS INTENDED ONLY FOR THE PERSONAL AND CONFIDENTIAL USE OF THE DESIGNATED RECIPIENTS NAMED ABOVE AND MAY CONTAIN LEGALLY PRIVILEGED INFORMATION. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone at 617-227-4469 Ext. 228. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Non-deprecated way to capture array length
I needed to find out the length of an array and did it by referencing the array in scalar context. However, "use warnings" indicated that this is a deprecated feature. Is there a non-deprecated way to do this (other than looping through the whole array until I run out of elements)? Thanks. -- Marc Sacks, Ed.D. | Quality Assurance Manager Lextranet | 107 Union Wharf | Boston, MA 02109 http://www.lextranet.com (617) 227-4469 Extension 228 [EMAIL PROTECTED] THE INFORMATION IN THIS MESSAGE IS INTENDED ONLY FOR THE PERSONAL AND CONFIDENTIAL USE OF THE DESIGNATED RECIPIENTS NAMED ABOVE AND MAY CONTAIN LEGALLY PRIVILEGED INFORMATION. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this communication in error, please notify us immediately by telephone at 617-227-4469 Ext. 228. Thank you. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
Using HTTP and LWP
Hello, I'm using an existing program that perform HTTP Request. In a POST request I found this : my $request = POST($URL Content => [ 'user' => $user, 'pwd' => $pwd, 'no_auth' => '1', 'submit_login'=>'Login', ], ); Can someone says me what means "no_auth" ?? Thanks a lot Marc ___ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français ! Yahoo! Mail : http://fr.mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
trailing white space
Hi I created a script that reads a file and attaches a string infront of each read in item. When the file is saved with the changes though, each item has a blank line between the next item. The original text document does is single sapced. Original tesxt file item1 item2 item3 Saved text file string item1 string item2 string item3 I think what his happening is when the items are read in lots of white space is attached to the end of the string. Is there a way to remove only trailing white space, from a string, but retain white spaces with in the string? thanks, Marc Marc Fromm Computer Systems Specialist University of Montana--Western 710 South Atlantic Street Dillon, MT 59725 406-683-7164 Sent via the HotDawg Mail system at hotdawg.umwestern.edu -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl Newbie - Need good book recommendation
* Ed Yost <[EMAIL PROTECTED]> [2003-09-27 14:29]: > Hi all, > > I am a complete newbie to perl and have no programming experience. Do > any of you have a good recommendation on a book or resource for a > beginner such as myself? I'm using O'Reilly's _Learning Perl_ and it's very clear. Like you, I have no programming experience (except for BASIC and Pascal in high school over ten years ago of which I remember exactly zero), and find the book's hand-holding style (jokes, focusing on one specific topic at a time, building on each concept, etc.) reassuring. I tried using online tutorials like the other replier suggests, but got lost. I think that method works if you know something about programming already, because most of the tutorials I came across (granted, they may not have been the best ones, and I didn't try hundreds before going for the book) assume a certain level of familiarity with basic programming concepts which I didn't have. -- Sat, 27 Sep 2003 16:17:00 -1000 Linux 2.4.20-20.9 Mutt 1.4.1i (2003-03-19) A legion of French Bosoms could not match the lucid beauty of your toenails! -- the surreal compliment generator Marc Adler -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Perl Vs ...
* Tassilo von Parseval <[EMAIL PROTECTED]> [2003-09-21 20:27]: > On Sun, Sep 21, 2003 at 09:28:21PM -0400 Paul Kraus wrote: > > > Perl was pretty much my first language. Not counting Business Basic and same > > old Pascal from high school. The more I learn the more I see that perl can > > handle just about anything I want to do. How do you go about deciding if you > > should use another tool such as C++ over perl? I am thinking about learning > > another language and trying to decide what language would be best to learn. > > To expand my skill set. Suggestions, Ideas, Book Recommendations? > > I was always of the opinion that knowing C is one of the essential > things. Too many vital stuff is nowadays hidden away from the user in > more recent languages (such as portability issues and memory management > for instance). > > C also has the advantage that it integrates tightly into perl. You can > write Perl modules as C extensions which is fun and will teach you a lot > about perl and how interpreters in general work. > > However, C's learning curve is rather steep (but shorter than Perl's). Would learning C++ do just as well? On many of the C/C++-related websites/newsgroups they say that there's no point in learning C because you'll have to unlearn a bunch of "bad habits" when you learn C++ (I don't know either language, so I don't know what those habits might be). Also, how commonly is perl learned as a first language? > $_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({ > pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#; > $_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~;eval What's all that? -- Sun, 21 Sep 2003 21:12:00 -1000 Linux 2.4.20-20.9 Mutt 1.4.1i (2003-03-19) Fear not the earl lest I had conquered him and peopled else this isle with Calibans. -- the surreal compliment generator Marc Adler -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to speed up two arrays compare.
kevin liu schrieb: But this algorithm takes a long time to compare, could you please help to improve this piece of code to less the time needed? Thanks in advance. I don't know if it's faster, but you can also use the smart-match operator of perl5.10.0. use feature ':5.10'; use strict; use warnings; my @a=qw/A B C/; my @b=qw/A B C/; my @c=qw/C A B/; say "\...@a=\@b" if @a ~~ @b; # True say "\...@a=\@c" if @a ~~ @c; # Won't work this way, wrong order my %match; @mat...@c}=(1) x @c; say "\...@a=\@c" if @a ~~ %match; # But this works. Or if you don't have perl5.10.0 print "\...@c=\@a\n" if @{...@match{@a}]} == scalar(@a) ; #Not perl5.10.0 way Does anyone have a better idea how to force list context in the last line? scalar(@mat...@a}) returns 1, the first element, not 3 Marc "Maluku" Lucksch -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Reading 2 array lists
Chris, I installed the latest 5.10 and it does not work this is the error message C:\scripts\doubletakecheck>test.pl Can't locate List/compare.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/li b .) at C:\scripts\doubletakecheck\test.pl line 4. BEGIN failed--compilation aborted at C:\scripts\doubletakecheck\test.pl line 4. On Thu, Feb 19, 2009 at 4:25 PM, Chas. Owens wrote: > On Thu, Feb 19, 2009 at 15:19, marc ritorto wrote: > > will this module work with activestate perl ? > snip > > With ActivePerl you need to look at the build status page* to see if a > given module works. It looks like it works with Perl 5.8, but not > Perl 5.6. You should be able to install it with the PPM**. > > * http://ppm.activestate.com/BuildStatus/5.6.html for Perl 5.6 and > http://ppm.activestate.com/BuildStatus/5.8.html for Perl 5.8 > ** http://docs.activestate.com/activeperl/5.8/faq/ActivePerl-faq2.html > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. >
which mailing list?
I was using CPAN on aix433 with perl5.6 and was installing MD5 when I got this error make:cc_r: Command not found make: *** [MD5.o] Error 127 To which of the dozens of perl lists should I post to find out what happened? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
installation under aix
I have installed perl 5.6.1 under aix via an lpp from the Bull distribution. The config.sh file indicates that CC='cc_r' but there is no such file. If I create a link from /usr/local/bin/gcc the make runs but it bombs with compiler errors. Does anyone know: a) if aix requires perl to be compiled with something other than gcc (seems I had seen that somewheres) b) where to file the configure command in the lpp c) whether there is some way to set gcc to do the make successfully and d) which of the now gazillion lists is intended to address such issues (I have already posted to aix-l) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Trying to extract an email address
Hi all, I am a newbie and really enjoy this list. I have what i am sure is a fairly easy question, but I need help. I have a text file which contains much un-needed data, but also contains a bunch of email addresses I need. I have been succesful in the basics of opening the file and putting the contents into an array. However, I have had a problem extracting the email addresses. I used the grep/@/ function an this returned all the lines that contained an email address. However, I don't want the whole line, just the email address. I tried the nongreedy modifier grep/@?/ but this didn't work. Any suggestions. Thanks in advance. MMM __ Do You Yahoo!? Send FREE Valentine eCards with Yahoo! Greetings! http://greetings.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Extracting Multiple Lines
I have an online form that has a "Comments" field. I need to extract ALL of the information from the comments field. Each "Comments" line begins with Comment: so the /^Comments/ works to match that, however the user may, or may not enter a new line in their comments and they may or may not start from the line where "Comments" is written. Also there are no delimiting characters to search. And one more problem is that they rarely end the sentence with a period. The only good news is that there are never more than 4 lines. But because there is almost always a newline, I can't use: while <> because it searches line by line. Any suggestions on capturing several lines at once? Thanks! MMM __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multiple lines - I must be doing something wrong
I have an online form that has a "Comments" field. I need to extract ALL of the information from the comments field. Each "Comments" line begins with Comment: so the /^Comments/ works to match that, however the user may, or may not enter a new line in their comments and they may or may not start from the line where "Comments" is written. Also there are no delimiting characters to search. And one more problem is that they rarely end the sentence with a period. The only good news is that there are never more than 4 lines. But because there is almost always a newline, I can't use: while <> because it searches line by line. I posted on line and got a very helpful response to use: local $/ = undef; However I put this at the beginning of my script and nothing matched. I am still using the while<>. Is this what is messing it up? Thanks! MMM __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple lines - I must be doing something wrong
The form generally has input as follows: Comment: comment 1 then a new line then comment two then a new line then comment three I am trying to capture all three lines of this Comment: field. The script looks like: $/ = undef; while <>; if /^Comment:(\s*)(\w*)/ print $2; Hope this helps; Thanks Marc Morrison --- Michael Kelly <[EMAIL PROTECTED]> wrote: > On 2/23/02 3:52 PM, Marc Morrison > <[EMAIL PROTECTED]> wrote: > > > I have an online form that has a "Comments" field. > I > > need to extract ALL of the information from the > > comments field. > > > > Each "Comments" line begins with Comment: so the > > /^Comments/ works to match that, however the user > may, > > or may not enter a new line in their comments and > they > > may or may not start from the line where > "Comments" is > > written. > > It would help if you could give us some sample data, > but I think I know what > you're talking about. Is it something along the > lines of this? > > Comment: line 1 > Comment: line 2 > Comment: line 3 > > > Also there are no delimiting characters to search. > > And one more problem is that they rarely end the > > sentence with a period. The only good news is > that > > there are never more than 4 lines. But because > there > > is almost always a newline, I can't use: > > > > while <> > > > > because it searches line by line. > > > > I posted on line and got a very helpful response > to > > use: > > > > local $/ = undef; > > > > However I put this at the beginning of my script > and > > nothing matched. I am still using the while<>. > Is > > this what is messing it up? > > It might help if you posted the code you're using > right now. > > I'm really not sure if this is right (sample data > and code would help), but > this might work: > > # START CODE # > > # assuming this is the kind of data you're talking > about > $comments = <<_COMMENTS_; > Comment: line 1 > Comment: line 2 > Comment: line 3 > _COMMENTS_ > > my $data; > > # run through each line and collect the data > while ($comments =~ /^Comment: (.+)$/gm){ > > $data .= "$1\n"; > > } > > print "$data"; > > # END CODE # > > To examine the regex itself: > > /^Comment: (.+)$/gm > > The 'm' switch allows the ^ and $ to match at the > beginning and end of > lines, instead of the entire string, and the 'g' > option allows global > matching. The '(.+)' traps one or more of anything, > and sets it to $1. > > NOTE: This regex assumes there's a space after the > "Comment:". If you can't > be sure that there will be either remove the space > or replace it with " ?" > (space-question mark; matches 0 or 1 spaces). > > That said, I may have totally misunderstood your > problem. If so, just ignore > this email :) > > Hope that helps, > > -- > Michael > > > -- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > __ Do You Yahoo!? Yahoo! Sports - Coverage of the 2002 Olympic Games http://sports.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Text search engine [OT]
Hi Dermont/Ray, Please check out the MRS system (mrs.cmbi.ru.nl). It has a SOAP interface to perl and other languages, and is extremely fast in indexing and retrieval. MRS is a generic tool and you can index yourself, but also dowload indexed bio-databanks. The source code is in C++ and is available as well. Teaching material is available but tailored towards biologists. Best, Marc Raymond Wan schreef: Hi Dermot, Off-topic, so I hope no one minds if I reply. Perl is good at manipulating text strings, but that doesn't usually help search engine implementations. A search engine (or information retrieval system) has to be fast and after it has tokenized the document collection or query, you're basically comparing integers (i.e., a lookup table that maps an integer to a word in a dictionary). Actually, even during the initial mapping, a C-style strcmp would be sufficient. I doubt a fast search engine would actual perform string matching using regular expressions. Of course, a Perl implementation might be interesting as a learning tool for students. But as an IR system that is suppose to be run in the "real world" and not in the class room...I don't think you will see a Perl system anytime soon. I think if you wrote quick Perl and C/C++ implementations that merely tokenize a collection (let's say of the range in GBs), you'll know what I am talking about. Of course, in the classroom, a lecturer might just want the students to play with something that is a MB or less...if so, I think Perl would be good and students might even prefer it... :-) Ray Dermot wrote: I am looking for a text search engine that has a Perl interface. I have found a few, Lucene, OpenFTS and Swish-E. OpenFTS hasn't had a release of the last 3 years. That makes me nervous about using it. Lucene is java based. I have zero java experience but there is Perl Module into a 'C++ port API of Lucene'. There is also a thread on perlmonks about the performance penalty of tying Perl to Java. I am a bit surprised that the there isn't a more native Perl text search engine given Perl's agility with text strings. Could anyone recommend any of the above or suggest an alternative? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: case
Well, there isn't a real case statement as in C or Pascal, but, you can emulate one through a block =) SWITCH: for ($str_fruit) { if (/apple/) { ... last SWITCH; } if (/banana/) { ... last SWITCH; } if (/orange/) { ... last SWITCH; } } Hope this helps, Marc... | Hi, | | there is in Perl a statement "case" like in "C" or in "Pascal" ??? | | Walter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Ok- real dumb question
I am supposed to parse a text file such as this- 781457 Hartanto Victor Setiawan <[EMAIL PROTECTED]> 777557 Hatfield Benjamin <[EMAIL PROTECTED]> 779777 Henry James <[EMAIL PROTECTED]> 777947 Hergert Michael William <[EMAIL PROTECTED]> 778097 Iverson Jennifer Marsee <[EMAIL PROTECTED]> As you can see... some people have middle names and some dont... how would I go about parsing this text file and putting each into it own seperate entity, except if there is a middle name, in which case I want it to be joint first and middle. I realize that I am supposed to use some kind of split function, however I am unsure how to use it fully, and the prfessor didnt go over it too much. Thanks for any help! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl Cookbook
You can checkout the PLEAC sourceforge project, it has all recipes the cookbook has.. The difference between PLEAC and the book is that PLEAC doesn't offer any motivation or explanation with the recipes.. The project: http://pleac.sourceforge.net/ Perl specific: http://pleac.sourceforge.net/pleac_perl Furthermore i must say that buying the cookbook is well worth your money, it's a great and very useful book.. Goodluck, Marc... | Hi Folks, | | I've just worked my way though the learning perl (lama book) 3rd edition and | I must say I found it very good, and after lurking in here for a while and | hearing people talk about the perl cookbook. I took a wander over to amazon | and read the reviews, pretty so, so I though and for a technical book that | was written/published in 1998 it seems fairly old. So, my question is, is it | worth buying or should I just wait till the next/lastest version comes out ? | | Thanks, | Patrick -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Newbie: Move to next entry
> I have delimited the fields in the logfile by ","..and delimited the > last field for each entry with a "*". > > How do I get it to move to the next entry after the *, and print that to > screen? > > open(READFILE, $log_file) || > > print "The log file could not be opened",$BR; > > while() > > { @data = split( /\n/); Why are you looking for the end of line if your next entry should be after a * ? I'm not a guru perl but this one is seem to be the same error I would do without thinking to it! Don't be shy, I am to a lower Perl knowledge but I do lot of my code in Java but there's not only Java in the world... proud to learn Perl's langage in those Java world... And also... you may not keep your file open while printing to the screen... what would append if to user try to one read the file and the other to write to it... Don't know the code but I know it could be easilly done by assigning the fille content to an Array, which will contain every line of the file... Some guru migth help on this one! By the way pardon me for my english... Ya Foeb With Beg or yet another french on a english board with bad english grammar :P > > foreach $entry (@data) > > { ($d, $e, $f, $g, $h, $i, $j)= split(/,/, $entry); > > print "First Name : ", $d, $BR; > print "Last Name : ", $e, $BR; > print "City : ", $f, $BR; > print "State : ", $g, $BR; > print "Country : ", $h, $BR; > print "Email : ", $i, $BR; > print "Comments : ", $j, $BR; > } > } > close(READFILE); > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBI driving me nuts ... !
Have you tried to print @row? #!/usr/bin/perl use Mysql; $dbh = Mysql->connect("localhost"," > > mailscanner","root","c0nc3pt") or > die ("Error " . Mysql->errno . " - " . Mysql->errstr); > $sql = "SELECT to_address FROM maillog LIMIT 10;"; > $sth = $dbh->query($sql) or die ("Error " . Mysql->errno . " - " . > Mysql->errstr); > while (@row = $sth->fetchrow){ >print "@row /n"; > } $dbh->disconnect(); 2009/10/6 Gregory Machin > Hi > Please can you advise ? > > #!/usr/bin/perl > > use Mysql; > > $dbh = Mysql->connect("localhost","mailscanner","root","c0nc3pt") or > die ("Error " . Mysql->errno . " - " . Mysql->errstr); > $sql = "SELECT to_address FROM maillog LIMIT 10;"; > $sth = $dbh->query($sql) or die ("Error " . Mysql->errno . " - " . > Mysql->errstr); > while (@row = $sth->fetchrow){ >print "$row /n"; > } > > which gives this > > [r...@mail10 ~]# perl addressrep2.pl > /n /n /n /n /n /n /n /n /n /n[r...@mail10 ~]# > > when it should give the same output as > > Database changed > mysql> SELECT to_address FROM maillog LIMIT 10 >-> ; > ++ > | to_address | > ++ > | iv...@systems.xxx| > | tkek...@stpeters.xxx | > | dfou...@howden.xxx | > | melan...@mdlulisharp.xxx | > | er...@mdlulisharp.xxx| > | desi...@oas.xxx | > | dbalakis...@multivid.xxx | > | bhar...@webb.xxx | > | jcven...@multivid.xxx| > | ad...@troika-iw.xxx| > ++ > 10 rows in set (0.00 sec) > > mysql> > > > > what am I doing wrong ? > > Thanks > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : paumarc.mu...@bioinf.uab.cat
two errors
Hi every body recently i compiled a svmlight perl module two use svmlight program with perl http://search.cpan.org/~kwilliams/Algorithm-SVMLight-0.09/lib/Algorithm/SVMLight.pm to compile a patch is needed and as i wanted to run it under linux in a 64 bits machine, i used the flag make " CFLAGS='-fPIC -O3' " after applaying a patch the compilation worked fine, but when ever i try to build an object i get get the following error usr/bin/perl: symbol lookup error: /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi/auto/Algorithm/SVMLight/SVMLight.so: undefined symbol: set_learning_defaults I would appreciate is some of you could tell me what does "symbol lookup error" and "undefined symbol" means, by the way, set_learning_defaults is deffined at the patch Thanks pau -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: (+34)935 86 89 39 Email : paumarc.mu...@bioinf.uab.cat
Re: two errors
Hi Shiomi Thanks for your answer, i compiled this program with a 32 bits machine and everything worked, but now this machine is dead, as long as the two versions of linux are different, can the problem due to different compilers version? pau 2010/10/29 Shlomi Fish > Hi Pau, > > On Thursday 28 October 2010 16:04:19 Pau Marc Munoz Torres wrote: > > Hi every body > > > > recently i compiled a svmlight perl module two use svmlight program with > > perl > > > > > http://search.cpan.org/~kwilliams/Algorithm-SVMLight-0.09/lib/Algorithm/SVM<http://search.cpan.org/%7Ekwilliams/Algorithm-SVMLight-0.09/lib/Algorithm/SVM> > > Light.pm > > > > to compile a patch is needed and as i wanted to run it under linux in a > 64 > > bits machine, i used the flag make " CFLAGS='-fPIC -O3' " after applaying > a > > patch > > > > the compilation worked fine, but when ever i try to build an object i > get > > get the following error > > > > usr/bin/perl: symbol lookup error: > > > /usr/local/lib64/perl5/site_perl/5.10.0/x86_64-linux-thread-multi/auto/Algo > > rithm/SVMLight/SVMLight.so: undefined symbol: set_learning_defaults > > > > I would appreciate is some of you could tell me what does "symbol lookup > > error" and "undefined symbol" means, by the way, set_learning_defaults > is > > deffined at the patch > > These are errors of the GNU linker. I don't know what is causing them but > we > can try to investigate. Maybe the set_learning_defaults was defined as a > static function or it was not an external symbol. > > Regards, > >Shlomi Fish > > -- > - > Shlomi Fish http://www.shlomifish.org/ > Funny Anti-Terrorism Story - http://shlom.in/enemy > > She's a hot chick. But she smokes. > She can smoke as long as she's smokin'. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: (+34)935 86 89 39 Email : paumarc.mu...@bioinf.uab.cat
dinamic table creation with cgi.pm
Hi everbody! I just discovered CGI.pm package and i think it's cool, but i still having a couple of dubts Imagine i got a pice of script like that use DBI; use CGI; my $h=new CGI() ; ## some DB connection print $h->header; print $h->start_html; my $query=$q->prepare("select name, age from student"); $query->execute(); print ""; while(my @data=Sq->featchrow_array()){ print "$data[0]$data[1]\n"; } print ""; print $h->end_html; How do you would script the table part on cgi.pm, please, notice that the table could be really hugh and take a long time to be compleatly written, so , i would like to be printed as long as i'm reciving the data from the select. Thanks P
Re: dinamic table creation with cgi.pm
thanks! 2011/10/28 Shawn H Corey > On 11-10-28 09:22 AM, Pau Marc Munoz Torres wrote: > >> Hi everbody! >> >> I just discovered CGI.pm package and i think it's cool, but i still >> having >> a couple of dubts >> >> Imagine i got a pice of script like that >> >> use DBI; >> >> use CGI; >> >> my $h=new CGI() ; >> ## some DB connection >> >> print $h->header; >> print $h->start_html; >> >> my $query=$q->prepare("select name, age from student"); >> >> $query->execute(); >> >> print ""; >> > > print $h->start_table(); > > > while(my @data=Sq->featchrow_array()){ >> >>print "$data[0]$**data[1]\n"; >> > > print $h->Tr( td($data[0]), td($data[1]) ); > > >> } >> >> print ""; >> > > print $h->end_table(); > > > >> print $h->end_html; >> >> >> How do you would script the table part on cgi.pm, please, notice that the >> table could be really hugh and take a long time to be compleatly written, >> so >> , i would like to be printed as long as i'm reciving the data from the >> select. >> >> Thanks >> >> P >> >> > > -- > Just my 0.0002 million dollars worth, > Shawn > > Confusion is the first step of understanding. > > Programming is as much about organization and communication > as it is about coding. > > The secret to great software: Fail early & often. > > Eliminate software piracy: use only FLOSS. > > "Make something worthwhile." -- Dear Hunter > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >
Re: dinamic table creation with cgi.pm
Hi Shlomi thanks you for your advise, next time i would do it carefully pau 2011/10/28 Shlomi Fish > Hi Pau, > > in addition to what Shawn has written, here are a few comments on your > code: > > On Fri, 28 Oct 2011 15:22:26 +0200 > Pau Marc Munoz Torres wrote: > > > Hi everbody! > > > > I just discovered CGI.pm package and i think it's cool, but i still > having > > a couple of dubts > > > > Imagine i got a pice of script like that > > > > > > > use DBI; > > > > use CGI; > > > > Always start with "use strict;" and "use warnings;": > > http://perl-begin.org/tutorials/bad-elements/#no-strict-and-warnings > > > my $h=new CGI() ; > > That should be: > >my $h = CGI->new; > > See: > > http://perl-begin.org/tutorials/bad-elements/#indirect-object-notation > > You should also give a more meaningful variable name to the CGI instance > than > "$h". Maybe "$cgi". > > ## some DB connection > > > > print $h->header; > > print $h->start_html; > > > > my $query=$q->prepare("select name, age from student"); > > Where is $q coming from? $dbh is the common name for the DBI handle. > > > > > $query->execute(); > > > > print ""; > > while(my @data=Sq->featchrow_array()){ > > Well, ignoring the mis-spellings here and the fact that "$q" should be > "$query". > > > > >print "$data[0]$data[1]\n"; > > Make sure you avoid HTML injection / Cross-site scripting (XSS) attacks > here: > > http://en.wikipedia.org/wiki/Cross-site_scripting > > Regards, > >Shlomi Fish > > > > > } > > > > print ""; > > > > print $h->end_html; > > > > > > How do you would script the table part on cgi.pm, please, notice that > the > > table could be really hugh and take a long time to be compleatly written, > so > > , i would like to be printed as long as i'm reciving the data from the > > select. > > > > Thanks > > > > P > > > > -- > - > Shlomi Fish http://www.shlomifish.org/ > My Aphorisms - http://www.shlomifish.org/humour.html > > There is no IGLU Cabal! Its members can be arranged in N! orders to form N! > different Cabals. The algorithm to find which order formulates the correct > IGLU Cabal is NP‐Complete. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . >
recover data generated by jqurety from a form
Hi guys i have a problem recovering from data using my cgi, lets says i got the following form And i want to recover the info generated by the javascript funtion ( getCSVdata() ), do you know how i could do it? param('submit') returns "Get CSV File" thanks Pau Marc Muñoz Torres http://www.linkedin.com/in/paumarc
Re: recover data generated by jqurety from a form
Yes. It works, i fuond out the solution yesterdey, i did not recover the csv_text parameter propierly Thanks El 30/05/2013 0:29, "lesleyb" va escriure: > On Wed, May 29, 2013 at 03:09:51PM +0200, Pau Marc Muñoz Torres wrote: > > Hi guys > > > > i have a problem recovering from data using my cgi, lets says i got the > > following form > > > > > > > > >onclick="getCSVData()"> > > > > > > > > And i want to recover the info generated by the javascript funtion ( > > getCSVdata() ), do you know how i could do it? > > > > param('submit') returns "Get CSV File" > > > > thanks > > > > Pau Marc Muñoz Torres > Hi > > The form is working perfectly. You have a submit button with a specific > value, > "Get CSV File". When you query the value of the submit button you get the > expected result, "Get CSV file". > > Have you queried the value of the hidden parameter, csv_text, yet? > > Kind Regards > > Lesley > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > >
dinamic cgi with perl
Hi everybody i got a program that works in a bash environment, and now, i would like to make a cgi with it, the objective for this program is check the integrity of the info provided by some text files and if it finds some error ask you for some info and i would like to be able to introduce it. To solve it i was thinking on introduce a javascript code into my cgi, but i don't know how to pass the variable info between perl and javascript. could any of you tell me how to do it or give me any idea or give me a solution of how do it? thanks pau -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Re: dinamic cgi with perl
Hi is There some easy-understanding "how to use ajax with perl" tutorial somewhere? i just need to know how to do a cgi script to launch a prompt (javascript) and use the answer in my script please help!! pau -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Can't find string terminator "EOHTML" anywhere before EOF
Hi I just copied this script from CGI::Ajax manual at cpan.org page use strict; use CGI; # or any other CGI:: form handler/decoder use CGI::Ajax; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); print $pjx->build_html( $cgi, \&Show_HTML); sub perl_func { my $input = shift; # do something with $input my $output = $input . " was the input!"; return( $output ); } sub Show_HTML { my $html = < Enter something: EOHTML return $html; } And I get the error: Can't find string terminator "EOHTML" anywhere before EOF at ./ajax.pl line 37. What's wrong? -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Re: Can't find string terminator "EOHTML" anywhere before EOF
mmm i did in a single line and i keep havinh the problem my $html = <Enter something:EOHTML return $html; 2008/4/4, Rob Dixon <[EMAIL PROTECTED]>: > > Pau Marc Munoz Torres wrote: > > Hi > > > > I just copied this script from CGI::Ajax manual at cpan.org page > > > > use strict; > > use CGI; # or any other CGI:: form handler/decoder > > use CGI::Ajax; > > > > my $cgi = new CGI; > > my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); > > > > print $pjx->build_html( $cgi, \&Show_HTML); > > > > sub perl_func { > > my $input = shift; > > # do something with $input > > my $output = $input . " was the input!"; > > return( $output ); > > } > > > > sub Show_HTML { > > my $html = < > > > > > Enter something: > > > onkeyup="exported_func( ['val1'], ['resultdiv'] );"> > > > > > > > > > > EOHTML > > return $html; > > } > > > > And I get the error: > > > > Can't find string terminator "EOHTML" anywhere before EOF at ./ajax.pl > line > > 37. > > > > What's wrong? > > > The here-document terminator EOHTML must be on its own on the line, i.e. > there can't be any whitespace before or after it or it won't be found. > > > Rob > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
assign javascript variables to a perl variables using ajax
Hi , I got a cgi in perl, in this cgi i use ajax to ejecute a javascript code, in this code i produce a prompt, and i store the value at the res variable. now i would like to store this variabe, res into a perl variable ($res), something like $res=res How can i do that? thanks #!/usr/bin/perl use strict; use CGI; # or any other CGI:: form handler/decoder use CGI::Ajax; my $cgi = new CGI; my $pjx = new CGI::Ajax( 'exported_func' => \&perl_func ); my $script=&Show_HTML; print $pjx->build_html( $cgi, $script); sub Show_HTML { my $html .= < function valor(){ var res; res=prompt("introduir nom",""); } EOHTML return $html; }; -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
how to refresh between different pages of the same script
I have to modify a script to upload different data to a server, until now i did and script that ask you a question and capture the variable into a hash (see below), now, i would like to modify it and make something that allows me to ask different questions using the same script how can i do this? Thanks #! /usr/bin/perl #use strict; use CGI::Ajax; use CGI; my $q = new CGI; my $concatter = sub { my $buffer = $ENV{'QUERY_STRING'}; my @pairs = split( /&/, $buffer ); foreach my $pair (@pairs) { my ( $name, $value ) = split( /=/, $pair ); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $Variables{$name} = $value; } print ""; foreach (%Variables) {print "$_\n"} print ""; return ; }; my $Show_Form = sub { my $html = ""; $html = < CGI::Ajax Multiple Return Value Example Submit EOT ; return $html; }; my $Show_Form2 = sub { my $html = ""; $html = < CGI::Ajax Multiple Return Value Example form2 EOT ; return $html; }; my $pjx = CGI::Ajax->new( 'jsFunc' => $concatter); $pjx->JSDEBUG(1); $pjx->DEBUG(1); print $pjx->build_html($q,$Show_Form); # this outputs the html for the page -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Fwd: how to refresh between different pages of the same script
I have to modify a script to upload different data to a server, until now i did and script that ask you a question and capture the variable into a hash (see below), now, i would like to modify it and make something that allows me to ask different questions using the same script how can i do this? Thanks #! /usr/bin/perl #use strict; use CGI::Ajax; use CGI; my $q = new CGI; my $concatter = sub { my $buffer = $ENV{'QUERY_STRING'}; my @pairs = split( /&/, $buffer ); foreach my $pair (@pairs) { my ( $name, $value ) = split( /=/, $pair ); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $Variables{$name} = $value; } print ""; foreach (%Variables) {print "$_\n"} print ""; return ; }; my $Show_Form = sub { my $html = ""; $html = < CGI::Ajax Multiple Return Value Example Submit EOT ; return $html; }; my $Show_Form2 = sub { my $html = ""; $html = < CGI::Ajax Multiple Return Value Example form2 EOT ; return $html; }; my $pjx = CGI::Ajax->new( 'jsFunc' => $concatter); $pjx->JSDEBUG(1); $pjx->DEBUG(1); print $pjx->build_html($q,$Show_Form); # this outputs the html for the page -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED] -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Re: About FASTA file
Hi Fasta file is just a text file, so you can read it as any other text file using perl. The name usually is somthing.fasta, but you can keep the old name (output.txt) The format is: > sequence description sequence (60 letters) sequence (60 letters) For more info, reed this link http://en.wikipedia.org/wiki/FASTA_format 2007/11/10, Spiros Denaxas <[EMAIL PROTECTED]>: > > On Nov 8, 3:42 am, [EMAIL PROTECTED] (Auxence Sima) wrote: > > i have Sequence Data in a file that i named " OUTPUT.TXT",and hereis my > question. I would like to create a FASTA data file, and i wonder how to > process. do i have to just take out the info inside the OUTPUT.TXT, and > keep only Sequences, and then put them ina FASTA format?? DO i keep the > same name for the data file??? > > > > the second question is : After i have created the fasta file, will i > read the info just the same way i would with TXT file??? > > > > __ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam protection > aroundhttp://mail.yahoo.com > > You may also want to check: > > the BioPerl project @ http://www.bioperl.org/wiki/Main_Page > the BioPerl mailing list @ > http://lists.open-bio.org/mailman/listinfo/bioperl-l > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
indexing tables using my owns functions
Hi I've created a function that return a float value the code for it is : create function IDR(pin1 varchar(20),pin4 varchar(20),pin6 varchar(20),pin7 varchar(20),pin9 varchar(20),MOL varchar(20)) returns float DETERMINISTIC begin declare output float; declare P1 float; declare P4 float; declare P6 float; declare P7 float; declare P9 float; select VALUE into P1 from PSSMS where AA=pin1 and POS='1' and MOLEC=MOL; select VALUE into P4 from PSSMS where AA=pin4 and POS='4' and MOLEC=MOL; select VALUE into P6 from PSSMS where AA=pin6 and POS='6' and MOLEC=MOL; select VALUE into P7 from PSSMS where AA=pin7 and POS='7' and MOLEC=MOL; select VALUE into P9 from PSSMS where AA=pin9 and POS='9' and MOLEC=MOL; select P1+P4+P6+P7+P9 into output; return output; end // And it works, now, i would like index a table using this function. The table description is: mysql> describe precalc; +---+-+--+-+-++ | Field | Type| Null | Key | Default | Extra | +---+-+--+-+-++ | id | int(6)| NO | PRI | NULL| auto_increment | | P1| char(1) | YES || NULL|| | P4| char(1) | YES || NULL|| | P6| char(1) | YES || NULL|| | P7| char(1) | YES || NULL|| | P9| char(1) | YES || NULL|| +---+-+--+-+-++ 6 rows in set (0.01 sec) and i try index by the following command: mysql> create index AA on precalc (IDR(P1,P4,P6,P7,P9,'HLA-DRB13')); But i Get the following error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''P1','P4','P6','P7','P9','HLA-DRB13'))' at line 1 Some one knows where is the error? Thanks Pau -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]
Re: loading scripts to mysql
hi, Tanks for your help, finally i found the "source" command. It work like this: mysql> source /Lhome/geruppa/mhc/Pack_Ref_web/prova.sql 2007/11/9, Michael Gargiullo <[EMAIL PROTECTED]>: > > On Fri, 2007-11-09 at 13:22 +0100, Pau Marc Munoz Torres wrote: > > > Hi everybody > > > > I'm writing a function script in a flat file using vim, now i would > like > > load it into my sql, there is some command to do it similar to "load > data > > into" to fill tables? > > > > thanks > > > > > Sure, > >From command line: > mysql -u username -p database < file-containing-sql > > -Mike > -- Pau Marc Muñoz Torres Laboratori de Biologia Computacional Institut de Biotecnologia i Biomedicina Vicent Villar Universitat Autonoma de Barcelona E-08193 Bellaterra (Barcelona) telèfon: 93 5812807 Email : [EMAIL PROTECTED]