[23408] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5626 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 03:05:48 2003

Date: Tue, 7 Oct 2003 00:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 7 Oct 2003     Volume: 10 Number: 5626

Today's topics:
        Data::Dumper confusion <swen@news.com>
    Re: Data::Dumper confusion <invalid-email@rochester.rr.com>
    Re: Getting MAC & NetBIOS Name with Perl? (James Willmore)
    Re: LWP:UserAgent not working ??? (Gaurav)
    Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Randal L. Schwartz)
    Re: Opinions on "new SomeObject" vs. "SomeObject->new() (Tad McClellan)
    Re: parse boolean logic <invalid-email@rochester.rr.com>
    Re: Pattern Match With $ (2) (Cheok Yan Cheng)
    Re: Pattern Match With $ (2) <invalid-email@rochester.rr.com>
    Re: pattern matching <invalid-email@rochester.rr.com>
        Perl module to clear pop mailbox? <dillon@SpamMinuSaccessdenied.darktech.org>
    Re: Perl module to clear pop mailbox? <kalinaubears@iinet.net.au>
    Re: Perl module to clear pop mailbox? (Tad McClellan)
    Re: Perl::Inline compiling problems <kalinaubears@iinet.net.au>
    Re: require and do - absolute vs relative - let me try  (James Willmore)
    Re: Sendmail BCC with multiple recipients (James Willmore)
    Re: Strange behaviour with '\r' character (Tad McClellan)
        Teach me how to fish, regexp <henryn@zzzspacebbs.com>
    Re: Teach me how to fish, regexp <mgjv@tradingpost.com.au>
        Very Interesting max_size in UserAgent <test@test.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 06 Oct 2003 18:38:56 -0700
From: swen <swen@news.com>
Subject: Data::Dumper confusion
Message-Id: <3F821930.9070908@news.com>

the code:

   use Data::Dumper;
   .
   .
   .
   $Data::Dumper::Useqq = 1; # i have also tried with a setting of 0
   my $search = eval(Dumper($params));
   print "addSearch(): Dumper(\$params) = ".Dumper($params);
   print "addSearch(): Dumper(\$search) = ".Dumper($search);
   print "addSearch(): Dumper(eval(Dumper(\$params))) =
   ".Dumper(eval(Dumper($params)));

the output (you can also see what $params contains):

   addSearch(): Dumper($params) = $VAR1 = {
           "returnFields" => [
                               "pr.status",
                               "pr.requestor"
                             ],
           "searchFields" => [
                               {
                                 "and_or" => "and",
                                 "name" => "pr.status"
                               }
                             ]
         };
   addSearch(): Dumper($search) = $VAR1 = undef;
   addSearch(): Dumper(eval(Dumper($params))) = $VAR1 = undef;

Can someone tell me why the eval returns undef? I'm missing something.



------------------------------

Date: Tue, 07 Oct 2003 03:43:49 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Data::Dumper confusion
Message-Id: <3F8235A8.9070202@rochester.rr.com>

swen wrote:

> the code:
> 
>   use Data::Dumper;
>   .
>   .
>   .
>   $Data::Dumper::Useqq = 1; # i have also tried with a setting of 0
>   my $search = eval(Dumper($params));
>   print "addSearch(): Dumper(\$params) = ".Dumper($params);
>   print "addSearch(): Dumper(\$search) = ".Dumper($search);
>   print "addSearch(): Dumper(eval(Dumper(\$params))) =
>   ".Dumper(eval(Dumper($params)));
> 
> the output (you can also see what $params contains):
> 
>   addSearch(): Dumper($params) = $VAR1 = {
>           "returnFields" => [
>                               "pr.status",
>                               "pr.requestor"
>                             ],
>           "searchFields" => [
>                               {
>                                 "and_or" => "and",
>                                 "name" => "pr.status"
>                               }
>                             ]
>         };
>   addSearch(): Dumper($search) = $VAR1 = undef;
>   addSearch(): Dumper(eval(Dumper($params))) = $VAR1 = undef;
> 
> Can someone tell me why the eval returns undef? I'm missing something.
> 

