[22254] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4475 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 28 09:06:55 2003

Date: Tue, 28 Jan 2003 06:05:08 -0800 (PST)
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, 28 Jan 2003     Volume: 10 Number: 4475

Today's topics:
    Re: byte array in perl, how? pack, unpack? java to perl <bart.lateur@pandora.be>
    Re: Edit a perl script and run the modified one from th <bigj@kamelfreund.de>
    Re: Email address RE (Helgi Briem)
    Re: identifying web host platform? <simon.oliver@nospam.umist.ac.uk>
        loop-array question (patric)
    Re: loop-array question (Anno Siegel)
    Re: loop-array question <eldar@nospam.iki.fi>
    Re: loop-array question <Graham.T.Wood@oracle.com>
    Re: loop-array question (Anno Siegel)
    Re: loop-array question <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: loop-array question <nobull@mail.com>
    Re: loop-array question <bart.lateur@pandora.be>
    Re: More random then other random (Tad McClellan)
    Re: perl code to "fix" VBR mp3s with bogus time informa (Anno Siegel)
    Re: Perl Library Path.. I need to change at runtime (Anno Siegel)
    Re: Possible dead links in perlfaq <Jodyman@hotmail.com>
    Re: Regular Expression Question (SteveW)
    Re: script <pons@gmx.li>
    Re: script <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: script <pons@gmx.li>
        sending attachments with mime::lite and sendmail (Dhruv)
    Re: sending attachments with mime::lite and sendmail <anfi@Box43.pl>
        Tainting individual variables (John Ramsden)
        Using storable. <spikey-wan@bigfoot.com>
        Very Basic Question on the Use of the __DATA__ Token <gbarbay@NOnetscapeSPAM.net>
    Re: Very Basic Question on the Use of the __DATA__ Toke (Tad McClellan)
        Why doesn't  perl -ex 'print 1' work on Windows? (John Ramsden)
    Re: Why doesn't  perl -ex 'print 1' work on Windows? <simon.oliver@nospam.umist.ac.uk>
    Re: Why doesn't  perl -ex 'print 1' work on Windows? <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Why doesn't  perl -ex 'print 1' work on Windows? <bart.lateur@pandora.be>
    Re: win32 tieregistry html (Nuno Cancelo)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Jan 2003 13:33:01 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: byte array in perl, how? pack, unpack? java to perl
Message-Id: <1b1d3vgqfdu2nll8015fbr9trjuiqqkbbs@4ax.com>

vientoloco wrote:

>This funtions are in java.
>I'll try to find similar functions in perl.
>Help, please :)
>Any tutorial?

It looks like what you want, is turn hexadeciaml strings into binary
strings and vice versa. There's an appopriate but rather low level
function built into Perl for that: pack/unpack with the 'H' template
(plus a number, or a star for all of them). See "pack" in perlfunc for
the basic docs.

As for a tutorial, Perl now comes with a tutorial on pack/unpack,
"perlpacktut", also available on perldoc.com:

	<http://www.perldoc.com/perl5.8.0/pod/perlpacktut.html>

It might guide you through the numerous dark places in pack(), a bit.

-- 
	Bart.


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

Date: Tue, 28 Jan 2003 09:44:51 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Edit a perl script and run the modified one from the command	line..
Message-Id: <pan.2003.01.28.08.06.57.348819@kamelfreund.de>

On Mon, 27 Jan 2003 17:12:53 +0000, Jim Carter wrote:

> The command I know is (windows 2000)
> C:\perl -e "s/3/4/g;" test.pl
> 
> and it doesn't work. Do any of you modify the the above piece of line?

I believe, that
perl -pi -e "s/3/4/g" test.pl
     ^^^
does what you want to achieve.


Greetings,
Janek


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

Date: Tue, 28 Jan 2003 12:56:01 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Email address RE
Message-Id: <3e367d4b.2109150027@news.cis.dfn.de>

On Tue, 28 Jan 2003 10:21:26 +1000, Matthew Braid
<mbear@uq.net.au> wrote:

>I've been looking for a package to retrieve a valid email address from a 
>string and have had little luck (Mail::Address was a little 
>disappointing - given the string "fleeble" it thinks the email address 
>is "fleeble" rather than ''. Useful)

