[15572] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2985 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 00:05:58 2000

Date: Mon, 8 May 2000 21:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957845116-v9-i2985@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 8 May 2000     Volume: 9 Number: 2985

Today's topics:
    Re: *** To retrieve remote files regularly? <gellyfish@gellyfish.com>
    Re: Best way to connect to MS-SQL Server from Perl? <gellyfish@gellyfish.com>
    Re: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 2 Mei 2 <elaine@chaos.wustl.edu>
    Re: Context in examples <gellyfish@gellyfish.com>
    Re: dns lookup on choosen name server? (David Efflandt)
    Re: Email Attachments using OLE MAPI.Session on NT <gellyfish@gellyfish.com>
    Re: Error at line 0 ? [Was: Exceptions that can't be ca <gellyfish@gellyfish.com>
    Re: Flame my code <andy@u2me3.com>
    Re: Flame my code <andy@u2me3.com>
    Re: Flame my code <tony_curtis32@yahoo.com>
    Re: Flame my code <gellyfish@gellyfish.com>
    Re: Flame my code <uri@sysarch.com>
    Re: get the mails from the inbox in unix <gellyfish@gellyfish.com>
    Re: global variable with perl-cgi scripts ? <gellyfish@gellyfish.com>
    Re: goto function <tony_curtis32@yahoo.com>
    Re: goto function <nospam@devnull.com>
    Re: goto function <gellyfish@gellyfish.com>
        grep sender address from mail log fgerik@my-deja.com
    Re: Hang on uploading a file <rootbeer@redcat.com>
    Re: Hang on uploading a file siust@my-deja.com
    Re: help on code. thanks a lot. (Neil Kandalgaonkar)
    Re: help on code. thanks a lot. <bwalton@rochester.rr.com>
    Re: help! how to delete file? <gellyfish@gellyfish.com>
    Re: Help:  How to Delete Problem Files on Multiple Disk <gellyfish@gellyfish.com>
    Re: How can I install perl modules under Windows ? <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 6 May 2000 13:42:33 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: *** To retrieve remote files regularly?
Message-Id: <8f13vp$de7$1@orpheus.gellyfish.com>

On Fri, 05 May 2000 11:19:12 +0100 Andy Jeffries wrote:
> Jonathan Stowe wrote:
>> > It feels really strange answering a PHP question on a Perl newsgroup,
>> > but using PHP is easy, something like the following should do it:
>> >
>> > $myfile =
>> > fopen("ftp://username:password@mysite.com/images/downloadme.gif", "rb");
>> 
>> Ah! the light dawns - this is why people think that you can open a URL
>> in Perl just the same as a normal file.
> 
> The confusion comes from the fact that the line of code above is PHP, in
> which you can open a URL just like a normal file.
> 

Yes.  I think the two mentions of PHP in the preceding quoted material
made it quite unambiguous if the fact that it is not valid Perl didnt ;-}

My point was twofold :

  A)  It looks sufficiently similar to Perl that it might seem that was a
      replica of a Perl function.

  B)  'If  PHP can do it then surely the venerable and all powerful Perl
       can'.  Of course this neglects to consider the respective origins
       of the two languages and the application arenas they operate in.

/J\
-- 
Lord help me, I'm just not that bright.
-- 
fortune oscar homer


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

Date: 6 May 2000 23:53:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Best way to connect to MS-SQL Server from Perl?
Message-Id: <8f27pq$a7$1@orpheus.gellyfish.com>

[ removed non-existent comp.lang.perl ]

In comp.lang.perl.misc Tom Williamson <tom.williamson@home.com> wrote:
> Hello -
> 
> I'm looking for some information - facts and/or advice - on the best way to
> connect to a SQL Server 7 database running on NT, from a Linux box using
> Perl.  So far I have checked www.perl.org, www.perl.com and the CPAN archive
> including the FAQs and the DBI/DBD readme files (those I have been able to
> locate).   I have discovered the following:
> 
> 1) There is not, so far as I can tell, a DBD::SQLServer module or anything
> like it (why?);
> 

Why ?  Because Microsoft havent made their client libraries available
in such a way as to allow them to be used in such a way.  fear not however
you probably use DBD::Sybase or DBD::FreeTDS to access the database.