That's not what I get with your code verbatim (Windoze 98SE, AS build 806):

D:\junk>perl junk391.pl
addSearch(): Dumper($params) = $VAR1 = {
           "searchFields" => [
                               {
                                 "name" => "pr.status",
                                 "and_or" => "and"
                               }
                             ],
           "returnFields" => [
                               "pr.status",
                               "pr.requestor"
                             ]
         };
addSearch(): Dumper($search) = $VAR1 = {
           "searchFields" => [
                               {
                                 "name" => "pr.status",
                                 "and_or" => "and"
                               }
                             ],
           "returnFields" => [
                               "pr.status",
                               "pr.requestor"
                             ]
         };
addSearch(): Dumper(eval(Dumper($params))) =
   $VAR1 = {
           "searchFields" => [
                               {
                                 "name" => "pr.status",
                                 "and_or" => "and"
                               }
                             ],
           "returnFields" => [
                               "pr.status",
                               "pr.requestor"
                             ]
         };

D:\junk>

Code I used:

$params = {
           "returnFields" => [
                               "pr.status",
                               "pr.requestor"
                             ],
           "searchFields" => [
                               {
                                 "and_or" => "and",
                                 "name" => "pr.status"
                               }
                             ]
         };
use Data::Dumper;
   $Data::Dumper::Useqq = 1; # i have also tried with a setting of 0
   my $search = eval(Dumper($params));
   print "addSearch(): Dumper(\$params) = ".Dumper($params);
   print "addSearch(): Dumper(\$search) = ".Dumper($search);
   print "addSearch(): Dumper(eval(Dumper(\$params))) =
   ".Dumper(eval(Dumper($params)));

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: 6 Oct 2003 18:45:31 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: Getting MAC & NetBIOS Name with Perl?
Message-Id: <e0160815.0310061745.7154029@posting.google.com>

"Snuffy2" <snuffy2@yahoo.com> wrote in message news:<oBkgb.36102$qj6.2231314@news1.news.adelphia.net>...
> I'm looking to try to get a users MAC and/or NetBIOS name when they visit my
> website. It somehow can be done, I'm not sure with Perl, but it can be done.
> 
> Does anyone have any idea how?
> 
> As an example check out:
> http://stealthtests.lockdowncorp.com/
> 
> On that site, there are tests that will display NetBIOS & MAC addresses.
> (NOTE: if you are properly firewalled or protected it won't display the
> information accurately, however if unprotected and not behind a NAT or
> router, it works)
> 
> Now how did they do this? & how can I?
> 
> Thanx

Why?  Something to do?  Are you (as the web site you suggest viewing)
selling a product?

Jim


------------------------------

Date: 6 Oct 2003 23:48:38 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: Re: LWP:UserAgent not working ???
Message-Id: <42983cb.0310062248.753a5202@posting.google.com>

Bart Lateur <bart.lateur@pandora.be> wrote in message news:<ajg3ov04mavs1epnqgae35hsh2n44m9br5@4ax.com>...
> Gaurav wrote:
> 
> >where can i find just the module needed for LWP::UserAgent to work. Do
> >i need more modules or just that one particular module ?
> 
> lib-www, that's the suite you need. I think it only relies on standard
> modules.

###################

I have tried running the script on my laptop having win 2000. I have
the latest cygwin installed and it comes with  perl.

I am getting the same error message. 

So everything we have discussed so far also applies to personal
computer with perl bundled in Cygwin ??

thank you .
Gaurav


------------------------------

Date: Tue, 07 Oct 2003 01:03:01 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
To: Tore Aursand <tore@aursand.no>
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <642aea591ecc43a4da321e6220dbeac1@news.teranews.com>

>>>>> "Tore" == Tore Aursand <tore@aursand.no> writes:

Tore> I prefer the latter, but as long as you design your classes to expect them
Tore> to be used both ways, there shouldn't be any difference;

Tore>   sub new {
Tore>       my $proto = shift;
Tore>       my $class = ref( $proto ) || $proto;
Tore>   }

