Re: undefined value error
Xiangli Zhang wrote: I got the following error when one cgi file 'test.cgi' was called from HTML: Can't call method sequence on an undefined value However I can run 'test.cgi' with command 'perl test.cgi' correctly. Can anybody help me figure out the problem? The following is my code: error happened on bold lines. thanks, #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use warnings; use diagnostics; use DNAalign; use fastream; use DNAseq; print Content-type: text/html\n\n; print htmlheadtitlePerl CGI Example # 2; print /title/headbodyh1; print Alignment Result /h1p; print pre; chdir(/srv/www/httmp/default/chromat_dir); my $seq1=fastream-new(default.fasta.screen.contigs); my $seq2=fastream-new(secondFile); my $test1=$seq1-next_seq(); my $test2=$seq2-next_seq(); my $s1=$test1-sequence(); my $s2=$test2-sequence(); print input1===$s1\n; print input2===$s2\n; ($sa,$sb)=DNAalign::align($test1,$test1); $result1=$sa-sequence(); $result2=$sb-sequence(); print \n; print result1=== $result1\n; print result2=== $result2\n; print /pre; print /p; print /body/html; Xiangli Zhang (Justin) 306-310 Decaire Street, Coquitlam BC, Canada, V3K 6X1 phone: 604-9399181 Xiangli Zhang (Justin) 306-310 Decaire Street, Coquitlam BC, Canada, V3K 6X1 phone: 604-9399181 - Post your free ad now! Yahoo! Canada Personals Justin, I think you are making a basic 'cgi' error. The error may stem from the fact that the 'State' of the html page cannot change once it is printed. Try moving all of the statements that might change the state of the script (i.e. chdir(/srv/www/httmp/default/chromat_dir); my $seq1=fastream-new(default.fasta.screen.contigs); my $seq2=fastream-new(secondFile); my $test1=$seq1-next_seq(); my $test2=$seq2-next_seq(); my $s1=$test1-sequence(); my $s2=$test2-sequence(); and so on) ahead of the html header print Content-type: text/html\n\n; Let me know how you make out. Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: undefined value error
--- David Kirol [EMAIL PROTECTED] wrote: Xiangli Zhang wrote: I got the following error when one cgi file 'test.cgi' was called from HTML: Can't call method sequence on an undefined value use DNAseq; print Content-type: text/html\n\n; Justin, I think you are making a basic 'cgi' error. The error may stem from the fact that the 'State' of the html page cannot change once it is printed. Try moving all of the statements that might change the state of the script (i.e. chdir(/srv/www/httmp/default/chromat_dir); snip ... and so on) ahead of the html header print Content-type: text/html\n\n; If that works I would be surprized. The original error states that a subroutine in package DNAseq is at fault -- I thought this was asked and answered already anyways? -Sx- = -Sx- seeking employment: http://youve-reached-the.endoftheinternet.org/ __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Fwd: Re: undefined value error
David: It doesnot work, instead HTTP 500 - Internal server error happened.Page "test.cgi" cannot even display. Anyway, thank you for your suggestion.Note: forwarded message attached.Xiangli Zhang (Justin)306-310 Decaire Street, CoquitlamBC, Canada, V3K 6X1phone: 604-9399181 Do you Yahoo!?vote.yahoo.com - Register online to vote today!---BeginMessage--- Xiangli Zhang wrote: I got the following error when one cgi file 'test.cgi' was called from HTML: Can't call method sequence on an undefined value However I can run 'test.cgi' with command 'perl test.cgi' correctly. Can anybody help me figure out the problem? The following is my code: error happened on bold lines. thanks, #!/usr/bin/perl use CGI; use CGI::Carp qw(fatalsToBrowser); use warnings; use diagnostics; use DNAalign; use fastream; use DNAseq; print Content-type: text/html\n\n; print htmlheadtitlePerl CGI Example # 2; print /title/headbodyh1; print Alignment Result /h1p; print pre; chdir(/srv/www/httmp/default/chromat_dir); my $seq1=fastream-new(default.fasta.screen.contigs); my $seq2=fastream-new(secondFile); my $test1=$seq1-next_seq(); my $test2=$seq2-next_seq(); my $s1=$test1-sequence(); my $s2=$test2-sequence(); print input1===$s1\n; print input2===$s2\n; ($sa,$sb)=DNAalign::align($test1,$test1); $result1=$sa-sequence(); $result2=$sb-sequence(); print \n; print result1=== $result1\n; print result2=== $result2\n; print /pre; print /p; print /body/html; Xiangli Zhang (Justin) 306-310 Decaire Street, Coquitlam BC, Canada, V3K 6X1 phone: 604-9399181 Xiangli Zhang (Justin) 306-310 Decaire Street, Coquitlam BC, Canada, V3K 6X1 phone: 604-9399181 - Post your free ad now! Yahoo! Canada Personals Justin, I think you are making a basic 'cgi' error. The error may stem from the fact that the 'State' of the html page cannot change once it is printed. Try moving all of the statements that might change the state of the script (i.e. chdir(/srv/www/httmp/default/chromat_dir); my $seq1=fastream-new(default.fasta.screen.contigs); my $seq2=fastream-new(secondFile); my $test1=$seq1-next_seq(); my $test2=$seq2-next_seq(); my $s1=$test1-sequence(); my $s2=$test2-sequence(); and so on) ahead of the html header print Content-type: text/html\n\n; Let me know how you make out. Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response ---End Message--- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: undefined value error
Xiangli Zhang [EMAIL PROTECTED] wrote: : It does not work, instead HTTP 500 - Internal server : error happened.Page test.cgi cannot even display. Show us the updated code you are using. We'll also need to see the modules you are using. They don't seem to be from CPAN. Either provide their source or a url where we can view them. : Note: forwarded message attached. Attaching forwarded messages is annoying. Just post below the pertinent information and delete everything else. Like I did here. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: undefined value error
Here is my updated code with errorHTTP 500 that did not happened for the old code, and the modules I am using. thank you justinz test.cgi: #!/usr/bin/perl #use lib '/srv/www/cgi-bin/phrap/perl-lib'; use CGI; use CGI::Carp qw(fatalsToBrowser); use warnings; use diagnostics; use File::Basename; use DNAalign; use fastream; use DNAseq; my $dir=/srv/www/httmp/justin/p1/chromat_dir; my $key; foreach $key (sort keys(%INC)) { # print $key = $INC{$key}\n; } chdir($dir); my $seq1=fastream-new(p1.fasta.screen.contigs); my $seq2=fastream-new(p1.fasta.screen.contigs); my $test1=$seq1-next_seq(); my $test2=$seq2-next_seq(); my $s1=$test1-sequence(); my $s2=$test2-sequence(); #print ** $s1\n\n\n; #print $s2\n\n\n; my ($sa,$sb)=DNAalign::align($test1,$test2); my $result1=$sa-sequence(); print Content-type: text/html\n\n; print htmlheadtitlePerl CGI Example # 2; print /title/headbodyh1; print /h1p; print pre; print $result1\n\n\n; print /pre; print /p; print /body/html; DNAalign.pm # Keith Anthony Boroevich -- 24.11.2003 package DNAalign; use strict; use Carp; use diagnostics; use File::Temp 'tempfile', 'tempdir'; use fastream; my $tdir = tempdir('DNAalignX', TMPDIR = 1, CLEANUP = 1); BEGIN { } sub align { my $seq1 = shift; my $seq2 = shift; my %options = ( ALGORITHM = 'lagan', FILENAME = undef, STYLE = undef, ); %options = (%options, @_) if @_; # --- align sequences --- # my @aseq; if(uc($options{ALGORITHM}) eq 'LAGAN') { @aseq = lagan($seq1,$seq2); } elsif (uc($options{ALGORITHM}) eq 'CLUSTAL') { croak Clustal not yet supported.\n; return ($seq1,$seq2); } # elsif other formats else { croak Unknown Algorithm: ,$options{ALGORITHM},.\n; return ($seq1,$seq2); } #--- output file if requested ---# if (defined($options{FILENAME})) { open OFILE, $options{FILENAME}; if ((uc($options{STYLE}) eq 'FASTA')||(! $options{STYLE})) { foreach my $aseq (@aseq) { print OFILE $aseq; } } elsif (uc($options{STYLE}) eq 'CLUSTAL') { print OFILE clustal_format(@aseq); } close OFILE; } return (@aseq); } sub lagan { my $seq1 = shift; my $seq2 = shift; # --- create sequence files --- # my ($ofh1,$ofile1) = tempfile( TEMPLATE = 'kabX', SUFFIX = '.fas', UNLINK = 1, DIR = $tdir); print $ofh1 $seq1; system(/data/software/RepeatMasker/current/RepeatMasker -qq -int -nocut $ofile1 /dev/null); my ($ofh2,$ofile2) = tempfile( TEMPLATE = 'kabX', SUFFIX = '.fas', UNLINK = 1, DIR = $tdir); print $ofh2 $seq2; system(/data/software/RepeatMasker/current/RepeatMasker -qq -int -nocut $ofile2 /dev/null); # --- align sequences --- # my ($ifh, $ifile) = tempfile( TEMPLATE = 'kabX', SUFFIX = '.fas', UNLINK = 1, DIR = $tdir); close($ifh); #print `/data/software/lagan/current/lagan.pl $ofile1 $ofile2 -mfa $ifile`; # With lagan reporting system(/data/software/lagan/current/lagan.pl $ofile1 $ofile2 -mfa $ifile 2 /dev/null); my $istream = fastream-new($ifile); my @seqs; while (my $seq = $istream-next_seq()) { push @seqs, $seq; } return @seqs; } sub clustal_format { my @seqs = @_; my $count = $#seqs; my $minlength = $seqs[0]-length(); foreach (@seqs) { $minlength = $_-length() if $_-length() $minlength; } my $cf = CLUSTAL X (1.8) multiple sequence alignment\n\n; for (my $i = 0; $i $minlength; $i+=50) { foreach (@seqs) { $cf .= $_-id().' '.$_-subseq($i,50).\n; } $cf .= \n; } return $cf; } END { } 1; == fastream.pm #Keith Anthony Boroevich package fastream; use strict; use Carp; use DNAseq; use diagnostics; #---# #- Constructor -# #---# sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = { ifile = undef, ofile = undef, position = undef, endoffile = 0 }; if ($_[0]) { if (-r $_[0]) { $self-{ifile} = $_[0]; $self-{position} = 0; } else { croak Cannot read file ,$self-{ifile},.\n; } } bless($self,$class); return $self; } #--# #- Attributes -# #--# # retrun or set the filename sub infilename { my $self = shift; if (@_) { $self-{ifile} = shift; $self-{position} = 0; unless (-r $self-{ifile}) { croak Cannot read file ,$self-{ifile},.\n; $self-{file} = undef; $self-{position} = undef; } } return $self-{ifile}; } # return the end of file flag (Retruns 1 if the eof has been hit) sub endoffile { my $self = shift; return $self-{endofile}; } #---# #- Methods -# #---# sub next_seq { my $self = shift; #check validity of reading next sequence return 0 if $self-{endoffile}; unless(defined($self-{ifile})) { carp No input filename is defined; return 0; } #check file position open iFILE, $self-{ifile};
Re: Problem with subroutines with hash and var as input
Edward Wijaya wrote: On Fri, 01 Oct 2004 08:58:44 -0700, John W. Krahn [EMAIL PROTECTED] wrote: Since $HoH now contains a reference to a hash you have to dereference it properly. delete $HoH-{ $k } if keys %${ $HoH-{ $k } } $limit; return %$HoH; I apologize for insisting John. Tried as you suggested: 64: sub reduce_hash2 { 65:my ($HoH,$limit) = @_; 66:foreach my $k ( keys %${HoH} ) { 67: delete $HoH-{ $k } if keys %${ $HoH-{ $k } } $limit; 68:} 69: return %$HoH; 70: } with this command: my %new_hoh = reduce_hash2(\%hoh,2); Gives error: Not a SCALAR reference at testcode.pl line 67. Sorry, there is an extra $ in there, it should be: 67: delete $HoH-{ $k } if keys %{ $HoH-{ $k } } $limit; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Problem with subroutines with hash and var as input
On Sat, 02 Oct 2004 01:46:01 -0700, John W. Krahn [EMAIL PROTECTED] wrote: there is an extra $ in there, it should be: 67: delete $HoH-{ $k } if keys %{ $HoH-{ $k } } $limit; Thanks a lot John. Now it's ok. RegardS, Edward WIJAYA SINGAPORE -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Howto reverse SortByValue with Tie::IxHash
Hi, I have a problem using Tie::IxHash. My question is how can I sort the hash by value in descending order. I tried this to get the descending order, but doesn't seem to work: __BEGIN__ my %hash =( '1-1' = 3, '2-3' = 2, '2-2' = 1, '1-2' = 6, '1-3' = 3 ); my $t = Tie::IxHash-new(%hash); $t-SortByValue; # ascending, ok! $t-$hash{$b}=$hash{$a}SortByValue; #tried this but doesn't work __END__ Can anybody advice how to go about this? Thanks beforehand. Regards, Edward WIJAYA SINGAPORE -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Howto reverse SortByValue with Tie::IxHash
Edward Wijaya wrote: my $t = Tie::IxHash-new(%hash); $t-SortByValue; # ascending, ok! $t-$hash{$b}=$hash{$a}SortByValue; #tried this but doesn't work Where in the docs for Tie::IxHash did you find that syntax? You can obviously not just guess and hope that Perl will read your mind. Did you possibly consider to use the Reorder method? Edward, you have asked for help with this application a vast number of times on this list as well as other similar forums. There are reasons to believe that there is something fundamentally wrong with your methods for reading the docs and learning new stuff. You are posting way too many questions IMO. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Howto reverse SortByValue with Tie::IxHash
Gunnar Hjalmarsson mailto:[EMAIL PROTECTED] wrote: : Edward Wijaya wrote: : : : : my $t = Tie::IxHash-new(%hash); : : $t-SortByValue; # ascending, ok! : : : : $t-$hash{$b}=$hash{$a}SortByValue; # tried this but : : # doesn't work : : Where in the docs for Tie::IxHash did you find that syntax? : You can obviously not just guess and hope that Perl will : read your mind. I think Ed is getting 'sort' mixed in there. Gunnar's right, Ed. You can't just make syntax up. (Well, not without a lot more programming, anyway.) : Did you possibly consider to use the Reorder method? This is a tough one. You need to supply a list of keys to the Reorder() method. Getting the list of keys already sorted by value may not be apparent to a beginner. If $t-SortByValue() sorts the hash by values, then $t-SortByValue()-Keys() will return the keys for that sort. We want to supply the reverse of those keys. $t-Reorder( reverse $t-SortByValue()-Keys() ); HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: How TO CREATE RUNTIME CONTROLS
atul ashpalia [EMAIL PROTECTED] wrote: : I want to create runtime controls on the same webpage. : For example, my webpage will contain a textbox, a : hyperlink a submit button. : I want to achieve the following functionality: : That is, if i click on the hyperlink, a new textboxes : should be placed below the first one, if i click the : second time on the hyperlink, another new textbox will : be appended/placed below the 2nd one...and so on... Yes, that is complicated, but easy to write. How are you generating the form now? Show us your code to process it without the link to add fields and we can help you do the rest. : Then on submit button, a new page is called where the : data will be displaced which the user enters. The documentation for CGI.pm can show you how to do this. CGI.pm is part of the standard distribution. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Howto reverse SortByValue with Tie::IxHash
On Sat, 2 Oct 2004 08:53:02 -0500, Charles K. Clarkson [EMAIL PROTECTED] wrote: This is a tough one. You need to supply a list of keys to the Reorder() method. Getting the list of keys already sorted by value may not be apparent to a beginner. $t-Reorder( reverse $t-SortByValue()-Keys() ); Thanks so much for your explanation and understanding, Clark. I get it now. Also thanks for your correction, Gunnar. I know I've been rather annoying to you guys lately...Thanks for bearing with it ... :-) I will keep it mind your suggestions. Gratefuly yours, Edward WIJAYA SINGAPORE -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: sum a column
I apologize, I did miss read that comment about the author and having a clue. I thought it said does not. I will attempt the helpful advice and let you know. Thanks, Rob -Original Message- From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sent: Friday, October 01, 2004 12:02 PM To: [EMAIL PROTECTED] Subject: Re: sum a column Rmck wrote: Gunnar Hjalmarsson wrote: Rmck wrote: Im not sure how to sum up the column... I tried by using the field and * it by the increment. That awkward attempt seems to be made by someone who hasn't a clue about programming. I have written every part of my script, The script author does have a clue about programming. This is a beginner's mailing list. I'm sorry my script is not at your level, I'm learning. Please show us that you are learning! Prove that I'm wrong by showing us how you applied Wiggins' helpful advice in your code. I think telling someone on a beginners mailing list that they don't have a clue is inappropriate. But I didn't say that about the script author, and you claim to be the script author, so what's the problem? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE : Becoming Disenheartened - Everyone talks about Python and says Perl is old news.
-Message d'origine- De : Nicolay A. Vasiliev [mailto:[EMAIL PROTECTED] Envoyé : vendredi 1 octobre 2004 22:39 À : Perl Beginners List Objet : Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news. I didn't mean CGI, only standart types. s.replace(...) is a consequence of everything is object thinking. Look at the following: import re; m = re.match(r(?Pint\d+)\.(\d*), '3.14'); //After performing this match //m.group(1) is '3', as is m.group('int') //and m.group(2) is '14'. There is a similar ugly thing in Java. All of this because you want everything to be an object. Can you tell us how will you perform the above matching without import re; :). In Perl you don't absolutely need a kind of use RE; to be able performing regular expression macthing. So, don't force my $s = I am Perl Guru; to be an object and contain a replace() method. $s is a string will be treated as is in Perl. José. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: RE : Becoming Disenheartened - Everyone talks about Python and says Perl is old news.
Dear friend! I MEANT STANDART TYPES. ARE YOU ABLE TO SEE THE DIFFERENCE? If you assign the value for string variable it automaticaly gets the number of methods belonging to String object. And as an example I wrote the s.replace statement.. The similar approach has Ruby. Of course, if you need more complicated functionality you make import or another including of some module. I wrote about this only to show what can the real OO language (Python of course could be figured as procedural language too). Jose Nyimi wrote: -Message d'origine- De : Nicolay A. Vasiliev [mailto:[EMAIL PROTECTED] Envoyé : vendredi 1 octobre 2004 22:39 À : Perl Beginners List Objet : Re: Becoming Disenheartened - Everyone talks about Python and says Perl is old news. I didn't mean CGI, only standart types. s.replace(...) is a consequence of everything is object thinking. Look at the following: import re; m = re.match(r(?Pint\d+)\.(\d*), '3.14'); //After performing this match //m.group(1) is '3', as is m.group('int') //and m.group(2) is '14'. There is a similar ugly thing in Java. All of this because you want everything to be an object. Can you tell us how will you perform the above matching without import re; :). In Perl you don't absolutely need a kind of use RE; to be able performing regular expression macthing. So, don't force my $s = I am Perl Guru; to be an object and contain a replace() method. $s is a string will be treated as is in Perl. José. -- - Nicolay A. Vasiliev http://www.spamliquidator.com - Real spam fighter http://www.soft411.com - Excellent soft archive -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: RE : Becoming Disenheartened - Everyone talks about Python and says Perl is old news.
From: Nicolay A. Vasiliev [EMAIL PROTECTED] I MEANT STANDART TYPES. ARE YOU ABLE TO SEE THE DIFFERENCE? If you assign the value for string variable it automaticaly gets the number of methods belonging to String object. And as an example I wrote the s.replace statement.. The similar approach has Ruby. Of course, if you need more complicated functionality you make import or another including of some module. And we were trying to explain to you that it doesn't really matter whether you have some builtin method of the builtin types or just a buch of builtin functionsoperators. And that we actually prefer the second for the very basic types like numbers and strings. I asked you in another mail whether you'd rather write x = y.sin().plus(z) or x = sin(x) + z What's the reply? I wrote about this only to show what can the real OO language (Python of course could be figured as procedural language too). Do not sweat about real whatever langauges. That's not what gets the job done. So Perl doesn't treat the base types like objects. So what? That doesn't make its support for OO programming any less complete. Yeah in strongly typed languages with oldstyle type system (read all mainstream strongly typed langauges including Java and C#) need some base Object type that all other types, including the base ones, inherit from. You don't need this in Perl, you can pass a number or a string or an object to the same function or method and the method may easily be programmed to accept them all and do the right thing. Even if some of them are not considered objects. In my opinion forcing everything to be an object is wrong. Or at least inconvenient. (Especialy the way Java/C# does it.) But that's just my personal preference. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Becoming Disenheartened - Everyone talks about Python and says
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (JupiterHost.Net) writes: Nicolay A. Vasiliev wrote: I didn't mean CGI, only standart types. Everyone is just using your own examples as examples of why your arguments are moot :) That's the last .02 I'm spending on this crazy thread :) The CGI.pm was a red herring. The OP is complaining that Perl does not do autoboxing. He might be interested in using this: http://search.cpan.org/~chocolate/autobox-0.11/lib/autobox.pm I know, it's another module to use... but it does provide the precious autoboxing. Disclaimer: I haven't used it, I haven't verified that claim. Also, see: http://search.cpan.org/~swalters/autobox-Core-0.2/Core.pm -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
OT: Email syntax validation
As a result of the thread Check for valid email address, I have modified my emailsyntax() function to better conform to RFC 822. After all, I wouldn't like e.g. my contact form module to reject Randal when he has changed addresses. ;-) I skipped the specification's domain-literal alternative, at least for the time being. This is the modified function: sub emailsyntax { return 1 unless my ($localpart, $domain) = shift =~ /^(.+)@(.+)/; my $atom = '[^[:cntrl:] (),.:;@\[\]]+'; my $qstring = '(?:.|[^\s]|[ \t])*'; my $word = qr($atom|$qstring); return 1 unless $localpart =~ /^$word(?:\.$word)*$/; $domain =~ /^$atom(?:\.$atom)+$/ ? 0 : 1; } my $test = 'fred[EMAIL PROTECTED]'; print $test is , emailsyntax($test) ? 'not ' : '', ok.\n; Looking forward to your critique. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response