What's wrong with that?

Anyway, this is a Frequently Asked Question or FAQ.
Questions to FAQs are to be found in a series of
documents, perlfaq1-9, that come bundled with every
distribution  of Perl and can be browsed and searched
using the perldoc program.

"perldoc -q address" will tell you all you need to
know about this subject.
-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: Tue, 28 Jan 2003 08:26:12 +0000
From: Simon Oliver <simon.oliver@nospam.umist.ac.uk>
To: I'm Dan <dg1261@cs.com>
Subject: Re: identifying web host platform?
Message-Id: <3E363EA4.3060707@nospam.umist.ac.uk>

I'm Dan wrote:
> Some time ago (within the last year or two) I recall tinkering with a way to
> reveal the host platform and server of a website (ie., NT vs linux, IIS v
> Apache, etc).  However, I can no longer recall how it was done.  I don't
> remember whether it was a URL of some diagnostic site, or whether it was a
> perl CGI script, or whether it was some exe file to run.  I don't even
> remember whether I learned about it from a magazine (PC Magazine, maybe?) or
> from a newsgroup.  Does this ring a bell with anyone?

This infomration is often disclosed in the Server http header.  Use LWP 
to retrieve the headers, something like this:

require LWP::UserAgent;

my $url = 'http://www.perl.org';
my $ua = LWP::UserAgent->new(env_proxy => 1);
my $response = $ua->head($url);
print $response->header('Server');

-- 
   Simon Oliver



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

Date: 28 Jan 2003 01:30:42 -0800
From: patrick_cusack@hotmail.com (patric)
Subject: loop-array question
Message-Id: <1ec975dc.0301280130.6b44e0f@posting.google.com>

What is the best way for me to proceed through a loop, find an item in
an array that matches a condition, delete it and then proceed to the
next match without having to go back to the beginning of the array and
re-loop?


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

Date: 28 Jan 2003 09:45:02 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: loop-array question
Message-Id: <b15jeu$5hv$2@mamenchi.zrz.TU-Berlin.DE>

patric <patrick_cusack@hotmail.com> wrote in comp.lang.perl.misc:
> What is the best way for me to proceed through a loop, find an item in
> an array that matches a condition, delete it and then proceed to the
> next match without having to go back to the beginning of the array and
> re-loop?

It is difficult (not only) in Perl to change an array while looping
over it.  This sounds like a job for grep:

    my @new_array = grep not condition( $_), @old_array;

Anno



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

Date: Tue, 28 Jan 2003 09:46:55 GMT
From: "perlsage" <eldar@nospam.iki.fi>
Subject: Re: loop-array question
Message-Id: <jksZ9.25837$ZE1.544116@news1.nokia.com>

"patric" <patrick_cusack@hotmail.com> wrote in message
news:1ec975dc.0301280130.6b44e0f@posting.google.com...
> What is the best way for me to proceed through a loop, find an item in
> an array that matches a condition, delete it and then proceed to the
> next match without having to go back to the beginning of the array and
> re-loop?

I think the easiest way to do this is:

foreach (@arr){
    if ($_=~/\bpattern\b/){
## do your stuff
    }
}




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

Date: Tue, 28 Jan 2003 09:54:25 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: loop-array question
Message-Id: <3E365351.866CAE1C@oracle.com>

patric wrote:

> What is the best way for me to proceed through a loop, find an item in
> an array that matches a condition, delete it and then proceed to the
> next match without having to go back to the beginning of the array and
> re-loop?

Some code to illustrate what you are doing would help.  If I understand
correctly, you want to loop through elements of an array and discard any
that match a certain condition.

I think you should read perldoc -f grep.  The grep function will return a
list of items matching a condition from within another list.  For example

@allsorts=qw(loan bone tone moan groan hone phone);
@oan_list = grep {!/one/}@allsorts;  # the "!" means not matching /one/
@one_list will contain "loan","moan", "groan"

Note that you are not limited to regular expression matching in the {},
you can use any condition.

Hope this helps

Graham Wood



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

