Retrieving Cookies does not return all domain values
I am in the process of changing my cookies (stored on my users’ browsers) so they can be shared across multiple servers under my domain. So, instead of writing cookies with domain ‘www.mydomain.com’, I am writing them to ‘.mydomain.com’ so they can be read by www.mydomain.com, www2.mydomain.com etc. During the transition, I need to be able to retrieve cookie values stored for the main domain and the subdomain. Browsers will store cookies from ‘www.mydomain.com’ and ‘.mydomain.com’ separately, and return multiple values if the target servername matches the hierarchy. However, I cannot find a way under CGI.pm or CGI::Cookie to retrieve these multiple values – only one value is ever returned. Example, I can set 2 cookies from server www.mydomain.com using: my $cookieShort = cookie(-name='var', -value=’hello_short’, -expires='+1M', -domain=’.mydomain.com’) my $cookieLong = cookie(-name='var', -value=’hello_long’, -expires='+1M', -domain=’www.mydomain.com’) print $q-header({-cookie=[$cookieShort, $cookieLong], -type='text/html', -expires='-1d'}) ; The client returns both values properly to this server, and I can see these passed to the ENV environment variable: print ENV{'HTTP_COOKIE'} ; var=hello_short; var=hello_long However, using CGI.pm or CGI::Cookie only one value (the highest level domain ) is ever returned: Print $q-cookie(-name='var') ; hello_short my @arrayCookies = $q-cookie(-name='var') ; # using array context foreach (@arrayCookies) { print $_\n ; } hello_short Is there a method to get CGI.pm to fetch all the values in the request, or am I forced to use the environment variable? Fetching cookies using an array context will only bring back multiple values if they are set under a single domain. -- To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org For additional commands, e-mail: beginners-cgi-h...@perl.org http://learn.perl.org/
2 files, 1 package, shared constants
-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? Here is a minimal example: - one.pl 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 to satisfy require() 1; - two.pl package MyPackage; use warnings; use strict; require 'one.pl'; print 'The 1st constant is: ' . MyPackage-MY_FIRST_CONSTANT . \n; print 'The 2nd constant is: ' . *MY_SECOND_CONSTANT . \n; print ' SCALAR: ' . ${*MY_SECOND_CONSTANT{SCALAR}} . \n; print ' ARRAY: ' . join(', ', @{*MY_SECOND_CONSTANT{ARRAY}}) . \n; MyPackage-routine1; - This produces output like this: $ perl ./two.pl The 1st constant is: hello world! The 2nd constant is: *MyPackage::MY_SECOND_CONSTANT ~ SCALAR: 729 ~ ARRAY: 1, 3, 7 Hello from routine1! 729 Funny thing is that in two.pl MyPackage-MY_FIRST_CONSTANT works, but neither of these: print '' . MY_FIRST_CONSTANT . \n; print '' . MyPackage::MY_FIRST_CONSTANT . \n; Bareword MY_FIRST_CONSTANT not allowed while strict subs in use at ./two.pl line ***. Execution of ./two.pl aborted due to compilation errors. So I suspect that although I managed to solve the problem, the solution with MyPackage-MY_FIRST_CONSTANT is a bug in Perl or something?? Why should I be able to call the constant subroutine, but not be able to refer to the constant as is?? Why should I even bother with all these, since I am using only 1 package MyPackage? The documentation says package is namespace is symbol table. Why does MY_FIRST_CONSTANT work as is in one.pl, and not in two.pl? I am using Perl v5.8.8. STF === http://eisenbits.homelinux.net/~stf/ . My PGP key fingerprint is: 9D25 3D89 75F1 DF1D F434 25D7 E87F A1B9 B80F 8062 === -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iD8DBQFJpSAQ6H+hubgPgGIRAoYHAJ4uRiGGwlAbjB3whHx8nDOZCN58QwCdHZTA Y7Anj2S1iXe93mES2d19REY= =iwf7 -END PGP SIGNATURE- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Simplify a script which copies files
Hi, I wrote a script which copies files in directory to an another directory based on user input. Any suggestions to simplify or shorten this? I'm using Win XP. -L code - #!/bin/perl use warnings; use strict; use File::Copy; my $dire; my $destination; my $days; #Dir from where to copy while (1){ print \nPath to dir for files to copy: ; chomp($dire = STDIN); #Check dir if ($dire !~ /^.+\/+$/){ print \nGive dir like C:/Temp/\n; next; } last; } #Dir to copy while (1){ print \nPath to copy: ; chomp($destination = STDIN); #Check dir if ($destination !~ /^.+\/+$/){ print \nGive dir like C:/Temp/\n; next; } last; } #Days from this day to copy while (1){ print \nPlease enter days from current date of modified files: ; chomp($days = ); # Check for non-numeric characters if ($days =~ /\D/){ print \nPlease enter a number; next; } last; } print \nCopied files:\n\n; opendir DIR, $dire; foreach my $filename (readdir(DIR)) { next if -d $filename; next if -f $filename and -M $filename $days; print $filename \n; copy($filename, $destination) or die Couldn't copy: $!; } end - -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
Octavian Râsnita wrote: From: Gunnar Hjalmarsson nore...@gunnar.cc Well, if I understand it correctly, Mail::Builder::Simple *enforces* the use of UTF-8, which is something I don't like. Well, I like that, because it is more simple to send special chars from more languages, but without needing to know nor to specify the charset explicitly when creating the message. Ok, then we are simply not agreed on this one. This code works, and the message is displayed just fine in my email client: use Mail::Sender; ref (new Mail::Sender - MailMsg( { smtp = 'localhost', charset = 'ISO-8859-1', from = 'Pär m...@example.com', to= 'me m...@example.com', subject = 'Östra Vägen', msg = Hello,\n\nWondering about Östra Vägen.\n, } )) or die Cannot send mail: $Mail::Sender::Error\n; I have tried to use the same code but I've changed the charset to UTF-8 (also tried utf8) and the subject to: subject = 'Östra Vägen astâîASTÂÎ', If you change the charset to UTF-8, you'd better also pass UTF-8 encoded strings to the module. That's not a UTF-8 string. snip So there should be some bugs in Mail::Sender or the module it uses for encoding the headers. As far as I know, Mail::Sender does not encode the headers, but I wouldn't call that a bug. It just means that unless the subject line is ISO-8859-1 (or ASCII), you need to encode it using quoted-printable or base64. In my experience, Mail::Sender sends messages with any encoding. This code works for me: use Mail::Sender; ref (new Mail::Sender - MailMsg( { smtp = 'localhost', charset = 'UTF-8', from = 'Pär m...@example.com', to= 'me m...@example.com', subject = '=?UTF-8?Q?' . MIME::QuotedPrint::encode('Östra Vägen', '') . '?=', msg = Hello,\n\nWondering about Östra Vägen.\n, } )) or die Cannot send mail: $Mail::Sender::Error\n; When trying to send the same message using Mail::Builder::Simple, I encountered two problems: snip 2) Mail::Builder objected, claiming that my stated From: address Pär m...@example.com is not valid (which is something I don't understand). It tells you this because the syntax for using it with Mail::Builder::Simple is different. You need to use: from = ['m...@example.com', 'Pär'], Ok, thanks. The automatic encoding of headers with non-ASCII characters is nice, but Mail::Builder::Simple is still not very useful to me, since it only permits UTF-8 encoded strings. I also don't like that Mail::Sender ads strange headers to the mail messages and I don't know why it does this. It doesn't if you say $Mail::Sender::NO_X_MAILER = 1; snip -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- 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 wrote: snip Funny thing is that in two.pl MyPackage-MY_FIRST_CONSTANT works, but neither of these: print '' . MY_FIRST_CONSTANT . \n; print '' . MyPackage::MY_FIRST_CONSTANT . \n; Concatenation seems like a bad idea. Try: print MY_FIRST_CONSTANT, \n; print MyPackage::MY_FIRST_CONSTANT, \n; (untested) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- 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
Gunnar Hjalmarsson wrote: Concatenation seems like a bad idea. Try: print MY_FIRST_CONSTANT, \n; print MyPackage::MY_FIRST_CONSTANT, \n; Ee... you mean . instead of , right? This: print MY_FIRST_CONSTANT . \n; print MyPackage::MY_FIRST_CONSTANT . \n; yields this output: MY_FIRST_CONSTANT MyPackage::MY_FIRST_CONSTANT which I would say is even more strange (but I am new to Perl). STF === http://eisenbits.homelinux.net/~stf/ . My PGP key fingerprint is: 9D25 3D89 75F1 DF1D F434 25D7 E87F A1B9 B80F 8062 === signature.asc Description: OpenPGP digital signature
Re: 2 files, 1 package, shared constants
Stanisław T. Findeisen wrote: Gunnar Hjalmarsson wrote: Concatenation seems like a bad idea. Try: print MY_FIRST_CONSTANT, \n; print MyPackage::MY_FIRST_CONSTANT, \n; Ee... you mean . instead of , right? No, I mean ,. You can print() a list. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
From: Gunnar Hjalmarsson nore...@gunnar.cc I have tried to use the same code but I've changed the charset to UTF-8 (also tried utf8) and the subject to: subject = 'Östra Vägen astâîASTÂÎ', If you change the charset to UTF-8, you'd better also pass UTF-8 encoded strings to the module. That's not a UTF-8 string. If I used it in a UTF-8 encoded perl program and was also using use utf8; in it, I expected that it understand that it should be encoded to UTF-8. So there should be some bugs in Mail::Sender or the module it uses for encoding the headers. As far as I know, Mail::Sender does not encode the headers, but I wouldn't call that a bug. It just means that unless the subject line is ISO-8859-1 (or ASCII), you need to encode it using quoted-printable or base64. Well, instead of the old type encoding of ISO-8859-1, it would have been much better if it would encode to UTF-8 and also do the MIME encoding. In my experience, Mail::Sender sends messages with any encoding. This code works for me: use Mail::Sender; ref (new Mail::Sender - MailMsg( { smtp = 'localhost', charset = 'UTF-8', from = 'Pär m...@example.com', to= 'me m...@example.com', subject = '=?UTF-8?Q?' . MIME::QuotedPrint::encode('Östra Vägen', '') . '?=', msg = Hello,\n\nWondering about Östra Vägen.\n, } )) or die Cannot send mail: $Mail::Sender::Error\n; Well, I think it is too low level to need to explicitly do the MIME encoding... It tells you this because the syntax for using it with Mail::Builder::Simple is different. You need to use: from = ['m...@example.com', 'Pär'], Ok, thanks. The automatic encoding of headers with non-ASCII characters is nice, but Mail::Builder::Simple is still not very useful to me, since it only permits UTF-8 encoded strings. Yes I know this, but since any char from any language can be found in the UTF-8 encoding, I don't think this is such a big issue... unless you need to modify an old code. I also don't like that Mail::Sender ads strange headers to the mail messages and I don't know why it does this. It doesn't if you say $Mail::Sender::NO_X_MAILER = 1; Oh sorry, I was using Mail::Sender::Easy because it has a much nicer syntax than Mail::Sender, and Mail::Sender::Easy also adds some headers that can't be disabled with a configuration. Octavian -- 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 wrote: 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. First: Please disregard my theory about concatenation. Concatenation is ok, which is clearly stated in perldoc constant. 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? Since the files share the same package, no exporting is needed. Here is a minimal example: - one.pl 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 to satisfy require() 1; - two.pl package MyPackage; use warnings; use strict; require 'one.pl'; print 'The 1st constant is: ' . MyPackage-MY_FIRST_CONSTANT . \n; print 'The 2nd constant is: ' . *MY_SECOND_CONSTANT . \n; print ' SCALAR: ' . ${*MY_SECOND_CONSTANT{SCALAR}} . \n; print ' ARRAY: ' . join(', ', @{*MY_SECOND_CONSTANT{ARRAY}}) . \n; MyPackage-routine1; I (now) believe that the problem is about compile time vs. runtime. When two.pl is compiled, one.pl has not yet been required. Two possible solutions: 1) Put the require statement in a BEGIN block. BEGIN { require 'one.pl' } 2) Convert one.pl to a module (one.pm) and use() it. use one; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
Octavian Râsnita wrote: From: Gunnar Hjalmarsson nore...@gunnar.cc Octavian Râsnita wrote: I have tried to use the same code but I've changed the charset to UTF-8 (also tried utf8) and the subject to: subject = 'Östra Vägen astâîASTÂÎ', If you change the charset to UTF-8, you'd better also pass UTF-8 encoded strings to the module. That's not a UTF-8 string. If I used it in a UTF-8 encoded perl program and was also using use utf8; in it, I expected that it understand that it should be encoded to UTF-8. I don't think that's what the utf8 pragma is about. (But, as I'm sure you understand, my UTF-8 knowledge is limited.) perldoc utf8 As far as I know, Mail::Sender does not encode the headers, but I wouldn't call that a bug. It just means that unless the subject line is ISO-8859-1 (or ASCII), you need to encode it using quoted-printable or base64. Well, instead of the old type encoding of ISO-8859-1, it would have been much better if it would encode to UTF-8 and also do the MIME encoding. AFAIK, no mail sending module automatically *encodes to UTF-8*. But I agree that MIME encoding of certain headers would have been nice. ... Mail::Builder::Simple is still not very useful to me, since it only permits UTF-8 encoded strings. Yes I know this, but since any char from any language can be found in the UTF-8 encoding, I don't think this is such a big issue... unless you need to modify an old code. There is - and will be in the foreseeable future - quite a lot of text in this world that is not UTF-8 encoded. ;-) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
Gunnar Hjalmarsson wrote: Octavian Râsnita wrote: If I used it in a UTF-8 encoded perl program and was also using use utf8; in it, I expected that it understand that it should be encoded to UTF-8. I don't think that's what the utf8 pragma is about. (But, as I'm sure you understand, my UTF-8 knowledge is limited.) perldoc utf8 This is an example program where use utf8; makes a difference: use utf8; $igår = '2009-02-24'; print Yesterday: $igår\n; (igår is Swedish for yesterday) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
[ new attempt - encoding is tricky... ] Gunnar Hjalmarsson wrote: Octavian Râsnita wrote: If I used it in a UTF-8 encoded perl program and was also using use utf8; in it, I expected that it understand that it should be encoded to UTF-8. I don't think that's what the utf8 pragma is about. (But, as I'm sure you understand, my UTF-8 knowledge is limited.) perldoc utf8 This is an example program where use utf8; makes a difference: use utf8; $igår = '2009-02-24'; print Yesterday: $igår\n; (igår is Swedish for yesterday) -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
From: Gunnar Hjalmarsson nore...@gunnar.cc [ new attempt - encoding is tricky... ] Gunnar Hjalmarsson wrote: Octavian Râsnita wrote: If I used it in a UTF-8 encoded perl program and was also using use utf8; in it, I expected that it understand that it should be encoded to UTF-8. I don't think that's what the utf8 pragma is about. (But, as I'm sure you understand, my UTF-8 knowledge is limited.) perldoc utf8 This is an example program where use utf8; makes a difference: use utf8; $igår = '2009-02-24'; print Yesterday: $igår\n; (igår is Swedish for yesterday) -- Gunnar Hjalmarsson Well I have tried the scripts from the 2 messages, but I must admit that I don't understand what I should look for. Both of them print the same thing, no matter if I use use utf8; or not Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
Octavian Râs,nit,a( wrote: From: Gunnar Hjalmarsson nore...@gunnar.cc This is an example program where use utf8; makes a difference: use utf8; $igÃ¥r = '2009-02-24'; print Yesterday: $igÃ¥r\n; (igÃ¥r is Swedish for yesterday) Well I have tried the scripts from the 2 messages, but I must admit that I don't understand what I should look for. Both of them print the same thing, no matter if I use use utf8; or not $ cat test1.pl $igÃ¥r = '2009-02-24'; print Yesterday: $igÃ¥r\n; $ cat test2.pl use utf8; $igÃ¥r = '2009-02-24'; print Yesterday: $igÃ¥r\n; $ perl test1.pl Unrecognized character \xC3 in column 4 at test1.pl line 1. $ perl test2.pl Yesterday: 2009-02-24 $ The variable name, which actually is $igår, is UTF-8 encoded in the scripts. Enabling the utf8 pragma makes Perl allow that. HTH -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
How to install Win32 module...
I downloaded and unzipped the TAR file...how do I install it...directions say copy into lib which didn't work thanks in advance -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
replace text in file
Hi All, I'm trying to replace some text in file. Below is my script. It basically makes a copy of line with changes. How can I replace pattern in the uxix sed way? use strict; use warnings; use Cwd; use Win32; use File::Path; use File::Find; use File::Basename; @ARGV = Win32::GetCwd() unless @ARGV; my @source; find (\findSource, $ARGV[0]); foreach ( @source ) { open SOURCE, +, $_ or die Error: $!\n; my @file = SOURCE; seek SOURCE,0,0; foreach my $file (@file) { if ( $file =~ /STARBUCKS.*RESTAURANT/i ) { $file =~ s/RESTAURANT/CAFE/g; print SOURCE $file; } } close SOURCE; } Example of my original file: STARBUCKS|RESTAURANT JACK IN THE BOX|RESTAURANT STARBUCKS|RESTAURANT MC DONALDS|RESTAURANT after replacement it should be like this: STARBUCKS|CAFE JACK IN THE BOX|RESTAURANT STARBUCKS|CAFE MC DONALDS|RESTAURANT Thanks in advance, Vladimir -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
We now return you to the original problem! I got the sample that Gunnar posted using Mail::Sender to work after I played around with cpan and got it installed. Now I have discovered a new problem. The SMTP server does not respond on the first try all the time. (I think this is a local problem, but I need to replace my gateway/firewall server to solve ti.) It returns a message Cannot send mail: Service not available. Reply: This comes from the internals of Mail::Sender. I found the place and it is trying to print some status code or return code right after Reply: but there isn't anything there. This is probably why the error exit at the end of the my test code isn't triggered. Here is my code: ref (new Mail::Sender - MailMsg( { smtp = 'smtpout.secureserver.net', port = '3535', # or whatever auth = 'LOGIN', authid= 't...@mgssub.com', authpwd = 'mypasswd', from = 'w...@mgssub.com', to= 'den...@wicksclan.com', subject = 'Yet another test!', msg = $msg, } )) or die Cannot send mail: $Mail::Sender::Error\n; Now the question is, how can I trap that error message from the Mail::Sender module and repeat as needed? Thanks for all the help! Dennis -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: replace text in file
On 2/25/09 Wed Feb 25, 2009 5:02 PM, lemba le...@sbcglobal.net scribbled: Hi All, I'm trying to replace some text in file. Below is my script. It basically makes a copy of line with changes. How can I replace pattern in the uxix sed way? I don't use sed, but you can use Perl one-liners to emulate sed. See 'perldoc perlrun' and the -p, -I, and -e options. Example: perl -p -i -e 's/(starbucks.*)restaurant/$1CAFE/i' file.txt Although for more control, you might still want to write a full script. Even in a full script, you can use the $^I variable to enable in-place editing using the file input operator, if desired, emulating the -I command-line option. use strict; use warnings; use Cwd; use Win32; use File::Path; use File::Find; use File::Basename; @ARGV = Win32::GetCwd() unless @ARGV; my @source; find (\findSource, $ARGV[0]); You don't seem to be showing us your full script (findSource is missing). I will assume that findSource puts file names to modify in the @source array. foreach ( @source ) { open SOURCE, +, $_ or die Error: $!\n; You might want to add the file name ($_) to your error message. open SOURCE, +, $_ or die Error in file $_: $!\n; my @file = SOURCE; @file is not a good variable name for an array that holds lines in a file. I would suggest @lines might be better. seek SOURCE,0,0; foreach my $file (@file) Maybe $line is a better name than $file here? { if ( $file =~ /STARBUCKS.*RESTAURANT/i ) { $file =~ s/RESTAURANT/CAFE/g; print SOURCE $file; You want to print $file if it doesn't match, so move this print statement below the if statement (but see below for a solution that doesn't involve an if statement.) } } There is no need to first test if $file matches, then substitute if it does. The s/// operator will not substitute unless there is a match. You just have to save the data you are matching or use look-ahead, look-behind constructs. I find it easier to save, as I can never remember the syntax for look-arounds: $file =~ s/(STARBUCKS.*)RESTAURANT/$1CAFE/i; print SOURCE $file; close SOURCE; } Example of my original file: STARBUCKS|RESTAURANT JACK IN THE BOX|RESTAURANT STARBUCKS|RESTAURANT MC DONALDS|RESTAURANT after replacement it should be like this: STARBUCKS|CAFE JACK IN THE BOX|RESTAURANT STARBUCKS|CAFE MC DONALDS|RESTAURANT Thanks in advance, Vladimir -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Word too long specific to System/memory concern ?
Hi, I have a perl script file with a statement as this $path = LD_LIBRARY_HOME=$HOME/bin; If i just change this to $path = LD_LIBRARY_HOME=$HOME/bin*:/lib:/usr/lib* ; I start getting Word too long error. On deep analysis and lots of testing , i find that this happens only on a specific solaris10 machine. I doubt it has somethign to do with system configuration or memory allocations. Can someone share any pointers that would help me resolve the Word too long issue ? Is there anyway i can do some settings that would help me solve this. Thanks in advance
Re: Word too long specific to System/memory concern ?
word too long is a Shell error, are you using back-ticks or system() to invoke an external command? That would spawn a new process and, it you have modified the PATH to contain more that the system-implementation maximum length. B On Wed, Feb 25, 2009 at 10:16 PM, Anisha Parveen anishaparveen2...@gmail.com wrote: Hi, I have a perl script file with a statement as this $path = LD_LIBRARY_HOME=$HOME/bin; If i just change this to $path = LD_LIBRARY_HOME=$HOME/bin*:/lib:/usr/lib* ; I start getting Word too long error. On deep analysis and lots of testing , i find that this happens only on a specific solaris10 machine. I doubt it has somethign to do with system configuration or memory allocations. Can someone share any pointers that would help me resolve the Word too long issue ? Is there anyway i can do some settings that would help me solve this. Thanks in advance -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: Sending email w/Mail::Builder::Simple -- need help
Dennis G. Wicks wrote: We now return you to the original problem! What's that about? Oh, yeah... ;-) I got the sample that Gunnar posted using Mail::Sender to work after I played around with cpan and got it installed. Now I have discovered a new problem. The SMTP server does not respond on the first try all the time. (I think this is a local problem, but I need to replace my gateway/firewall server to solve ti.) It returns a message Cannot send mail: Service not available. Reply: snip Now the question is, how can I trap that error message from the Mail::Sender module and repeat as needed? Try this: my $sender = Mail::Sender-new( { smtp = 'smtpout.secureserver.net', port = '3535', from = 'w...@mgssub.com', } ); ref $sender or die Object creation failed: $Mail::Sender::Error\n; for my $try (1..4) { if ( ref( $sender-MailMsg( { auth= 'LOGIN', authid = 't...@mgssub.com', authpwd = 'mypasswd', to = 'den...@wicksclan.com', subject = 'Yet another test!', msg = $msg, } ) ) ) { print Message was sent.\n; last; } else { warn Send attempt $try. $sender-{'error_msg'}\n; $try == 4 ? die 'I give up' : sleep 10; } } -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/