Greg and Bill: Thanks so much! Bill- I was able to get
the script to work in swish-e by re-writing it. As
I've said before, I'm no perl expert, and once I was
able to understand the concept of $string=shift;
everything made sense! I was able to look at the
examples as well as the suggestions you've given
recently to make it work.
Not only that, but Greg, your clean-up suggestion
actually made my code bug-free and work perfectly!
Tremendous thanks to both of you! I'll spend tomorrow
on making a cgi script with SWISH::API and slap this
puppy on a development box! When it goes into
production, I'll look at getting a link for everyone
to check out!
Again, thanks a ton!
-Alan
--- Greg Fenton <greg_fenton@yahoo.com> wrote:
>
> --- Alan Ivey <ai4891@yahoo.com> wrote:
> >
> > $Author="";
> > while($Author eq "") {
> > $line = <INPUT>;
> > if($line=~m/[A-Z,a-z]/) {
> > $Author=$line;
> > chomp $Author;
> > last;
> > }
> > }
> >
>
> Hope you don't mind a bit of feedback on the Perl
> code...
>
> The above will either cause an error or an infinite
> loop if the Author
> is not found in the input.
>
> I suggest rewriting it to:
>
> $Author="";
> while( $line = <INPUT> ) {
> if( $line =~ m/[A-Z,a-z]/ ) {
> $Author=$line;
> chomp $Author;
> last;
> }
> }
>
>
> Also, are you sure that the regexp is right? You
> are saying that $line
> is a match if it "contains any (english) letter or a
> comma". So if the
> line is just "A" it is a match. If the line is just
> "," it is a match.
>
> Might you mean: m/[A-Za-z]+,[A-Za-z]+/ ??
> ( or even m/[:alpha:]+,[:alpha:]+/ )
>
> Same while-loop and regexp questions for the $Title.
>
> Also, the last while loop (@tempBody) could be
> replaced with either a
> foreach:
>
> @tempBody=<INPUT>;
> $Body = "";
> foreach $i (@tempBody) {
> $Body .= $i;
> }
>
> or better yet remove the loop and use a join:
>
> @tempBody=<INPUT>;
> $Body = join("", @tempBody);
>
> or even better, don't use the @tempBody array at
> all:
>
> $Body = "";
> while(<INPUT>) {
> $Body .= $_;
> }
>
>
> Hope this helps,
> greg_fenton.
>
> =====
> Greg Fenton
> greg_fenton@yahoo.com
>
>
>
>
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!
> http://promotions.yahoo.com/new_mail
>
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
Received on Tue Aug 10 12:50:53 2004