Please, don't cargo-cult ref($proto) in this matter!
See my rant on that at <http://www.perlmonks.org/index.pl?node_id=52089>.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Tue, 7 Oct 2003 00:21:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Opinions on "new SomeObject" vs. "SomeObject->new()"
Message-Id: <slrnbo4j9s.hrf.tadmc@magna.augustmail.com>

Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> patriote@fastmail.fm (Patriote) wrote in 
> news:dced8a08.0310061336.35f80601@posting.google.com:
> 
>> Some programmers use the style 
>> 
>> $objSome = new SomeObject;
>> 
>> instead of
>> 
>> $objSome = SomeObject->new();
>> 
>> What are the penalties for using the former Java-like syntax if any? 
>> I've heard that it can cause problems with inheritance, but I've read
>> no specifics.
> 
> I personally think it makes NO sense to create a new object from an 
> existing one 


That code does not create a new object from an existing one.

"SomeObject" is not an object (bad choice of name), it is a class.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 07 Oct 2003 03:01:42 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: parse boolean logic
Message-Id: <3F822BCD.50905@rochester.rr.com>

Thomas Reat wrote:

> I have a perl script that must take some boolean logic as input.
> Something like:
> 
> ((a || b) & !c) || d || (e && f)

&&----------^

perhaps?


If so, you could evaluate it right in Perl, with something like:

   use strict;
   use warnings;
   #set up variable values
   my %h;
   $h{$_}=int(rand(2)) for('a'..'f');
   #set up string
   my $string='((a || b) && !c) || d || (e && f)';
   my $res=compute($string,\%h); #call sub
   #do stuff with $res
   print "res=$res\n";
   sub compute{ #string,hashref varname=>value,...
     my $string=shift;
     my $href=shift;
     $string=~s/(\w+)/\$\$href{$1}/g;
     my $result=eval($string);
     #prints for debug/demo
     print "$_=$$href{$_}, " for sort keys %h;
     print "result=$result\n";
     $result;
   }


> 
> Is there any module out there that can help me parse this? And
> evaluate it as well?
> 
> Ideally I would pass it the expression and a hash (or callback) to get
> the values of each variable. And it returns the value of the whole
> expression. But if there's nothing that does that, I'm interested in
> anything that helps with this.
> 

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: 6 Oct 2003 18:07:50 -0700
From: yccheok@yahoo.com (Cheok Yan Cheng)
Subject: Re: Pattern Match With $ (2)
Message-Id: <4d2111c5.0310061707.825143f@posting.google.com>

gml4410@ggr.co.uk (Lack Mr G M) wrote in message news:<2003Oct6.112800@ukwit01>...
> In article <4d2111c5.0310060203.3da86a45@posting.google.com>, yccheok@yahoo.com (Cheok Yan Cheng) writes:
> |>
> |> i expect both are match. but i got the result:
> |>...
> |> how can i solve this problem?
>  
> > $ebb = '$ebb';
> > if($ebb =~ /${ebb}/)
> 
>    This replaces ${ebb} with it's value and ends up doing:
> 
> if ($ebb =~ /$ebb/)
> 
>    Now, since variable interpolation has already been done the '$' here
> means end-of-line.  So the match fails.
> 
>    You can "see" what is happenign if you add:
> 
>  use re 'debug';
> 
> to the start of the script.
> 
>    The cure is to use:
> 
>  if ($ebb =~ /\Q${ebb}/)
> 
> if you want all of characaters in ${ebb} to be treated literally.  Of
> course, if the contents may be a regular expression then you have to
> take care when setting it up instead.

what if i want to match a string '$ebb.xyz'
i use

$ebb = '$ebb.xyz';
if($ebb =~ /^\Q${ebb}(\.)xyz/)
{
print "done :)\n";
}
else
{
print "not work :(\n";
}

