[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Can't get sendmail to put subject right...



On Thu, Jul 27, 2000 at 04:00:41AM -0700, EaTrom wrote:
> My wife is an eBay seller, and I have been creating some perl scripts to
> assist her. I do have a problem that is email associated that maybe
> someone could help me over. Snippet included:
> 
> # auction_desc = "This item for sale       Item #12345"
> 
>     $auction = $test_data{'auction_desc'};
>     chomp($auction);
>     $auction_full = $auction;     # used for subject
>  $auction =~ /(.*)(Item #)(\d+)/;   # segment the description and item
> number

Because this regular expression uses (.*) to match the description,
$auction_desc below can't contain any newlines, even though you're using
chomp() below.  I think you should be using the /s option here.


>  $auction_desc = $1;
>  $auction_ID = $3;
>  $auction_desc =~ /(.*)(\r|\n)/;
>  $auction_desc = $1;
>  chomp($auction_desc);

You shouldn't use the values of $1 et al. without making sure the match
succeeded.

if ($auction =~ /(.*)Item #(\d+)/s) {
   ($auction_desc, $auction_ID) = ($1, $2);
   $auction_desc =~ s/[\r\n]+$//;
}


> # the problem is that $auction_full ends up without the id number.

How can $auction_full 'end up without the id number'?  You haven't made any
changes to $auction_full after assigning to it.


> $auction_desc & $auction_ID work as expected.
> # I tried to append the id, but that also fails.
>  $auction_full .= $auction_ID;
> 
>  print qq{
>   <a
> href="mailto:$bidder_email?subject=$auction_full&message=Hello">eMail
> Winner</a>
>  };
> 
> # when the link is clicked, a message window opens (this is what I want)
> but the subject is truncated at "Item "
> # is something "thinking" the #12345 indicates a comment, and so strips
> it?

#12345 does not indicate a comment: it refers to an anchor name, as in:

http://www.example.com/catalog.html#item27

which will bring up catalog.html with the page scrolled to the location of
item27.


You need to URL encode the string before you use it as a URL.  Recent
versions of the CGI module have a method for this; other HTML generating
modules probably do as well.


> # second - how does one fill in the message body? add \n\ntext to the
> subject?

?subject= isn't even standard itself.  I don't know if there's a way to
fill in the body.  But you could try ?body=.


Ronald


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org