searching a string
Hi i am searching for a string of consecutive words say the lucky coin These may be in one line or different line separated by blank lines such as 1the lucky coin 2thelucky coin 3the lucky coin Whats the way in perl ? mark ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: searching a string
What I would do is elliminate all the extra white space; s/\w/ /g; s/\r\n/ /g; then do a match. /the lucky coin/; Dennis - Original Message - From: mark sony [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 02 13 Subject: searching a string Hi i am searching for a string of consecutive words say the lucky coin These may be in one line or different line separated by blank lines such as 1the lucky coin 2thelucky coin 3the lucky coin Whats the way in perl ? mark ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: searching a string
$string = the\n\tlucky\n\t\tcoin; if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coin(\s)*$/) { print Yup; }
Re: delete pattern from text file
On Mon, 17 Mar 2003 12:30:02 -0500, [EMAIL PROTECTED] (Andrew Hughes) wrote: submit the file gets read into memory. If I open the file as open (DELETEFILE, . etc., the list gets overwritten entirely with nothing. If I open the file as open (DELETEFILE, . etc, the info gets stored into memory because I can print it out using print @emailfile which gives me the entire file. Then, when I try to print back to the file, it is the entire The first thing I always do is change the syntax to it's simplest known-to-work style and then work from there. I would try taking the concantation out of the open statement to eliminate that possibility. Like: sub deleteFromSubscribeList { my $outfile = $mailingListPath . $mailingListName; open (DELETEFILE, . $mailingListPath . $mailingListName) or die cannot open file for appending: $!; open (DELETEFILE, $outfile) or die $!; flock (DELETEFILE, 2) or die cannot lock file exclusively: $!; my @emailfile = DELETEFILE; # -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Re: searching a string
Hi It is giving the found status everytime even when there are no strings: My script: #!/usr/local/bin/perl -w #use strict; #use warnings; while (test.s) { $string = the\n\tlucky\n\t\tcoins; if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coins(\s)*$/) { print Yup,exists.\n; } else { print nope \n; } } test.s doesnt have anything $ perl x.pl Yup,exists. $ mark On Tue, 18 Mar 2003 [EMAIL PROTECTED] wrote : $string = the\n\tlucky\n\t\tcoin; if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coin(\s)*$/) { print Yup; } ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Searching a string from a file
Note: Forwarded message attached -- Orignal Message -- From: mark sony [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Re: searching a string ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn ---BeginMessage--- Hi It is giving the found status everytime even when there are no strings: My script: #!/usr/local/bin/perl -w #use strict; #use warnings; while (test.s) { $string = the\n\tlucky\n\t\tcoins; if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coins(\s)*$/) { print Yup,exists.\n; } else { print nope \n; } } test.s doesnt have anything $ perl x.pl Yup,exists. $ mark On Tue, 18 Mar 2003 [EMAIL PROTECTED] wrote : $string = the\n\tlucky\n\t\tcoin; if ($string =~ m/^(\s)*the(\s)*lucky(\s)*coin(\s)*$/) { print Yup; } ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ---End Message--- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Good Perl cgi book?
What is the best book for a beginner to get started with on Perl and CGI? Bob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Good Perl cgi book?
These all helped me... - Learning Perl - Perl/CGI Cookbook - CGI Programming with Perl - Standard POD documentation - http://www.perldoc.com Scot Robnett inSite Internet Solutions -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Good Perl cgi book?
Bob X wrote: What is the best book for a beginner to get started with on Perl and CGI? Bob MY favorite is /Sams Teach Yourself Perl in 24 Hours./ Tim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Good Perl cgi book?
Get the mother of all perl books: Programming Perl (from O'reilly) by Larry Wall (perl creator), Tom Christainsen, and Jon Orwant. It moves at a comfortable pace and lets you dig as deep as you want. It's also actually a fun read! Try saying that about most programming books. (of course, I am a geek, so you may not enjoy it as much as I did) Good luck. -P -Original Message- From: Bob X [mailto:[EMAIL PROTECTED] Sent: Monday, March 17, 2003 2:31 PM To: [EMAIL PROTECTED] Subject: Good Perl cgi book? What is the best book for a beginner to get started with on Perl and CGI? Bob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Good Perl cgi book?
Elizabeth Castro's Perl and CGI for the WWW: Visual Quickstart Guide. In a message dated 3/18/2003 8:45:04 AM Eastern Standard Time, [EMAIL PROTECTED] writes: What is the best book for a beginner to get started with on Perl and CGI?
Re: Good Perl cgi book?
Blatant and shameless self-promotion.. see my sig.. :) On Mon, Mar 17, 2003 at 05:30:44PM -0500, Bob X ([EMAIL PROTECTED]) said something similar to: What is the best book for a beginner to get started with on Perl and CGI? Bob -- [Writing CGI Applications with Perl - http://perlcgi-book.com] Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen a angry penguin charging at them in excess of 100mph. They'd be a lot more careful about what they say if they had. -- Linus Torvalds -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Good Perl cgi book?
Get the mother of all perl books: Programming Perl (from O'reilly) by Larry Wall (perl creator), Tom Christainsen, and Jon Orwant. That is the mother of all perl books. It's also more of a reference book than anything else. Altho if you're that type of learner, it'll be a great read. It should also sit on the bookshelf of any Perl programmer, regardless of whether they use it to read from cover to cover, or to lookup those miscelanious little tid bits they kind of know and need clarification on. Dennis -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Good Perl cgi book?
On Tue, 18 Mar 2003, Dennis Stout wrote: That is the mother of all perl books. It's also more of a reference book than anything else. Altho if you're that type of learner, it'll be a great read. It should also sit on the bookshelf of any Perl programmer, regardless of whether they use it to read from cover to cover, or to lookup those miscelanious little tid bits they kind of know and need clarification on. Any programming manual that has _The Lord of the Rings_ on its list of recommended reading is certainly worth owning, IMHO. *_^ -- Brett http://www.chapelperilous.net/ The first half of our lives is ruined by our parents and the second half by our children. -- Clarence Darrow -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem with regular expressions!!!
As u probably have guessed some part of my code is not working properly and i don't understand why!! This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # As u see, i'm trying to separate the complete name of a file in two parts, the filename ($1) and the extension($2)... then i check to see whatever a extension is of some kind and if it is, i do something. However this doesn't work. Because in $2, perl adds a . before the extension. 4 example: if file_completename equal to myfile.jpeg, then $2 equials to .jpeg, but it should be jpeg. What am i doing wrong? Thank u very much, Marcelo Taube _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with regular expressions!!!
This is a newbie observation, but aren't you not supposed to name one of your own variables with a number as the first value after a $, @, or % as in the case of $2? Could this be part of the problem? Andrew -Original Message- From: Marcelo Taube [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 4:29 PM To: [EMAIL PROTECTED] Subject: Problem with regular expressions!!! As u probably have guessed some part of my code is not working properly and i don't understand why!! This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # As u see, i'm trying to separate the complete name of a file in two parts, the filename ($1) and the extension($2)... then i check to see whatever a extension is of some kind and if it is, i do something. However this doesn't work. Because in $2, perl adds a . before the extension. 4 example: if file_completename equal to myfile.jpeg, then $2 equials to .jpeg, but it should be jpeg. What am i doing wrong? Thank u very much, Marcelo Taube _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with regular expressions!!!
This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # did u turn on warnings and use strict ?? did you catch the ] at the end of $extension? i tried this on my machine and it works fine: $fn = test.jpg; if ($fn =~ /(.*?)\.(.*)/ ) { print $2 } # prints jpg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with regular expressions!!!
On Tue, 18 Mar 2003, Marcelo Taube wrote: As u probably have guessed some part of my code is not working properly and i don't understand why!! This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # You should use the split function here: my @file = split /\./, $file_completename; $file[1] will contain the extension, without the leading . -- Brett http://www.chapelperilous.net/ When you speak to others for their own good it's advice; when they speak to you for your own good it's interference. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with regular expressions!!!
It looks odd to me b/c * and ? are both quantifiers which usually triggers an error when you try to run it. See if this works for you: $file_completename =~ /([^.]*)\.(.*)/; On Tue, 2003-03-18 at 15:28, Marcelo Taube wrote: As u probably have guessed some part of my code is not working properly and i don't understand why!! This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # As u see, i'm trying to separate the complete name of a file in two parts, the filename ($1) and the extension($2)... then i check to see whatever a extension is of some kind and if it is, i do something. However this doesn't work. Because in $2, perl adds a . before the extension. 4 example: if file_completename equal to myfile.jpeg, then $2 equials to .jpeg, but it should be jpeg. What am i doing wrong? Thank u very much, Marcelo Taube _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem with regular expressions!!!
hmmm, sorry. That ] is not in my original code and it's not the problem i just made a mistake when writing the code here in the email. It's cool to know that it worked fine in your computer, i guess i did it right the first time. Somehow it doesn't work, i will keep looking at it. A questio: Should the 'split' version of the same code be faster? Original Message Follows From: Kipp, James [EMAIL PROTECTED] To: 'Marcelo Taube' [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: RE: Problem with regular expressions!!! Date: Tue, 18 Mar 2003 16:47:20 -0500 This is the code. # $file_completename =~ /(.*?)\.(.*)/; if ($2 eq $extension]) { #DO SOMETHING!!! } # did u turn on warnings and use strict ?? did you catch the ] at the end of $extension? i tried this on my machine and it works fine: $fn = test.jpg; if ($fn =~ /(.*?)\.(.*)/ ) { print $2 } # prints jpg -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] _ The new MSN 8: advanced junk mail protection and 2 months FREE* http://join.msn.com/?page=features/junkmail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with regular expressions!!!
Hughes, Andrew wrote: This is a newbie observation, but aren't you not supposed to name one of your own variables with a number as the first value after a $, @, or % as in the case of $2? Could this be part of the problem? Just to make sure this doesn't slip through, in his case $2 refers to the second match in the previous regular expression so he was using it correctly. This is a variable automagically set by Perl during the regular expression operation he had based on the grouping (). So for example: if ($string =~ /^(\d*)65(\d*)/) { within this block $1 will be set to anything that matched before the '65' and $2 will be set to anything matched after the '65'. And so on... } Because of these types of special cases you shouldn't use variable names such as $1, $2, $3, $a, $b (see 'sort'), etc. You will also find in the case of the numbers, that the variable is a global so 'my'ing will fail, and on top of that you will most likely get a bareword found where operator expected syntax error (though there may be ways around that). So your suggestion not to use that type of variable name is correct, for your own variables, but there are times when you will want to use Perl's builtin variables, which was the case here... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Problem with regular expressions!!!
On Tuesday, Mar 18, 2003, at 15:46 US/Pacific, Peter Kappus wrote: I also had no problem... myfile.jpeg =~ /(.*?)\.(.*)/; print $2; gives me jpeg Can we see the rest of your code? I think the problem may be in the value of $file_completename... [..] I think the OP may have a problem with what is really in that $file_completename that was not planned for. To test this I put together: sub split_me { my ($file_completename, $extension) = @_; $file_completename =~ /(.*?)\.([^\.]*)$/; if ($2 $2 eq $extension ) { print we match $extension for $file_completename\n; } else { print FAIL to match $extension for $file_completename; print - . $2 if ( $2 ) ; print \n; } } # end of split_me split_me(bob.txt , txt); split_me(bob.html , txt); split_me(bob.txt.html , txt); split_me(bob.txt.html.txt , txt); split_me(/some/path.here/bob.txt , txt); the first two cases work as expected and the next three will help show a part of the problem we match txt for bob.txt FAIL to match txt for bob.html - html FAIL to match txt for bob.txt.html - txt.html FAIL to match txt for bob.txt.html.txt - txt.html.txt FAIL to match txt for /some/path.here/bob.txt - here/bob.txt if one changes the RegEx to say $file_completename =~ /(.*?)\.([^\.]*)$/; then the output looks like: we match txt for bob.txt FAIL to match txt for bob.html - html FAIL to match txt for bob.txt.html - html we match txt for bob.txt.html.txt we match txt for /some/path.here/bob.txt the regex looks at ONLY the last stuff after a '.' note also that if we had split_me(bob , txt); that this would fail, and without the test to see that $2 existed we would get a warning about attempting to compare it to $extension. HTH. ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: persistent connection
Uma Ramdoss [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] hai, i am writing a simple browser using LWP::UserAgent i dont know how to make persistent connection. i think LWP sends connection-close header by default. i used keepalive header but no use. can anyone help with code? Thank You. -uma HTTP is a stateless protocol. This means you cant simply turn state on. The best you can do is emulate it. There is a recent article about a module called WWW::Mechanize on perl.com: http://www.perl.com/pub/a/2003/01/22/mechanize.html I haven't used it yet, but it looks pretty slick. It enables a program to surf the web while low-level operations like manipulating the LWP object are abstracted away. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: searching a string
If the text is contained in $text, then: if ($text =~ /the\s+lucky\s+coin/ism) { print ok; } Teddy, Teddy's Center: http://teddy.fcc.ro/ Email: [EMAIL PROTECTED] - Original Message - From: mark sony [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, March 18, 2003 1:13 PM Subject: searching a string Hi i am searching for a string of consecutive words say the lucky coin These may be in one line or different line separated by blank lines such as 1the lucky coin 2thelucky coin 3the lucky coin Whats the way in perl ? mark ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomosw n -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: shared cookies
Wiggins D'Anconia [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Hytham Shehab wrote: hi guys, i have multiple domain names - etc multiple sites - that i would like to share cookies inbetween, how can i - literally - do that, and is it enough to use HTTP::Cookies !? Mostly you can't, which is why I suppose the list has been so quiet. This is a security issue, you don't want other domains reading cookies that were specifically for your domain do you? If you are talking sub snip / Microsoft has this thing called hta (hypertext applications, or something like that) where you digitally sign your .asp file and give it a .hta extension. Client side code can then work out of the sandbox (i.e. read cookies from other domains). MS specific. Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Good Perl cgi book?
I'm currently using the resources at this website. I think it should be useful to you. http://learn.perl.org/library/beginning_perl/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
searching for a string
Hi I was trying the following code : open ( fh , test1.txt); while (fh) { $string = the lucky coin; if ($string =~ m/(\b)the(\s)(\b)lucky(\s)(\b)coin(\b)$/) { print Yup,exists.\n; } else { print nope \n; } } But the results are not as expected. I was thinking of the following : search for the then ignore blank spaces,tabs,newlines and look for lucky .If found then also print the next word which will be lucky .Is there no pipes in perl ? mark ___ Odomos - the only mosquito protection outside 4 walls - Click here to know more! http://r.rediff.com/r?http://clients.rediff.com/odomos/Odomos.htmodomoswn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]