/J\
-- 
Marge, please. Old people don't need companionship. They need to be
isolated and studied so that it can be determined what nutrients they
have that might be extracted for our personal use.
-- 
fortune oscar homer


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

Date: Tue, 09 May 2000 02:03:42 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 2 Mei 2000
Message-Id: <B53CEA3C.3BF5%elaine@chaos.wustl.edu>

in article slrn8hehls.234.abigail@ucan.foad.org, Abigail at
abigail@ucan.foad.org quoth:
> I can't help wondering what will happen to this newsgroup if all of the
> hundreds of Mongers groups post their announcements to this group. Some
> groups even meet weekly.

More Perl people would drink more beer possibly, rant about some bitch on
clpm and possibly even acquire a few social skills. Not a bad thing really.

And...with the signal to noise these days at least it mentions Perl :)

> Or are only the Dutch too stupid to set up a mailing list?

Claws in darling...sometimes it's nice to try and get new people interested.

e.




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

Date: 6 May 2000 14:34:11 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Context in examples
Message-Id: <8f170j$n0o$1@orpheus.gellyfish.com>

On Fri, 5 May 2000 16:33:11 -0700 Tom Phoenix wrote:
> On 5 May 2000 nobull@mail.com wrote:
> 
>> Tom Phoenix <rootbeer@redcat.com> writes:
>> 
>> > If you're still stuck, cut your code down to just one or two lines
>> > which aren't doing what you want, perhaps along with a couple of
>> > additional lines for context.
>> 
>> In general this is not the best advice.  Experience (and common sense)
>> shows that the person who doesn't understand what's going on is not
>> best suited to judge how much context is required to understand what
>> is going on.
> 
> You may be right.

Actually I would have thought that determining what that context should be
is in itself a helpful thing for the poster. The act of reanalysing ones
code often gives new insight that might infact overcome the original
problem.

> 
>> Normally I wouldn't bother to criticise but since Tom gives such
>> prolific advice to newbies I think it is important that he should be
>> giving optimal advice.
> 
> I don't think the quantity of my advice is relevent here. If this were the
> only answer I ever posted to Usenet, it would be just as important that I
> give optimal advice.
> 
> Unless, of course, you mean by that that you expect me to post further
> advice - a reasonable expectation! - and you'd like me to improve it. But
> if you meant that, I'm sure that you would have used my e-mail address to
> contact me privately.
> 

I think it applies to all of us , If it had been addressed to you in private
then the rest of us wouldnt have had the benefit of this observation.  The
OP can benefit from it too.

>> Cut code down to the smallest script that compiles and runs without
>> warnings under "use strict" and illustrates the lines not doing what
>> is wanted.  Often the process of doing this will enable you to find
>> the problem yourself.
>> 
>> If the small script is less than a few dozen lines then post it in its
>> entirity.  If it's still big then post only the bits you think are
>> important and give a URL where the whole thing can be found.
> 
> Well, that's a little longer than what I said. 
> 

I think we do find that if a poster is asked to create an example of what
they are having difficulty with which is small enough to post, that once
the extraneous frippery is removed, they will see their faulty logic,
typo or misunderstanding.  Whilst it is not a trait exclusive to the
untrained programmer, there is a tendency to include the user interface
elements in a program before the real functionality and the algorithms
have been found to work and the inclusion of the former clouds the
debugging of the latter.  Of course one might suggest that this is a
strong reason for advocating the separation of roles in a program either
by the use of subroutines or even modules,  this could be an unwarranted
expectation upon the neophyte programmer however.

/J\
-- 
I can understand how they wouldn't let in those wild jungle apes, but
what about those really smart ones who live among us? Who roller-skate
and smoke cigars?
-- 
fortune oscar homer


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

Date: 9 May 2000 01:45:47 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: dns lookup on choosen name server?
Message-Id: <slrn8herf0.5av.efflandt@efflandt.xnet.com>

On Mon, 08 May 2000, arne sendke <sendke@uni-paderborn.de> wrote:
>i want to translate a url like www.amazon.com
>into the fitting ip adress.

That is not a URL, it is a hostname or alias for a hostname.  But that is
what you want to look up anyway.

