Regex not working as expected

2006-09-04 Thread Chris Schults
I have a regular expression that is suppose to truncate long URLs at 50
characters and add "...", but can't figure out why it is not working with a
particular URL.

Here is the regex:

$url =~s#>((?:http\|ftp\|file)://.{50}).+#>$1...#g;

And here is the problem URL:

http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_
main.html?name=Toles&date=09012006">http://www.washingtonpost.com/wp-srv
/opinions/cartoonsandvideos/toles_main.html?name=Toles&date=09012006

Here is what the regex should return:

http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_
main.html?name=Toles&date=09012006">http://www.washingtonpost.com/wp-srv
/opinions/cartoonsand...

Interestingly, the regex works fine on this modified version of the URL:

http://www.washingtonpost.com/wp-srv/opinions/cartoonsandvideos/toles_main.h
tml?name=Toles

I think the digits might have something to do with it, but not sure.

Any thoughts?

Thanks!

Chris

--

Chris Schults
Web Production Manager
Grist Magazine
710 Second Avenue, Suite 860
Seattle, WA  98104
Phone: 206-876-2020, ext. 204
Fax: 253-423-6487
<http://www.grist.org>

To sign up for Grist by email, the world's top environmental news served up
with a sense of humor, click here <http://www.grist.org/signup/> or send a
blank email message to <[EMAIL PROTECTED]> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Regular expressions and closing HTML tags

2005-07-13 Thread Chris Schults
I have a text string, with some HTML code, that I truncate (using substr).
In some instances, I truncate off some HTML close tags.

In the case of anchor tags, I do this (please tell me if there is a more
elegant ay to do this!):

if ($text =~ /\/) {$text .= '';}

But I realized that this doesn't work if there is more than one link, like
so:

Here is some text that got truncated

Any suggestions?

Chris

------

Chris Schults
Web Production Coordinator
Grist Magazine
811 First Avenue, Suite 466
Seattle, WA  98104
Phone: 206-876-2020, ext. 204
Fax: 253-423-6487
<http://www.grist.org>

To sign up for Grist by email, the world's top environmental news served up
with a sense of humor, click here <http://www.grist.org/signup/> or send a
blank email message to <[EMAIL PROTECTED]> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Pattern matching to identify comma separated text

2005-03-08 Thread Chris Schults
I'm sending this on behalf of our intern Elmer. Thanks in advance for any
assistance. Chris

Hi there!

If anyone out there is good with Perl's pattern matching, maybe you can help
me out.  I am trying to take a string and derive information from it that is
separated by commas so I can then analyze the individual values.

So if I have a string like: 'Associated Press, John. D. Reporter, 01 Apr
2005'

I want to be able to scan it, and extract 'Associated Press' 'John. D.
Reporter' and '01 Apr 2005' as distinct values--maybe store them as
variables so I can manipulate them.

It should also be that the number of data items not be relevant.  In case
the string is like 'Joe Freelancer, 01 May 2005'  or 'Reuters, 01 Jun 2005'.
Or if it has no commas and is just '01 Jul 2005'.

Kind regards,

Elmer Zahraie



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Problem with script requiring valid referrer

2005-02-08 Thread Chris Schults
> This is really a question for the CGI list, but whatever.

Sorry, didn't realize there was one. Thanks for the heads up!

> Have you looked in the web server logs? Are you recording referer data? 
If not, you should be, it's useful in cases like this. If you're 
recording it, you should be able to verify or refute the claims. 

Yes, our web logs are recording referrer data, but I wouldn't know what to
look for. I'll ask the CGI list.

If anyone on this list wants to offer suggestions, they would certainly be
welcomed!

Chris

-Original Message-
From: Chris Devers [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 08, 2005 11:25 AM
To: Chris Schults
Cc: Perl Beginners List
Subject: Re: Problem with script requiring valid referrer

On Tue, 8 Feb 2005, Chris Schults wrote:

> In both cases, our visitors swear that they are linking to these 
> scripts from valid Grist pages. Any ideas why some people are getting 
> the error messages? I've asked for browser and O/S info, but many are 
> using the same setup we are using, which works just fine.
 
This is really a question for the CGI list, but whatever.

Have you looked in the web server logs? Are you recording referer data? 
If not, you should be, it's useful in cases like this. If you're 
recording it, you should be able to verify or refute the claims. 

With that information at hand, you can figure out what step comes next.
 

-- 
Chris Devers



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Problem with script requiring valid referrer

2005-02-08 Thread Chris Schults
Hey all. On our website we have several forms (send a letter, ask a
question, etc) that some of our visitors seem to have problems with. These
forms require the referring page to be from a Grist Magazine domain.

Here is some of the code:


my $goback  = param("goback") || "";
my $url = $goback || referer() || "";

if ($url !~ m{grist}) {
&error("Must be called from a page on Grist Magazine.");
}


We have another script that outputs a printer friendly version of a HTML
page. Some users are experiecing similar problems.


if (!referer) {
print h2 "Sorry, this script cannot be called directly.";
print p "Please try again.";
exit 0;
}


In both cases, our visitors swear that they are linking to these scripts
from valid Grist pages. Any ideas why some people are getting the error
messages? I've asked for browser and O/S info, but many are using the same
setup we are using, which works just fine.

Many thanks in advance!

Chris




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Checking last character of string for punctuation

2005-02-02 Thread Chris Schults
Thanks to the people who promptly replied.

I have two quick follow-up questions:

1) What does "s/\s*$/\./" do? (see email below)
2) What are the differences between:

$string .= '.' unless $string =~ /[$!.]+$/; (suggested in another email)

and

$title =~ s/\s*$/\./ unless $title =~ /[!?.]\s*$/;


Chris

-Original Message-
From: Ing. Branislav Gerzo [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 02, 2005 2:54 PM
To: beginners@perl.org
Subject: Re: Checking last character of string for punctuation

Chris Schults [CS], on Wednesday, February 2, 2005 at 14:39 (-0800)
wrote the following:

CS> However, some of my titles and subtitles end with punctuation ("?", "!",
CS> ".", "..."). Thus, I end up with: Am I a title that ends with
punctuation?.
CS> Do-oh!.

my $title = 'This is just test  ';
$title =~ s/\s*$/\./ unless $title =~ /[!?.]\s*$/;
print $title;

enjoy:)

-- 

 ...m8s, cu l8r, Brano.

[Confucius Says: Those who quote me are fools.]



-- 
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>




Checking last character of string for punctuation

2005-02-02 Thread Chris Schults
Howdy all. I'm a newbie with a newbie question. I assume that I'm in the
right place.

I need to update some code a developer programmed for my organization.

The purpose of the code is really basic. It simply prints: $title.
$subtitle.

However, some of my titles and subtitles end with punctuation ("?", "!",
".", "..."). Thus, I end up with: Am I a title that ends with punctuation?.
Do-oh!.

So, I need to revise the code so that it first checks each string to see if
it ends with a punctuation character. If it does, don't add the period. If
not, do add the period. Note: the string should be kept as is.

I believe the key is a regular expression of some sort, but I can't seem to
figure it out.

Any help would be appreciated!

Thanks in advance,

Chris



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]