but the result i get is
not work :(

may i noe how can i solve this problem?

thank you.

regards
yccheok


------------------------------

Date: Tue, 07 Oct 2003 03:28:46 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Pattern Match With $ (2)
Message-Id: <3F823224.8000904@rochester.rr.com>

Cheok Yan Cheng wrote:

> gml4410@ggr.co.uk (Lack Mr G M) wrote in message news:<2003Oct6.112800@ukwit01>...
> 
>>In article <4d2111c5.0310060203.3da86a45@posting.google.com>, yccheok@yahoo.com (Cheok Yan Cheng) writes:
 ...
> what if i want to match a string '$ebb.xyz'
> i use
> 
> $ebb = '$ebb.xyz';
> if($ebb =~ /^\Q${ebb}(\.)xyz/)
> {
> print "done :)\n";
> }
> else
> {
> print "not work :(\n";
> }
> 
> but the result i get is
> not work :(


It works, just not like you seem to think it should.  The \Q 
construction quotes all the following metacharacters until a \E (which 
isn't present, so that means to the end of the regexp).  The string you 
are trying to match is:

    '$ebb.xyz'

The pattern you are trying to match it to is (after interpolation and 
the application of \Q quoting):

    /^\$ebb\.xyz\(\\\.\)xyz/

There is no match because the string being matched doesn't contain a ( 
character as the character with offset 8 from the start of the string as 
the regexp requires.


> 
> may i noe how can i solve this problem?


What problem?  Your lack of understanding?  Read and study the docs 
thoroughly, study a book like "Mastering Regular Expressions" 
thoroughly, and develop an understanding of regular expressions.  Then 
you'll be able to solve it in your sleep.  Until then, don't just guess 
at it ... read the docs.  And try:

   use re 'debug';

as someone else suggested.  Take learning regexp's one step at a time -- 
you are in semi-difficult territory, and you don't yet understand the 
basics.


 ...


> yccheok
> 

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Tue, 07 Oct 2003 04:07:42 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: pattern matching
Message-Id: <3F823B3F.6070602@rochester.rr.com>

Lex wrote:

> "Bob Walton" <invalid-email@rochester.rr.com> wrote in message
> news:3F80C08B.2070501@rochester.rr.com...
> 
> 
>>Then you'll have to figure out how to "make a link".
>>
> 
> Bob your code is great.
> 
> However, I still have a question.
> 
> My code now looks like this:
> 
> <code>
> open (DB, "<$db_file_name_abc") or &cgierr("error in search. unable to open
> database: $db_file_name_abc.\nReason: $!");
>  if ($db_use_flock) { flock(DB, 1); }
> 
> my %xref;
> my %meaning;
> while ( <DB> ) {
>      chomp;
>      my($id, $word, $plural, $synonym,$cat,$text) = split /\|/;
>      @xref{($word, $plural, $synonym, $text)} = ($id)x4;

----------------------------------------^^^^^
Are you sure you want to put a whole phase in as a key in %xref?  The 
keys to %xref are supposed to be words according to the conventions used 
so far.


>      $meaning{$id}=$meaning;

---------------------^^^^^^^^
Did you use strict; and use warnings; ?  They would have pointed out 
that this variable is undef at this point because you changed it from 
$meaning to $text two lines above and didn't change it here.  If it were 
still stored in %meaning, then the text could be gotten back by ID just 
by saying $meaning{$id}.


> }
> 
> foreach my $id(keys %meaning){
>      foreach my $word ( $rec{'Text'} =~ /\S+/g ) {
> my $newword = "<a
> href=\"$db_dir_url/db.cgi?db=abc&uid=$db_uid&ID=$xref{$word}&mh=1&ww=1&view_
> records=1\" class=\"abclink\" ONMOUSEOVER=\"popup('...','#C6CBDE')\";
> ONMOUSEOUT=\"kill()\">$word</a>";
> $rec{'Text'} =~ s|\b$word\b|$newword|gs if exists $xref{$word};
>  }
> }
> 
> close DB;
> </code>
> 
> The links works now as well while using another database (where $rec{'Text'}
> is in).
> The only thing I don't know how to do (and I've tried lots...) is how, where
> you see " popup('...', ", the three dots, how to get there the original
> $text field that goes with this link. So, where $xref{$word} is now the ID
> of the record that has to be shown, I'd like the ... to be the original text
> field...


If you hadn't made the mistake of changing $meaning to $text in all but 
one of the places it is used, you could have used $meaning{$id} to get 
that text -- just replace the ... with $meaning{$id}.  You'd better make 
sure the text doesn't contain any ' characters, and perhaps " characters 
either.  Maybe < and > also?  Others?  Probably best to run it through a 
Javascript quoter, and then an HTML quoter?


 ...
> Lex

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



------------------------------

Date: Tue, 07 Oct 2003 11:17:02 +0800
From: AcCeSsDeNiEd <dillon@SpamMinuSaccessdenied.darktech.org>
Subject: Perl module to clear pop mailbox?
Message-Id: <6db4ovod7kvndrr1lvund83su3qbm2s69p@4ax.com>

Hi folks,

I'm attempting to automatically log into a pop account and clear/delete all the emails in it.
I know I can do this with some telnet routines, but if there is already a module out there, it would
safe me time.

I need this because the pop provider does not use 'standard' forwarding features.
Once an email has been forwarded, there just leave it there and my users have to regularly go in to
clear up their mailboxes.

Thanks

To e-mail, remove the obvious


------------------------------

Date: Tue, 07 Oct 2003 13:53:27 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Perl module to clear pop mailbox?
Message-Id: <3f82396f$0$23605$5a62ac22@freenews.iinet.net.au>

AcCeSsDeNiEd wrote:
> Hi folks,
> 
> I'm attempting to automatically log into a pop account and clear/delete all the emails in it.
> I know I can do this with some telnet routines, but if there is already a module out there, it would
> safe me time.
> 
> I need this because the pop provider does not use 'standard' forwarding features.
> Once an email has been forwarded, there just leave it there and my users have to regularly go in to
> clear up their mailboxes.
> 
> Thanks
> 
> To e-mail, remove the obvious

I've been using such a module to parse the headers of the mail on my 
ISP's server and delete (from the server) the Swen virus emails (so I 
don't have to download them to clear the pile).

To delete everything (untested):

use strict;
use warnings;
use Mail::POP3Client;

my $pop = new Mail::POP3Client
( USER=> "username",
PASSWORD=> "password",
HOST=> "something_like_mail.host.com",
#AUTH_MODE=> 'PASS', # perhaps not needed - see docs
TIMEOUT => 60,
DEBUG=> 0, # set to 1 to diagnose trouble
  ) or warn "cannot open: $!";

my $c = $pop->Count();
for (my $i = 1; $i <= $c; $i++) { $pop->Delete($i)}
$pop->Close() or warn "Can't close: $!";
__END__

One (obvious) thing to keep in mind is that if some mail turns up after 
the user has performed a download, but before this script starts, then 
that user will never see that mail, and no-one will know about it.

I think my preferred approach would be to apply standard forwarding 
procedure :-)

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



------------------------------

Date: Tue, 7 Oct 2003 00:53:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl module to clear pop mailbox?
Message-Id: <slrnbo4l7i.hrf.tadmc@magna.augustmail.com>

AcCeSsDeNiEd <dillon@SpamMinuSaccessdenied.darktech.org> wrote:


> I'm attempting to automatically log into a pop account and 
> clear/delete all the emails in it.


use Mail::POP3Client;

   http://search.cpan.org/~sdowd/Mail-POP3Client-2.14/


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 07 Oct 2003 11:32:14 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Perl::Inline compiling problems
Message-Id: <3f821856$0$23589$5a62ac22@freenews.iinet.net.au>

Sisyphus wrote:

> Caveat:
> 1) The source file ('s1.c') needs to be in a separate directory from 
> 'try.pl'. (Or maybe it just needs to be in a directory other than the 
> cwd - haven't tested.)
> 

'perldoc inline-faq' tells us that the C source files must be in a 
subdirectory of the perl script.

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



------------------------------

Date: 6 Oct 2003 18:54:24 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: require and do - absolute vs relative - let me try again
Message-Id: <e0160815.0310061754.2929782c@posting.google.com>

Derf <wunkalunka@elvis.com> wrote in message news:<Xns940CB5135666Cwunkalunkaelviscom@24.28.95.190>...
> I have a file at /path/from/root/cgi-bin/file.pl
> 
> and I want to require /path/from/root/cgi-bin/dir/requirefile.pl
> 
> the web root would be /cgi-bin/file.pl and the user root would be 
> /path/from/root/cgi-bin/file.pl
> 
> when i use an absolute path in file.pl:
> 
> do "/path/from/root/cgi-bin/dir/requirefile.pl";
> 
> or
> 
> require "/path/from/root/cgi-bin/dir/requirefile.pl";
> 
> i get the error 
> 
> ***corrected error from previous message:
> 
> Can't do: No such file or directory at /path/from/root/cgi-
> bin/file.pl line ##.
> 
> but if I move file.pl to /path/from/root/cgi-bin/dir/file.pl
> 
> and then do a relative call:
> 
> require "requirefile.pl";
> 
> or 
> 
> do "requirefile.pl";

Huh?  Try again using something like "/a/b/c/file.pl" instead of what
you used to describe the issue.  Maybe after doing that, you may find
your error and not need to post ... because, it looks as though you're
confussed about where the files are.  I know I am :-)

Seriously, you _should_ be able to execute another script from another
location using an absolute path.  You may want to check your
permissions and, as always, try the script from the command line to
see what happens.

HTH

Jim


------------------------------

Date: 6 Oct 2003 18:31:09 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: Sendmail BCC with multiple recipients
Message-Id: <e0160815.0310061731.7495a9e5@posting.google.com>

ecoffin@conbrio.cs.tufts.edu (Erica Coffin) wrote in message news:<bnjgb.200$X2.17258@news.tufts.edu>...
> Hello,
> 
> I'm completely stuck on this problem I've been having calling sendmail from a perl script.
> I can't seem to have multiple bcc recipients. If I have one bcc recipient, the message is received by the one bcc recipient and everything is happy.  If I have more than one bcc recipient, the message is sent to the To recipient only, and none of the bcc recipients receive an email.
> 
> I am posting here instead of a sendmail NG, because when I copy and paste the output of the print line  (from below) everything works great. All the bcc recipients get a copy of the message.
> 
> Here is the salient portion of my script:
> 
> $sendmail = '/usr/bin/sendmail';
> $from     = 'from@from.com';
> $email    = $debug ? $debug_email : $hash{'eMail'};
> $subject  = 'Your loan application';
> $text     = 'blah blah blah';
> $bcc      = 'bcc_recip1@company.com, bcc_recip2@company.com, bcc_recip3@company.com';
> 
> open MAIL, "|$sendmail $email"
>  or die "Unable to start sendmail:$!\n";
>   print MAIL "From: $from\nBcc: $bcc\nSubject:$subject\n$text";
> close MAIL;
> 
> Thanks for any help,
> erica

First - please read the posting guidelines.  Set your client to
truncate the lines at a "sane" position - like 72 characters.  Those
of us who sometimes use Goggle to read/post to groups have a tough
time reading posts that run off the side of the page :-)