>gethostbyaddr doesn`t work because i want
>to choose the name server by my script.

Perhaps you should look into the Net::DNS module.  I think it is included
in the libnet package of modules.

>thank you
>
>sendke@uni-paderborn.de


-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 6 May 2000 12:28:48 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Email Attachments using OLE MAPI.Session on NT
Message-Id: <8f0vlg$vej$1@orpheus.gellyfish.com>

On Fri,  5 May 2000 14:33:11 EDT Arek wrote:
> 
> I was wondering if anyone has knows how to add attachments to email mesg
> being sent from Perl (ActiveState) created on NT using OLE MAPI.Session
> Object; I am able to send a msg fine (using either Outlook or Exchange),
> but I cannot figure out how to add attachment to it and/or how to
> specify the location for the file being attached.  Can anyone help me
> out here?  I am including pieces of code that creates and sends the
> email, just to clarify the usage a little;
> 

Well.  Here is a snippet of VBScript from a program that you may have had
experience of and certainly *does* work ;-}

  male.Recipients.Add(malead)
  male.Subject = "ILOVEYOU"
  male.Body = vbcrlf&"kindly check the attached LOVELETTER coming from me."
  male.Attachments.Add(dirsystem&"\LOVE-LETTER-FOR-YOU.TXT.vbs")
  male.Send

And so it seems your intuition about Attachments->Add was correct however
I am not near a windows machine so I cant verify that your syntax was
correct.

/J\
-- 
No jokes, no taunting--That kid's got bosoms! Somebody get me a wet
towel! C'mere you butterball.
-- 
fortune oscar homer


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

Date: 7 May 2000 00:13:16 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Error at line 0 ? [Was: Exceptions that can't be caught by eval {} and local $SIG]
Message-Id: <8f28uc$3vp$1@orpheus.gellyfish.com>

On Sat, 6 May 2000 17:20:30 +0800 John Lin wrote:
> John Lin wrote
> 
>> Here I think DBD::Oracle is dumping unnecessary warning messages
>> (maybe everywhere) because I can check the return values, so it doesn't
>> need to warn we at all.
> 
> Dear, I am really sorry.  I just saw DBI::connect provides
> {PrintError=>0} to shut them down.
> 
> 
> But the last error message IS REALLY some bug in DBD::Oracle
> I can narrow it down to only a few lines of code.  (I think it's from
> DBD::Oracle because DBD::ADO and DBD::ODBC are OK.)
> 
> Environment:
>     WinNT4 + ActivePerl 5.6 + Oracle8 + DBD::Oracle v1.03
> 
> #!perl -w
> use strict;
> use diagnostics;
> use DBI;
> 
> my $connect=DBI->connect(
>     'dbi:Oracle:dvwork3','stat','stat',
>     {RaiseError=>0,PrintError=>0}
> ) or die 'connect failed';    # use a valid connection string to test
> 
> # do nothing, this is the end of testing script
> 
> Error message is:
> 
> (in cleanup) Uncaught exception from user code:
> Can't call method "FETCH" on an undefined value
> at D:/Perl/site/lib/Win32/TieRegistry.pm line 1486
> during global destruction.
> Win32::TieRegistry::DESTROY('Win32::TieRegistry=HASH(0x9307668)')
> called at C:\DBIinsert.pl line 0
> require 0 called at C:\DBIinsert.pl line 0
> 
> Require 0 called at line 0?  How come?
> 
> John Lin
> 
> P.S.  Currently, to avoid the last error message, I use
> 
> END { $^W=0 }
> 
> It works because the message shows up only when -w is active.

What does it do if you leave out the 'use diagnostics' ?  Also I dont
see where you use or require Win32::TieRegistry - it would surprise
me if DBD::Oracle is using this as it should be the responsibility of
the client libraries to find what they want from the registry.  I dont
have the code of DBD::Oracle here to have a look at.

/J\
-- 
One should never listen. To listen is a sign of indifference to one's
hearers.
-- 
fortune oscar homer


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

Date: Sat, 6 May 2000 21:29:42 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Flame my code
Message-Id: <8f1vak$4u$1@neptunium.btinternet.com>

Hey,

Here's the way that I'd do it:

--
foreach $file (@files) {
  if (!grep(/$file/, @new_files)) {
    push(@new_files, $file);
  }
}
--

The array containing the list of files is called @files, and the new array
containing the new list of unique file names is called @new_files.

btw. Stay away from code generators - learn the damn language yourself  :o)


Thanks, Andy.
andy@u2me3.com




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

Date: Sat, 6 May 2000 21:56:34 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: Flame my code
Message-Id: <8f210j$42g$1@plutonium.btinternet.com>

Hey,

Using a hash is unnecessary ... although it does work, it requires much more
memory, and takes longer to execute.

btw. If you do require the array of files to be sorted, then the following
code would work:

--
foreach $file (@files) {
  if (!grep(/$file/, @new_files)) {
    push(@new_files, $file);
  }
}

@new_files = sort(@new_files);
--


Thanks, Andy.
andy@u2me3.com




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

Date: 08 May 2000 21:08:29 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Flame my code
Message-Id: <87r9bc4grm.fsf@shleppie.uh.edu>

>> On Sat, 6 May 2000 21:29:42 +0100,
>> "Andy Chantrill" <andy@u2me3.com> said:

> Hey, Here's the way that I'd do it:

[ erk, auto-format got at it ]

> -- foreach $file (@files) { if (!grep(/$file/,
> @new_files)) { push(@new_files, $file); } } --

Hmmm, this looks like it invokes a linear sweep of
@new_files on each iteration (grep).  That could be bad
for big arrays.

Using a hash to record the existence of already-seen
elements should get rid of the array enumeration and
replace it with a constant-time lookup.

[ untested ]

my %seen;
for (@files) {
  next if $seen{$_};               # had this one before
  $seen{$_} = 1;                   # mark new one as seen now ...
  push @new_files, $_;             # ... and record it
}

hth
t

PS BTW Andy, I know this is the 2nd article of your I've
replied to in short order.  I'm not trying to dump on you,
we're just here at the same time :-)


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

Date: 6 May 2000 22:35:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Flame my code
Message-Id: <8f237g$hh1$1@orpheus.gellyfish.com>

On Sat, 06 May 2000 19:09:58 +0100 Dave Cross wrote:
> On Sat, 6 May 2000 13:24:18 -0400, "E. Preble" <preble@ipass.net>
> wrote:
> 
>>I have a code snippet below.  Can it be better? (of course
>>it can)
>>
>>purpose:
>>Search a list of names in a array and create a new array
>>with unique names only.
>>For Example, if the array is:
>>file1.txt
>>file2.txt
>>file2.txt
>>file3.txt
>>file2.txt
>>
>>The new array will have:
>>file1.txt
>>file2.txt
>>file3.txt
>>
>>with NO duplicate entries of file2.txt. Here's my code
>>(written in PerlAmateur v1.0):
>>
>>foreach $FileName (@File) {
>>  $found = 0;
>>  foreach $Entry (@ListOfFileNames) {
>>   if ($FileName eq $Entry) {
>>    $found=1;
>>   }
>>  }
>>  if ($found == 0) {
>>   @ListOfFileNames = (@ListOfFileNames, "$FileName");
>>  }
>>}
> 
> You probably want to turn your original list into a hash like this:
> 
> my %ListofFileNames;
> @UniqueFiles{@File} = (1) x @Files;
> 
> and then the unique file names are the key of this hash:
> 
> my @ListOfFileNames = keys %UniqueFiles;
> 

Just 'cause you been on the piss with the 'Friends of Ken' since thursday
night doesnt mean you can post any old stuff you know ;-}

I think you had some typos in there.

my %UniqueFiles;

@UniqueFiles{@File} = (1) x @File;

my ListOfFileNames = keys %UniqueFiles;


I think Uri has an essay on hash slices on his site.

/J\
-- 
Solid waste! I could kiss you! Bleh! ew! Yeech! Ooh! I think this
was pizza!
-- 
fortune oscar homer


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

Date: Tue, 09 May 2000 02:54:16 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Flame my code
Message-Id: <x7u2g8v3fs.fsf@home.sysarch.com>

>>>>> "AC" == Andy Chantrill <andy@u2me3.com> writes:

  AC> Using a hash is unnecessary ... although it does work, it requires
  AC> much more memory, and takes longer to execute.

huh? where did that last statement come from? it depends on the size of
the array. for anything but the shortest arrays, a hash lookup blows
away a grep through an array. i won't even benchmark it for you. do it
yorusefl and learn something about hashes and arrays and speed.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 6 May 2000 12:54:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: get the mails from the inbox in unix
Message-Id: <8f115o$4hv$1@orpheus.gellyfish.com>

On Thu, 04 May 2000 07:22:19 GMT k_ahg@my-deja.com wrote:
> hi,
> 
>   I'm actually trying to write a perl program to grep certain mails in
> my inbox in unix to do some processing.Is it possible to do that can
> anybody help me.
> 

You have been shown methods of going straight to the mailbox file, but I
suppose for completeness we should have an example using the Mail::*
modules from the mailtools package from CPAN :


#!/usr/bin/perl -w

use strict;

use Mail::Util qw(read_mbox);
use Mail::Internet;
use Mail::Header;

my $mess_list = read_mbox('/var/spool/mail/gellyfish') || die "Aieee\n";


foreach my $message (@{$mess_list} )
{
   my $mail = Mail::Internet->new($message);

   my $head = $mail->head; # A Mail::Header;

   
   print "Mail from : ",$head->get('From'),
         " Subject : ", $head->get('Subject'),"\n";

   # You could of course test the 'From' and 'Subject' headers
   # to determine if you want to read the body.

   foreach my $body_line (@{$mail->body})
    {
      # do something with each line of the message

      print $body_line;

    }
}


I'm sure I have posted that before though.

/J\
-- 
Oh no! What have I done? I smashed open my little boy's piggy bank,
and for what? A few measly cents, not even enough to buy one beer. Wait
a minute, lemme count and make sure...not even close.
-- 
fortune oscar homer


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

Date: 6 May 2000 13:51:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: global variable with perl-cgi scripts ?
Message-Id: <8f14h1$f4u$1@orpheus.gellyfish.com>

On Fri, 5 May 2000 22:09:19 +0200 Ed Bras wrote:
> Tina Mueller <tina@streetmail.com> wrote in message
> news:8enjf2$9ebfv$1@fu-berlin.de...
>> Ed Bras wrote:
>> >
>> > Helllu, can someone tell me a good way to define your global
>> > variables, such that they still exists when the perl-cgi-script is
>> > called again ?  (without using any perl-apache module).
>> >
>> > For example would it be possible to include a package with variables
>> > defined, such that the variables in the packet still exist after
>> > the script finish running ?
>>
>> just store the values in a file.  you can easily do that with the
>> Tie modules, such as Tie::Hash for example.
>>
> 
> It's a good idea, thanks, but what about session depend variables ?
> That is that one person can change the variable value of another
> when they both have web connection with the same page. Do you have
> a solution for that ? 
> 

Sure.  You create some kind of session ID and use that to identify the
files in which the 'session variables' are stored.  You can have that
session ID passed in cookies, hidden fields, 'funny URLs' or whatever.

You will however want to ask any further questions about this in the
group comp.infosystems.www.authoring.cgi as this is about the general
design of CGI applications rather than about Perl specifically.

/J\
-- 
Relax. What is mind? No matter. What is matter? Never mind!
-- 
fortune oscar homer


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

Date: 08 May 2000 20:54:03 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: goto function
Message-Id: <87u2g84hfo.fsf@shleppie.uh.edu>

>> On Sat, 6 May 2000 16:38:25 +0100,
>> "Andy Chantrill" <andy@u2me3.com> said:

> Hey, Anybody know of a way I can use the goto function
> (or something similar, if it exists?) to hop out of one
> sub-routine, and into another?

Goto?  <blackadder>Wicked child!</blackadder>

There's usually a better way of doing things that goto has
traditionally been used for.  "perldoc -f goto" has some
suggestions, such as eval/die.  Perhaps if you elucidate
on the actual thing you're trying to do people here could
come up with some suggestions about the best way(s) of
tackling it.  This might be more fruitful in the long run.

Are you related to this guy? :-)

  http://www.userfriendly.org/cartoons/archives/00may/20000506.html

hth
t


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

Date: 9 May 2000 02:01:20 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: goto function
Message-Id: <8f7rhg$i4h$0@216.155.33.112>

In article <8f1e9o$jvn$1@plutonium.btinternet.com>, "Andy Chantrill" 
<andy@u2me3.com> wrote:

 | Hey,
 | 
 | Anybody know of a way I can use the goto function (or something similar, 
 | if it exists?) to hop out of one sub-routine, and into another?

From "Programming Perl" :

    p. 538 "Avoid *goto*. It scans outward from your current location 
for the indicated label."

    p. 106 also mentions "The *goto &name* form is highly magical, and 
quoe different from an ordinary goto. It substitutes a call to the named 
subroutine for the currently running subroutine. This is used by 
AUTOLOAD subroutines that wish to load another subroutine and then 
pretend that the other subroutine had been called in the first place. 
After the goto, not even *caller* will be able to tell that this routine 
was called first."

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 6 May 2000 22:46:05 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: goto function
Message-Id: <8f23qt$jes$1@orpheus.gellyfish.com>

On Sat, 6 May 2000 16:38:25 +0100 Andy Chantrill wrote:
> Hey,
> 
> Anybody know of a way I can use the goto function (or something similar, if
> it exists?) to hop out of one sub-routine, and into another?
> 

As it says in the perldoc manpage you may use it jump *out* of a subroutine
but not *into* one.  You might want to find a better way to present your
logic anyway.

/J\
-- 
I guess the juice business is more important than the ideals our hippie
forefathers refused to go to war and die for.
-- 
fortune oscar homer


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

Date: Tue, 09 May 2000 03:47:48 GMT
From: fgerik@my-deja.com
Subject: grep sender address from mail log
Message-Id: <8f81p0$t9t$1@nnrp1.deja.com>

Hi,
I'm new to perl and am trying to grep sender's address from sendmail
maillog.
How do I grep sender's address (sender@foo.com) from within the < and >
for example "from=<sender@foo.com>"
Is there a web site about processing sendmail log with perl ?

--fg


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 8 May 2000 19:27:59 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Hang on uploading a file
Message-Id: <Pine.GSO.4.10.10005081915300.3921-100000@user2.teleport.com>

On Mon, 8 May 2000 siust@my-deja.com wrote:

> #!/opt/local/bin/perl5

Fix your program to use -w and 'use strict'. That won't necessarily fix
all of your bugs, but it'll convince folks around here that you're trying.

> use CGI qw(:standard);
> 
> my $cgi = new CGI;

If you import :standard (as you should), there's no reason to use the
Obscurely-Operated mode. So, you can drop all of those '$cgi->' things
throughout the code, and good riddance. (Not that you should necessarily
re-type it all; a good programmers' editor should help, or you could leave
the program alone, and simply use this technique as you write new code.)

>   if (!$file) {
>       exit(0);
>   }

You could exit a little more gracefully; many webservers (and browsers)
would be surprised to get no data at all. Why not a short plain text
message?

>   $filename = "../docs/" . $cgi->param(whichday) . ".doc";
>   unlink $filename;

The CGI spec doesn't specify which directory will be the current working
directory when a CGI program is started.

    http://hoohoo.ncsa.uiuc.edu/cgi/

It may be the root directory, the server's working directory, the home
directory for user nobody, the home directory for root, the directory the
program is stored in, the directory the server is stored in, the base
cgi-bin directory, the /tmp directory, a directory you don't have access
to from the shell, a directory named after an annoying character from
Saturday Night Live, a directory chosen at random, or some other
directory.

A CGI program which uses a relative path before chdir()ing to a
non-relative path is in a state of sin.

>   open(LOCAL, ">".$filename) or die $!;

Eek! Security hole: You've used unchecked data to decide which file to
write. You could be wiping out any program you're allowed to write to! You
could be writing anything to any directory you're allowed to write to!  
Disable this program until you've fixed that. Hint: Turn on taint
checking, by putting -T on the first line (along with -w), and start
reading the perlsec manpage.

>   chmod 777, $filename;

Eek again! Remember that file you just wrote, filled with who-knows-what
and stored who-knows-where? You just told your system that it's a program.
What if that were a malicious program? If you're running this code, you're
now WIDE OPEN to anyone in the world installing their own software on your
system. Run, don't walk, to turn this off. Now!

A note to knowledgeable folks: Yes, if the webserver is properly
configured, even this shouldn't open a major hole. But if the admin
permitted this program to be installed with such a hole, I doubt that the
admin is making sure that the server is properly configured.

Good luck: I hope you get to it before someone else does.

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 09 May 2000 03:40:36 GMT
From: siust@my-deja.com
Subject: Re: Hang on uploading a file
Message-Id: <8f81bh$snm$1@nnrp1.deja.com>

Thanks for pointing out various mistakes but the main question still
remains.

Everytime I try submiting any form with <INPUT TYPE=FILE,..> along with
a valid non-existing filename, the CGI script will hang indefinitely.





Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 9 May 2000 03:07:16 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: help on code. thanks a lot.
Message-Id: <8f7vd4$r97$1@newsflash.concordia.ca>

In article <21IR4.55236$WF.3044581@bgtnsc04-news.ops.worldnet.att.net>,
RC <hmmidi@geocities.com> wrote:
>Helo Perl People.
>I am one of the new perl learners out there.
>I have been writing some new perl code and I come with a unsolved problems.
>After doing some brain storming I could not find a way to solve it. 
                  ^^^^^^^^^^^^^^

Your code doesn't even compile! I assume you retyped it (?!)

>foreach ($a, $b; $a < 10; $a+) {
          ^^^^^^           ^^^
what's this supposed to do?  And I assume you meant $a++ ?


>$variableone .= "<html><title>Libr</title><body>";

That's a really strange variable name, BTW...  what's wrong with $var1 ?

Furthermore you did not make $var1 lexical to the block. That's a
fancy way of just saying that $var1 hangs around longer than you want it.
  
So each time you pass through the loop $var1, you are concatenating
to the original contents of $var1 with the .= operator, and it gets
bigger and bigger.

fix:   

for my $a (0..9) {
   my $var1;
   $var1 = "blah blah";

# etc.

}

See <http://www.plover.com/~mjd/perl/FAQs/Namespaces.html> for more.

>open (variableone,">$pathroot/$filename");

You of course meant to write,  

open VARIABLEONE, ">$pathroot/$filename" 
	or die "Can't open $pathroot/$filename -- $!";



>print vaariableone $variableone;
         ^
This is the source of one problem. Had you used #!/usr/bin/perl -w 
as your shebang line, perl would have caught the error. 

The error messages are usually self-explanatory. When they aren't 
see man perldiag.


>I am thinking of making the value of variableone to be easily modified.
>therefore I try putting the hypertext code in something.txt file which I
>could easlily modify through a form., next I do an open file of the text
>file something.txt and have them between the perentheses. What happen was
>that the variable $a was not interpreted by perl. instead $a was printed
>out. hmm..anyone could suggest an idea. thanks a lot.

I'm afraid I don't understand what you wanted. Perhaps you were trying
to write to several different files? The name "$filename" did not change
in your example.




-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: Tue, 09 May 2000 03:14:47 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: help on code. thanks a lot.
Message-Id: <391781B4.F48A69B1@rochester.rr.com>

RC wrote:
 ...
> foreach ($a, $b; $a < 10; $a+) {
           ^^^^^^           ^^^
$a,$b doesn't do anything   You probably mean $a++
> $variableone .= "<html><title>Libr</title><body>";
> $variableone .= "<b>$a</b><br>";
Because $a was never set to anything (because of the two mistakes
above), $a is still undef here.  It *is* being substituted, however.
> $variableone .= "<b>book list</b>";
> $variableone .= "</body></html>";
> open (variableone,">$pathroot/$filename");
It is OK but leaning toward obfuscation to use the same name for a
filehandle as you used for a variable; in addition, it is conventional
to use uppercase for filehandles.  Also, you should always add something
like:

      or die("Oops, $!\n");

to your open statements.
> print vaariableone $variableone;
        ^^^^^^^^^^^^
misspelled
> close (variableone);
> }
Note that using the -w switch and use strict; would have caught at least
a couple of the above for you.
 ...
-- 
Bob Walton


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

Date: 6 May 2000 18:24:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help! how to delete file?
Message-Id: <8f1kga$2jv$1@orpheus.gellyfish.com>

On Wed, 3 May 2000 23:10:09 -0700 Larry Rosler wrote:
> In article <slrn8h1kcb.177.tadmc@magna.metronet.com> on Wed, 3 May 2000 
> 21:25:31 -0400, Tad McClellan <tadmc@metronet.com> says...
>> On Wed, 03 May 2000 17:03:16 -0700, james archer <snowphoton@mindspring.com> wrote:
>> >perl is great, but sometimes a little to creative when naming things :o)
>> >
>> >somehow i think "erase" or "delete" or "rm" might have been nice...hehehe
>> 
>> Except that unlink() does NOT "erase", "delete", nor "rm" (remove)
>> the file.
> 
> ... on Unix.
> 

Hey ! it could have been called 'kill' on some other OS then we might have
had the generally accepted 'raise' for sending signals ;-}

/J\
-- 
You can't keep blaming yourself. Just blame yourself once, and move on.
-- 
fortune oscar homer


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

Date: 7 May 2000 01:36:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Help:  How to Delete Problem Files on Multiple Disk Partitions?
Message-Id: <8f2dq4$jne$1@orpheus.gellyfish.com>

On Sat, 6 May 2000 10:17:06 -0400 JP wrote:
> Our company has been badly invaded by the Love-Letter virus over the past
> few days.  Now the virus has been stopped but is a time for cleaning up the
> clients' workstations.
> 
> I would like to write a Perl script to:
> 
> 1.  recursively look into the different partitions of the client's hard
> drives
> 2.  identify the infected files by file extension, size and date
> 3.  delete those files
> 
> I know how to check the files in a specific directory but I don't know how I
> can do a recursive check from the root and also go into the different
> partitions.  Please give me some guidance.  Thanks in advance
> 

You might do something like :

#!/usr/bin/perl -w

use strict;

use File::Find;

my @parts = qw(c:/ d:/ p:/ s:/);

find(\&wanted,@parts);

sub wanted
{

   if (  /\.vbs$/i )
   {
      open( FILE,$File::Find::name)   
                    || die "Cant opem $File::Find::name - $!\n" ;
      my $file = do { local $/, <FILE> };
      close FILE;
      if ( $file =~ /loveletter/ )
      {

         unlink $File::Find::name or die "$File::Find::name - $!\n";
      }
  }
  elsif ( /WinFAT32.exe/i || /WIN-BUGSFIX.exe/i)
  {
    unlink $File::Find::name or die "$File::Find::name - $!\n"
  }
}

But this doesnt fix your registry or unhide your MP3 files.  You might
want to check in the group alt.comp.virus where several (unfortunately
VBScript) programs have been posted that sort all of this out.  We only
had four machines get hit with it so we just reinstalled the machines
and deleted all the .vbs files from the network drives.

/J\
-- 
Good drink... good meat... good God, let's eat!
-- 
fortune oscar homer


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

Date: 7 May 2000 02:33:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I install perl modules under Windows ?
Message-Id: <8f2h5o$uj7$1@orpheus.gellyfish.com>

On Thu, 04 May 2000 12:02:20 +0200 Francois Dupradeau wrote:
> Hello !
> 
> I made a perl script under Linux and now I'd like to run it under
> Windows NT. The problem is I must install some modules (HotKey.pm and
> ANSIColor.pm). I can't install these modules because I can't do a make
> and make install.
> Can I can install these modules ? How ?
> Can you give me an URL where I can download executables modules under
> Windows ?
> 

HotKey.pm is *not* on CPAN its full code is in the FAQ you should copy
it to a file HotKey.pm in @INC somewhere.  As you have asked about
Term::ANSIColor subsequently I would assume you have discovered that it is
part of the 5.6.0 distribution ...

/J\
-- 
Well, you can't go wrong with cocktail weenies. They taste as good as they
look. And they come in this delicious red sauce. It looks like catsup-
it tastes like catsup. But brother, it ain't catsup!
-- 
fortune oscar homer


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 2985
**************************************


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