Date: 28 Jan 2003 09:56:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: loop-array question
Message-Id: <b15k40$5hv$3@mamenchi.zrz.TU-Berlin.DE>

perlsage <eldar@nospam.iki.fi> wrote in comp.lang.perl.misc:
> "patric" <patrick_cusack@hotmail.com> wrote in message
> news:1ec975dc.0301280130.6b44e0f@posting.google.com...
> > What is the best way for me to proceed through a loop, find an item in
> > an array that matches a condition, delete it and then proceed to the
> > next match without having to go back to the beginning of the array and
> > re-loop?
> 
> I think the easiest way to do this is:
> 
> foreach (@arr){
>     if ($_=~/\bpattern\b/){
> ## do your stuff
>     }
> }

Not if "do your stuff" includes deleting the current element from
the array.  That's what to OP wants to do.

Anno


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

Date: Tue, 28 Jan 2003 11:02:19 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: loop-array question
Message-Id: <m5lc3v4hl453hpcbdcj0qstvpfncpim526@4ax.com>

On Tue, 28 Jan 2003 09:46:55 GMT, "perlsage" <eldar@nospam.iki.fi>
wrote:

>"patric" <patrick_cusack@hotmail.com> wrote in message
>news:1ec975dc.0301280130.6b44e0f@posting.google.com...
>> What is the best way for me to proceed through a loop, find an item in
>> an array that matches a condition, delete it and then proceed to the
>> next match without having to go back to the beginning of the array and
>> re-loop?
>
>I think the easiest way to do this is:
>
>foreach (@arr){
>    if ($_=~/\bpattern\b/){
>## do your stuff
>    }
>}


Your "solution" doesn't delete elements which don't match the
condition from the array and it assumes that the condition is a
pattern match, which is not necessarily true. Use grep() like Anno
suggested.



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: 28 Jan 2003 12:15:14 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: loop-array question
Message-Id: <u9r8axwjvx.fsf@wcl-l.bham.ac.uk>

patrick_cusack@hotmail.com (patric) writes:

> What is the best way for me to proceed through a loop, find an item in
> an array that matches a condition, delete it and then proceed to the
> next match without having to go back to the beginning of the array and
> re-loop?

Backwards!

for my $i ( reverse 0 .. $#an_array ) {
   splice @an_array, $i, 1 if a_condition($an_array[$i]);
}

See also alternative solutions using grep if you are happy to copy the
array rather than alter it in place.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 28 Jan 2003 13:26:09 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: loop-array question
Message-Id: <t61d3vsvbo67nbbbauesljakjds9ifhmtj@4ax.com>

patric wrote:

>What is the best way for me to proceed through a loop, find an item in
>an array that matches a condition, delete it and then proceed to the
>next match without having to go back to the beginning of the array and
>re-loop?

grep(). You can make a filtered copy of an array that way.

-- 
	Bart.


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

Date: Mon, 27 Jan 2003 22:32:36 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: More random then other random
Message-Id: <slrnb3c1v4.3e9.tadmc@magna.augustmail.com>

Bob Walton <bwalton@rochester.rr.com> wrote:

> Hmmmm...where does ceiling come from?


He misspelled the function's name.

   perldoc -q ceil


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


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

Date: 28 Jan 2003 10:44:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl code to "fix" VBR mp3s with bogus time information?
Message-Id: <b15mtp$5hv$5@mamenchi.zrz.TU-Berlin.DE>

Scott Evans <gse@antisleep.com> wrote in comp.lang.perl.misc:

[...]