Second - try out one of the many email/SMTP modules (such as
Net::SMTP, Mail::Mailer, MIME::Lite, etc) to do what you're doing. 
That's just a suggestion and something personal with me - I can't
stand sendmail.  Not to mention the fact that, one day, your company
_may_ decide that *NIX isn't cutting it and go with another platform -
one that does _not_ use sendmail.  Then you're going to be S.O.L. with
your script that only uses sendmail to send email :-)

Jim


------------------------------

Date: Tue, 7 Oct 2003 00:49:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Strange behaviour with '\r' character
Message-Id: <slrnbo4kuv.hrf.tadmc@magna.augustmail.com>

i5513 <i5513@hotmail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnbo2sra.gec.tadmc@magna.augustmail.com>...
>> i5513 <i5513@hotmail.com> wrote:


>> > (After get parameters)
>> 
>> You should use the CGI.pm module for that.
>>
> Ok I'll look for CGI.pm module. 


If you have a fairly recent perl installed, then the CGI module
should already be installed.

What happens when you type these?

   perl -v

   perldoc CGI


>> Saying it in Perl is always better than trying to say it in English.
>> 
>> You say that sentence in Perl like this:
>> 
>>    my %FORM = ( text => "\r\n" );
>> or
>>    $FORM{text} = "\r\n";

