Re: Why is the answer right...

2010-04-18 Thread John W. Krahn
Harry Putnam wrote: I may have turned the question around from the usual approach, but I'm having trouble seeing why my script gives the right answer. The script reads data that contains dates in the format YYMMDD N, the N isn't part of the date but is also a digit. What the script tries to do

Why is the answer right...

2010-04-18 Thread Harry Putnam
I may have turned the question around from the usual approach, but I'm having trouble seeing why my script gives the right answer. The script reads data that contains dates in the format YYMMDD N, the N isn't part of the date but is also a digit. What the script tries to do is read the dates, run

Can't locate object method "TIEHASH" via package " Apache::Session::MySQL

2010-04-18 Thread Mimi Cafe
I get following error when trying to open a session using Apache::Session::MySQL. Here is what I have 38 tie %session, " Apache::Session::MySQL", undef,{ 39 Handle => $dbh, 40 LockHandle => $dbh 41 }; Could not create new session: Can't loca

Re: Regex to validate user input (match any word or phrase)

2010-04-18 Thread Owen
On Sun, 18 Apr 2010 17:09:59 +0100 Mimi Cafe wrote: > I am trying to test user input to ensure it contains special > character or symbols that could cause problems to my program or > database. > > The user will enter a keyword in the web form to search in my > database, and I want to ensure I do

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
>$str =~ m{ \A ( .{0,15} .*? ) \s }msx; Yeah, this would do. I talked about the scenario where you didn't put "{0,15}", but just "{15}". In that case, it wouldn't work if the value given in the match string (15 as per above eg.) is greater than the character count of the particular string

Re: Extract substring from offset to space or full stop

2010-04-18 Thread John W. Krahn
Mimi Cafe wrote: From: John W. Krahn [mailto:jwkr...@shaw.ca] Mimi Cafe wrote: I used MySQL substr function to extra 100 characters from the result of a query, but understandably, I don't get what I want. Now I looked at Perl's substr function and it doesn't look like it can help me achieve

Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
It is a bit tricky. Just tried it and Perl warned: The string is: The black cat is. Can't do {n,m} with n > m in regex; marked by <-- HERE in m/ \A ( .{19,18} <-- HERE ?\s+ \b ) / at substr.pl line 10. My strings are not fixed length, but I do they are normally longer that the offset I used, so

Regex to validate user input (match any word or phrase)

2010-04-18 Thread Mimi Cafe
I am trying to test user input to ensure it contains special character or symbols that could cause problems to my program or database. The user will enter a keyword in the web form to search in my database, and I want to ensure I don't play around with special character otherwise any word or phras

Re: Extract substring from offset to space or full stop

2010-04-18 Thread John W. Krahn
Mimi Cafe wrote: I used MySQL substr function to extra 100 characters from the result of a query, but understandably, I don't get what I want. Now I looked at Perl's substr function and it doesn't look like it can help me achieve what I need to. Let's say I have: $s = "The black cat climbed th

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Shawn H Corey
Akhthar Parvez K wrote: Hi Shawn, $str =~ m{ \A ( .{15} .*? ) \s }msx; I don't think this would work if the value given in the match string (15 as per above eg.) is greater than the character count of the particular string. Right? No, it will fail if $str is less than 15 characters. Try:

Re: How to properly fold a subject header in email

2010-04-18 Thread John W. Krahn
Harry Putnam wrote: "John W. Krahn" writes: [...] From: http://www.rfc-editor.org/rfc/rfc5322.txt 2.2. Header Fields [...] (and even within some of the lexical tokens), folding SHOULD be limited to placing the CRLF at higher-level syntactic breaks. For CRLF is mentioned

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
Hi, > It works fine and I like it. My regex is not that good, but I can see what > is doing. I modified it a bit (to capture up till a full stop sign). Kewl. Good to hear that! Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be

RE: Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
Hi, It works fine and I like it. My regex is not that good, but I can see what is doing. I modified it a bit (to capture up till a full stop sign). #!/usr/bin/perl # use strict; use warnings; # my $str = "The black cat is trying to climbed the green tree. This time it failed."; print "string: $s

Re: How to properly fold a subject header in email

2010-04-18 Thread Harry Putnam
"John W. Krahn" writes: [...] > From: > > http://www.rfc-editor.org/rfc/rfc5322.txt > > > 2.2. Header Fields [...] > (and even within some of the lexical tokens), folding SHOULD be > limited to placing the CRLF at higher-level syntactic breaks. For CRLF is mentioned in several

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
Hi Shawn, > $str =~ m{ \A ( .{15} .*? ) \s }msx; I don't think this would work if the value given in the match string (15 as per above eg.) is greater than the character count of the particular string. Right? Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple ope

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Shawn H Corey
Mimi Cafe wrote: $s = "The black cat climbed the green tree"; $substring = substr( $s, 1, 15); # this will return "The black cat c". How can I have this return the whole word climbed rather than the c (i.e. I need to get "The black cat climbed")? I need to get the remaining characters from

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
Hi Mimi, > How can I have this return the whole word climbed rather than the c (i.e. I > need to get "The black cat climbed")? I need to get the remaining characters > from the length till the next white space or end of a phrase. > Any other way to overcome this limitation? How can I use regex he

Extract substring from offset to space or full stop

2010-04-18 Thread Mimi Cafe
I used MySQL substr function to extra 100 characters from the result of a query, but understandably, I don't get what I want. Now I looked at Perl's substr function and it doesn't look like it can help me achieve what I need to. Let's say I have: $s = "The black cat climbed the green tr