> (I always wonder why people follow up when they don't have an answer...)

It's how Usenet works.  You post something, people comment on *any*
aspect of your posting.  They are by no means obliged to answer your
questions.  If you want that, use a help desk.

Anno


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

Date: 28 Jan 2003 10:15:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Library Path.. I need to change at runtime
Message-Id: <b15l7t$5hv$4@mamenchi.zrz.TU-Berlin.DE>

Ingo Wichmann  <w_ichmann@uni-wuppertal.de> wrote in comp.lang.perl.misc:
> Mike schrieb:
> > I have a solaris 8 server that came  with perl installed.  For various
> > reasons I needed to install my own version of perl in /usr/local.   Now, I
> > have a script that needs to run the /usr/local perl as well as the
> > libraries under another  path.   Can I change a variable in the perl
> > script to
> > point to the library path I want to use for that script? I assume I can.
> > Can someone tell me what that ENV variable is and how I would set it in
> > the perl script. 
> 
> I've never done this. But you can use "use lib '/xx/yy'" to set it at 
> compile time. Maybe perldoc lib helps you.

The OP should note that not all Perl modules are compatible with
all versions of Perl.  In particular, if the new version is 5.8.0,
it will *not* be compatible with modules for an earlier version if
the module has an XS component.

Anno


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

Date: Tue, 28 Jan 2003 11:52:06 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: Possible dead links in perlfaq
Message-Id: <G9uZ9.139$Wu1.20008@newsread1.prod.itd.earthlink.net>


"brian d foy" <comdog@panix.com> wrote in message

> these links have failed a couple of times this week.  anyone know where
> these might have moved to?
>
> ------------------------------------------------------------------------
> FAILURE REPORT
> ------------------------------------------------------------------------
>
> ======perlfaq3.pod
>         http://alpha.olm.net/
>         http://www.MultiEdit.com/
>         http://www.binevolve.com/

How about http://www.codemagiccd.com?  Anyone know where they
went?

Jody




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

Date: 28 Jan 2003 05:50:41 -0800
From: spw57nc@hotmail.com (SteveW)
Subject: Re: Regular Expression Question
Message-Id: <b11ffee8.0301280550.609d9d9b@posting.google.com>

Thanks for all the responses.  Actually, the error was due to the
regex line.  The error was be reported because the special characters
were not being "escaped."  I put a "\" in front of all the special
characters (and not just the "\" as shown initially) and the code
works without giving the undef errors.

Steve


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

Date: Tue, 28 Jan 2003 11:09:06 +0200
From: "Pons" <pons@gmx.li>
Subject: Re: script
Message-Id: <b15h0m$voq4k$1@ID-172702.news.dfncis.de>


"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
message news:i2q93vsdm3omkr8vs0uargg41fqgvch1tj@4ax.com...
> On Sun, 26 Jan 2003 08:34:42 +0200, "Pons" <pons@gmx.li> wrote:
>
> >Greetings
> >I am gonna switch to new AIX Orcale system with load balance,
> >due to that I have to change the Alias and HOST IP in all
> >tnsnames files (tnsname.txt) of my Win2k remote users,
> >I do not want to do it manually. I want to write a script
> >to search for tnsnames file tnsnames.txt on remote windows
> >win2k machines C: and D: and replace it with a new tnsnames,
> >then  I am going place the script on my FreeBSD Intranet web server
> >to be accessd by double click in order to replace the file.
>
>
> There isn't a single question in your post. Let me ask one - are you
> expecting someone to write the script for you? If you are, don't hold
> your breath. If you aren't then why not try to write the script
> yourself and let us know if you stumble into trouble? Just be specific
> when you do ask for help.
>

I am doing it in another via remote ftp ...
I have created batch file batch.bat and placed this inside
ECHO OPEN 10.5.1.100 >> junk.ftp
ECHO USERNAME ftp >> junk.ftp
ECHO PASSWORD ftp >> junk.ftp
ECHO CD /var/ftp/incoming >> junk.ftp
ECHO ascii >> junk.ftp
ECHO get installPrep.sh >> junk.ftp
ECHO BYE >> junk.ftp
FTP -s:junk.ftp

When I try to run this i get the following
G:\>FTP -s:junk.ftp
ftp> OPEN 10.5.1.100
Connected to 10.5.1.100.
220 bsd.sdcdomain.com FTP server (Version 6.00LS) ready.
User (10.5.1.100:(none)):
331 Password required for USER ftp .
530 Login incorrect.
Login failed.

any help

-Pons
pons@gmx.li




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

Date: Tue, 28 Jan 2003 10:55:55 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: script
Message-Id: <3qkc3v478luiitdcu7aa42quvubg66750e@4ax.com>

On Tue, 28 Jan 2003 11:09:06 +0200, "Pons" <pons@gmx.li> wrote:

>
>"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
>message news:i2q93vsdm3omkr8vs0uargg41fqgvch1tj@4ax.com...
>> On Sun, 26 Jan 2003 08:34:42 +0200, "Pons" <pons@gmx.li> wrote:
>>
>> >Greetings
>> >I am gonna switch to new AIX Orcale system with load balance,
>> >due to that I have to change the Alias and HOST IP in all
>> >tnsnames files (tnsname.txt) of my Win2k remote users,
>> >I do not want to do it manually. I want to write a script
>> >to search for tnsnames file tnsnames.txt on remote windows
>> >win2k machines C: and D: and replace it with a new tnsnames,
>> >then  I am going place the script on my FreeBSD Intranet web server
>> >to be accessd by double click in order to replace the file.
>>
>>
>> There isn't a single question in your post. Let me ask one - are you
>> expecting someone to write the script for you? If you are, don't hold
>> your breath. If you aren't then why not try to write the script
>> yourself and let us know if you stumble into trouble? Just be specific
>> when you do ask for help.

[snipped non-Perl script]


That wasn't Perl, which is unfortunate since this group deals with
Perl (at least it tries to).



Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Tue, 28 Jan 2003 14:57:51 +0200
From: "Pons" <pons@gmx.li>
Subject: Re: script
Message-Id: <b15udf$vn4ld$1@ID-172702.news.dfncis.de>

Problem resolved.

d:
cd d:\orant\net80\admin
DIR
ECHO.open 10.5.1.100>script.ftp
ECHO.ftp>>script.ftp
ECHO.ftp>>script.ftp
ECHO.CD /incoming>>script.ftp
ECHO.bin >>script.ftp
ECHO.get TNSNAMES.ORA>>script.ftp
ECHO.BYE>>script.ftp
FTP -s:script.ftp


>
> >
> >"Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in
> >message news:i2q93vsdm3omkr8vs0uargg41fqgvch1tj@4ax.com...
> >> On Sun, 26 Jan 2003 08:34:42 +0200, "Pons" <pons@gmx.li> wrote:
> >>
> >> >Greetings
> >> >I am gonna switch to new AIX Orcale system with load balance,
> >> >due to that I have to change the Alias and HOST IP in all
> >> >tnsnames files (tnsname.txt) of my Win2k remote users,
> >> >I do not want to do it manually. I want to write a script
> >> >to search for tnsnames file tnsnames.txt on remote windows
> >> >win2k machines C: and D: and replace it with a new tnsnames,
> >> >then  I am going place the script on my FreeBSD Intranet web server
> >> >to be accessd by double click in order to replace the file.
> >>
> >>
> >> There isn't a single question in your post. Let me ask one - are you
> >> expecting someone to write the script for you? If you are, don't hold
> >> your breath. If you aren't then why not try to write the script
> >> yourself and let us know if you stumble into trouble? Just be specific
> >> when you do ask for help.
>
> [snipped non-Perl script]
>
>
> That wasn't Perl, which is unfortunate since this group deals with
> Perl (at least it tries to).
>
>
>
> Cheers,
> Bernard
> --
> echo 42|perl -pe '$#="Just another Perl hacker,"'




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

Date: 27 Jan 2003 23:33:33 -0800
From: dmalhotr2001@yahoo.com (Dhruv)
Subject: sending attachments with mime::lite and sendmail
Message-Id: <b6d0b0b.0301272333.20adf1de@posting.google.com>

Hi,

I am having problems sending message via mime::lite module using
sendmail.

I can send mail via sendmail fine if i dont send an attachment.

I am using a form to post and sending mail via a webpage.

Below is my code that the form gets posted to.

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

#!/usr/bin/perl -w
use CGI;
use CGI qw(:standard) ;
use CGI::Carp qw(fatalsToBrowser);  
use DBI;
use Time::localtime;
use strict;
use MIME::Lite;
use Net::SMTP;



#INCLUDE FILE ########
require "include.cgi";#####
######################
print header();

my ($emails, $from, $subject, $body, $attachment);

$emails = cookie('emails');
$from = param('from');
#$subject = param('subject');
$body = param('body');
$attachment = param('attachment');

#SPLIT EACH EMAIL ADDRESS FROM TEXT FILE
my @emails = split /\n/, $emails;

	my $from_address = '$from';
	my $to_address = 'dmalhotr2001@yahoo.com';
	my $subject = 'MIME Net::SMTP test';
	my $mime_type = 'multipart/mixed';
	my $message = "Hello world!\n";
    	
    	# Create the initial text of the message
	my $mime_msg = MIME::Lite->new(
	   From => $from_address,
	   To   => $to_address,
	   Subject => $subject,
	   Type => $mime_type,
	   Data => $message
	   )
 	 or die "Error creating MIME body: $!\n";
 	my $filename = '$attachment';
	my $recommended_filename = '$attachment';
	# Attach the test file
	
	$mime_msg->attach(
	   Type => 'BINARY',
	   Path => $filename,
	   Filename => $recommended_filename,
	   Disposition => 'attachment'
	   )
	  or die "Error attaching test file: $!\n";

    	    MIME::Lite->send("sendmail", "/usr/sbin/sendmail -t -oi
-oem");
----------------------------------------------------------

Please let me know what i am doing wrong.  When I post i dont get any
error messages and also my apache logs error_log has no error message.
 I am not sure what I am doing wrong.

Thanks

Dhruv


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

Date: Tue, 28 Jan 2003 13:19:58 +0000
From: Andrzej Filip <anfi@Box43.pl>
Subject: Re: sending attachments with mime::lite and sendmail
Message-Id: <3E36837D.DAD7472E@Andrzej.Adam.Filip>

Dhruv wrote:

> I am having problems sending message via mime::lite module using
> sendmail.
>
> I can send mail via sendmail fine if i dont send an attachment.
>
> I am using a form to post and sending mail via a webpage.
>
> Below is my code that the form gets posted to.
>
> -------------------------------------------------------------
>
> #!/usr/bin/perl -w
> use CGI;
> use CGI qw(:standard) ;
> use CGI::Carp qw(fatalsToBrowser);
> use DBI;
> use Time::localtime;
> use strict;
> use MIME::Lite;
> use Net::SMTP;
>
> #INCLUDE FILE ########
> require "include.cgi";#####
> ######################
> print header();
>
> my ($emails, $from, $subject, $body, $attachment);
>
> $emails = cookie('emails');
> $from = param('from');
> #$subject = param('subject');
> $body = param('body');
> $attachment = param('attachment');
>
> #SPLIT EACH EMAIL ADDRESS FROM TEXT FILE
> my @emails = split /\n/, $emails;
>
>         my $from_address = '$from';
>         my $to_address = 'dmalhotr2001@yahoo.com';
>         my $subject = 'MIME Net::SMTP test';
>         my $mime_type = 'multipart/mixed';
>         my $message = "Hello world!\n";
>
>         # Create the initial text of the message
>         my $mime_msg = MIME::Lite->new(
>            From => $from_address,
>            To   => $to_address,
>            Subject => $subject,
>            Type => $mime_type,
>            Data => $message
>            )
>          or die "Error creating MIME body: $!\n";
>         my $filename = '$attachment';
>         my $recommended_filename = '$attachment';
>         # Attach the test file
>
>         $mime_msg->attach(
>            Type => 'BINARY',
>            Path => $filename,
>            Filename => $recommended_filename,
>            Disposition => 'attachment'
>            )
>           or die "Error attaching test file: $!\n";
>
>             MIME::Lite->send("sendmail", "/usr/sbin/sendmail -t -oi
> -oem");
> ----------------------------------------------------------
>
> Please let me know what i am doing wrong.  When I post i dont get any
> error messages and also my apache logs error_log has no error message.
>  I am not sure what I am doing wrong.

Where do you call INSTANCE send method ?
[ $mime_msg->send ]

--
Andrzej [pl>en: Andrew] Adam Filip http://www.polbox.com/a/anfi/
*Random epigram* :
It will be generally found that those who sneer habitually at human nature
and affect to despise it, are among its worst and least pleasant examples.
	-- Charles Dickens



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

Date: 28 Jan 2003 05:32:11 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Tainting individual variables
Message-Id: <d27434e.0301280532.1b5cf318@posting.google.com>

I have an app in which the user can specify a 'boiler plate' text string
to appear in an alert email, and this string can contain any of a dozen
or so variables, such as $msg_severity, $device_name, etc, which means
I must eval() the text with variables of the valid names all in scope
in order to plug in the values of any referred to in the text.

Although the users will all be internal, so it can be assumed they are
cooperative from the standpoint of the app, and certainly not malicious,
I'd like to avoid even the theoretical possibility of some joker setting
up a string such as `rm -rf /` or something. So is there a way of tainting
a single variable before evaling it?

(I'd rather eval than simply substitute values via su///, as this allows
the string to include logical constructs such as '? :'.)


Cheers

John Ramsden (john_ramsden@sagitta-ps.com)


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

Date: Tue, 28 Jan 2003 13:49:34 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Using storable.
Message-Id: <b161r2$gsi$1@newshost.mot.com>

Hello World! :-)

I have successfully used storable to store and retrieve a hash of hashes
to/from a file.

If I had 2 hashes of hashes, and a scalar variable that I wanted to store
and retrieve to/from a single file, how would I go about this?

Thanks.

R.




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

Date: Tue, 28 Jan 2003 05:21:36 GMT
From: Gordon Barbay <gbarbay@NOnetscapeSPAM.net>
Subject: Very Basic Question on the Use of the __DATA__ Token
Message-Id: <5o4c3volnpmtqq2f87ohmm73hlk6oreg2p@4ax.com>

I have a very basic question on the use of the __DATA__ token to read
data into my script. This is on a Win98SE system using Activestate
Perl 5.6.1.  Here is the relevant parts of the code:


use strict;
use File::Find;

# @ARGV = qw(.) unless @ARGV;

while (<main::DATA>) {
find (\&sav_fd, @_);
}

sub sav_fd {
# This subroutine does the main work of the program
}

 __DATA__
H:/Programming/Perl/backup/


This is a backup program where I want to put a list of top level
directories to read in the DATA section.  The script will take each of
the directories and use the File::Find module to copy, recursively,
all the listed directories (I am only listing one directory while
developing the script) and thier files to the backup device.  

It seems like this should be simple, but I can't get it to work.  The
<main::DATA> should read the indicated directory as the first element
of the @_ array, correct?  The while should then operate on each
element (in this case, just one) in turn.  

If I try to run the code I get:
"invalid top directory at Perl/lib/File/Find.pm line 295, <DATA>
line1."
This error occurs almost no matter what I try.

The "@ARGV = qw(.) unless @ARGV;" line is a holdover from an earlier
incarnation of the script.  Here, instead of using the __DATA__ token
and the "while" loop, I used command line arguments to indicate which
directory I wanted to backup (this is code I used from the Cookbook).
I used @ARGV instead of the @_ in the find statement.  The *script
works perfectly* using this method, but I want to use the DATA token
since the working version of the script will have many directories
listed instead of one like above and I'd like for the script to be
self contained.

I have searched the Cookbook, Programming Perl, learn.perl.org and
even Googled the perl newsgroups but haven't been able to figure out
the problem.  I am a relative newbie to Perl programming so if the
solution is simple, thats why!  Any help would be appreciated!


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

Date: Tue, 28 Jan 2003 01:05:20 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Very Basic Question on the Use of the __DATA__ Token
Message-Id: <slrnb3catg.50r.tadmc@magna.augustmail.com>

Gordon Barbay <gbarbay@NOnetscapeSPAM.net> wrote:

> I have a very basic question on the use of the __DATA__ token to read
> data into my script. 


The DATA thing actually has nothing to do with your problem.


> while (<main::DATA>) {
> find (\&sav_fd, @_);
                  ^^
                  ^^

You spelled the name of the variable incorrectly, that should be $_ .


> It seems like this should be simple, but I can't get it to work.  The
><main::DATA> should read the indicated directory as the first element
> of the @_ array, correct?  


What did you see that made you think that?

   while ( <INPUT> )

is a special case shortcut, the longer version is:

   while ( $_ = <INPUT> )

the longest version is:

   while ( defined($_ = <INPUT>) )

The special case applies iff the input operator is the only thing
in the condition of a while. It automatically saves the input
line that was read into $_ for you.


> The "@ARGV = qw(.) unless @ARGV;" line is a holdover from an earlier
> incarnation of the script.


It should work if you just change the "@" to "$" (and add a chomp() ).

It will call find() once for each line in __DATA__ .

If you want to call find only once with all of the directories,
then you don't need an (explicit) loop at all:

   
   find (\&sav_fd, map { chomp; $_ } <main::DATA>);


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


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

Date: 28 Jan 2003 01:14:38 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Why doesn't  perl -ex 'print 1' work on Windows?
Message-Id: <d27434e.0301280114.671a879@posting.google.com>

Why do all the following commands, and several other variations,
print just a blank line in a Windows 2K DOS window, whereas the
equivalent single-line Perl scripts print what is asked for?

  perl -ex "print 1"
  perl -ex 'print 1'
  perl -ex "print \"\n\""
  perl -ex "print time"
  perl -ex "print time();"
    ::::

Cheers

John Ramsden (john_ramsden@sagitta-ps.com)

P.S. I realize there's probably some perldoc magic keyword one
can use to get a chapter and verse explanation; but without
knowing what the word is, that isn't much help. There was no
explanation in the 'perldoc -q command' output.


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

Date: Tue, 28 Jan 2003 09:18:48 +0000
From: Simon Oliver <simon.oliver@nospam.umist.ac.uk>
Subject: Re: Why doesn't  perl -ex 'print 1' work on Windows?
Message-Id: <3E364AF8.4040708@nospam.umist.ac.uk>

John Ramsden wrote:
> Why do all the following commands, and several other variations,
> print just a blank line in a Windows 2K DOS window, whereas the
> equivalent single-line Perl scripts print what is asked for?
> 
>   perl -ex "print 1"
>   perl -ex 'print 1'
>   perl -ex "print \"\n\""perldoc perlrun 
>   perl -ex "print time"
>   perl -ex "print time();"
>     ::::

Are you sure?  On my Linux box they print a balnk line too - as they 
shouls.  See perldoc perlrun form an explanation of the -x option.

-- 
   Simon Oliver



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

Date: Tue, 28 Jan 2003 10:58:44 +0100
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Why doesn't  perl -ex 'print 1' work on Windows?
Message-Id: <e0lc3v04lgik7eksalbnbochj78seq7lt0@4ax.com>

On 28 Jan 2003 01:14:38 -0800, john_ramsden@sagitta-ps.com (John
Ramsden) wrote:

>Why do all the following commands, and several other variations,
>print just a blank line in a Windows 2K DOS window, whereas the
>equivalent single-line Perl scripts print what is asked for?
>
>  perl -ex "print 1"
>  perl -ex 'print 1'
>  perl -ex "print \"\n\""
>  perl -ex "print time"
>  perl -ex "print time();"


Are you aware of what the -x switch does? If not try:


  perldoc perlrun


for an explanation. Then get rid of the x and try those commands
again.


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Tue, 28 Jan 2003 13:24:09 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why doesn't  perl -ex 'print 1' work on Windows?
Message-Id: <n11d3vck0dmgcqcjdc91m0i7v3sfavnok4@4ax.com>

John Ramsden wrote:

>Why do all the following commands, and several other variations,
>print just a blank line in a Windows 2K DOS window, whereas the
>equivalent single-line Perl scripts print what is asked for?
>
>  perl -ex "print 1"
>  perl -ex 'print 1'

Meaning what?

what you execute, is "x". That's a bareword, which Perl treats as a
string. It does nothing useful.

-- 
	Bart.


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

Date: 28 Jan 2003 05:07:26 -0800
From: nac@advancecare.com (Nuno Cancelo)
Subject: Re: win32 tieregistry html
Message-Id: <8349fc76.0301280507.71b64dd0@posting.google.com>

hi
the reason that i don't use the getlogin function is when i run on a
web server, using ie as a cliente, insted of giving me the username of
the person logged in the machine shows me "SYSTEM".
I'm kind a new is this perl "thing", but i thougt that by using
TieRegistry, my problem whould be bypass but doesn't seem so.
Any ideas??
thanks


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

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


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