> Ok I don't know english very well, as you can see


But that won't matter much if you say as much as possible "in Perl".  :-)


>> Have you seen the Posting Guidelines that are posted here frequently?
>> 
> Posting Guidelines, for this group 


Yes. They are posted to the newsgroup 2 times each week...


   http://mail.augustmail.com/~tadmc/clpmisc.shtml


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Tue, 07 Oct 2003 04:34:05 GMT
From: Henry <henryn@zzzspacebbs.com>
Subject: Teach me how to fish, regexp
Message-Id: <BBA79042.154E5%henryn@zzzspacebbs.com>

Folks:

I've got a bunch of fixed-format text files (< 100k bytes each) to sniff.

Each file is divided into paragraphs. Each para is preceded by at least
three blank lines, and is introduced by a section number of 1 to 6 digits
followed by a period and two spaces, OR, 1 to 6 digits followed by a period
and at least one digit, followed by a period and two spaces, e.g.

------------------------------------------------------
 .....
<empty>
<empty>
<empty>
12034.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah.
Blah. ...
------------------------------------------------------

Or, the second format:

------------------------------------------------------
 .....
<empty>
<empty>
<empty>
12034.1.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah. ...
 ....
------------------------------------------------------

Yes, if you are wondering, these are legal blah-blah-blahs.

Seems the best way to deal with this is to slurp, and use "split" with the
appropriate regexp.  Wrinkle: I need to retain the section numbers in the
return strings. 

Right! I've been writing trial regular expressions all day, and I have come
to the conclusion that I'm not very good at it. I've also examined examples
and help pages until I'm ... really tired and no wiser.

Well, I _can_ split based on assuming that the three empty lines _always_
appear before a new section, but this doesn't seem very robust.  Seems like
I really ought to be able to recognize at least two empties followed by
these two fixed-format alternatives.

Best I've figured out takes a common subset of the two cases:

   #@sections = split /\n\n\n[0-9][0-9]+\./,<>;

This works ok, but it eats the match string.  Non-capturing parentheses?  I
wish I could make heads or tails of this syntax.  Look-ahead assertion?
Even more cryptic. 

I can't even figure out why I seem to need "[0-9][0-9]+" for my 5 digit test
case when it seems "[0-9]+" ought to suffice.   (Yeah, I know my solution
will fail if there's only 1 digit --i.e. the first 9 sections-- but that's
obviously the least of my problems).

Could some wizard teach me to fish:  Please don't give me a solution, merely
tell me where I'm going wrong and put me back on the right path.

Or should I go back to my awk hack that works and which I actually
understand?

Thanks,

Henry

henryn@zzzspacebbs.com  remove 'zzz'




------------------------------

Date: 07 Oct 2003 07:01:46 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Teach me how to fish, regexp
Message-Id: <slrnbo4p6t.pv1.mgjv@verbruggen.comdyn.com.au>

On Tue, 07 Oct 2003 04:34:05 GMT,
        Henry <henryn@zzzspacebbs.com> wrote:
> Folks:
> 
> I've got a bunch of fixed-format text files (< 100k bytes each) to sniff.
> 
> Each file is divided into paragraphs. Each para is preceded by at least
> three blank lines, and is introduced by a section number of 1 to 6 digits
> followed by a period and two spaces, OR, 1 to 6 digits followed by a period
> and at least one digit, followed by a period and two spaces, e.g.

Is the first paragraph also preceded by three blank lines? And do you
mean three blank lines, or three newlines? I will assume three
newlines (i.e. two blank lines).

[snip of example records, see code, below]

> Seems the best way to deal with this is to slurp, and use "split" with the
> appropriate regexp.  Wrinkle: I need to retain the section numbers in the
> return strings. 

I would probably set the input record separator ($/, see perlvar) to
"", which will treat two or more consecutive newlines as the record
separator. Then each record starts with the number you're interested
in.

#!/usr/local/bin/perl
use warnings;
use strict;

$/ = "";
while (<DATA>)
{
    chomp;
    if (my ($num, $para) = /^(\d+(?:\.\d)?)\.  (.*)/s)
    {
        print "[$num] $para\n";
    }
    else
    {
        print "MALFORMED RECORD\n";
    }
}

__DATA__
12034.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah.
Blah. ...


12034.1.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah. ...
 ....

12034.2.  Foo bar baz


12035.  Grubble banana groo
feeble deee ....

=== End example program===

The regular expression in more detail:

/
    ^           # from the beginning of the record
    (           # start capture
      \d+       # one or more digits
      (?:       # start grouping, but no capturing
        \.\d    # A literal . followed by a digit
      )         # end grouping
      ?         # previous (group) one or zero times, i.e. it's optional
    )           # end capturing
    .\ \        # literal . followed by two spaces
    (.*)        # capture the rest of the record
/sx

The s modifier makes . match newlines, and the x modifier allows the
comments I put in (which is also why I needed to escape the spaces in
this version, and not in the one above. The first capturing set of
parentheses returns the paragraph number, including the sub-number, if
present, and the second capturing parentheses set returns the "Blah,
blah.." bit up to the end of the record.

Also see the perlvar and perlre documentation for more information.

If two newlines is not a record splitter, and you _have_ to use a
minimum of three, this won't work. You can't even check after reading
a record whether it ends in more than two newlines, since it always
will end in exactly two, no matter how many are in the input (which is
pretty annoying), so you'd have to probably set $/ to "\n\n\n", and
remove any leading and trailing whitespace yourself and skip "empty"
records:

#!/usr/local/bin/perl
use warnings;
use strict;

$/ = "\n\n\n";
while (<DATA>)
{
    s/^\s+//;
    s/\s+$//;
    next if $_ eq "";

    if (my ($num, $para) = /^(\d+(?:\.\d)?)\.  (.*)/s)
    {
	print "[$num] $para\n";
    }
    else
    {
	print "ILLEGAL RECORD\n";
    }
}

__DATA__
12034.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah.
Blah. ...

blah






12034.1.  Blah, blah, blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah,
blah, blah.  Blah.  Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.
Blah Blah Blah.  Blah. Blah, blah, blah, blah.  Blah.  Blah Blah Blah. ...
 ....



12034.2.  Foo bar baz


12035.  Grubble banana groo
feeble deee ....

=== End example program===


Martien
-- 
                        | 
Martien Verbruggen      | Freudian slip: when you say one thing but
Trading Post Australia  | mean your mother.
                        | 


------------------------------

Date: Tue, 07 Oct 2003 06:28:12 GMT
From: "Public Interest" <test@test.com>
Subject: Very Interesting max_size in UserAgent
Message-Id: <02tgb.167236$0v4.12674826@bgtnsc04-news.ops.worldnet.att.net>

  #!/usr/bin/perl
  use Net::HTTP;
  use LWP::UserAgent;

  $ua = LWP::UserAgent->new ( );
  $ua->max_size(2000);
  $url = 'http://www.yahoo.com';

  my $req = HTTP::Request->new(GET => "$url");

  $htmlcode = $ua->request($req)->content;
  print $htmlcode;

# the problem is if i change 2000 to 1950 in max_size, the $htmlcode is
still the same. Looks to me that the server is flushing and client is using
buffer to hold it and the server decide how much each flushing is giving,
and if each flushing is 1024 bytes, and max_size is checked after each
flushing. So, max size of 1025 to max size of 2047 will give the same
result: both are 2048. Is that right? So max_size in UserAgent is really an
estimated value.




------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 5626
***************************************


home help back first fref pref prev next nref lref last post