[10659] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4251 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 18 21:07:26 1998

Date: Wed, 18 Nov 98 18:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 18 Nov 1998     Volume: 8 Number: 4251

Today's topics:
    Re: attaching a jpeg <gellyfish@btinternet.com>
        Bareword? bigcheese@my-dejanews.com
    Re: delete/modify DBM <rootbeer@teleport.com>
        Experts: How to use setvbuf (Dov)
    Re: Experts: How to use setvbuf (Charles DeRykus)
    Re: help ftp yesterdays files - file testing? (Martien Verbruggen)
    Re: help ftp yesterdays files - file testing? (Martien Verbruggen)
        Help! How to use m// with scalars containing backslashe <marvuo@batman.jytol.fi>
    Re: Help! How to use m// with scalars containing backsl (Sam Holden)
    Re: hiding a URL <rootbeer@teleport.com>
    Re: Need wlib to install Perl <gellyfish@btinternet.com>
        Perl para windows 95 <zejeske@zaz.com.br>
    Re: Perl Usage Survey - interpretations, anyone? <eashton@bbnplanet.com>
    Re: Perl Usage Survey - interpretations, anyone? (Adam Turoff)
    Re: Perl Usage Survey - interpretations, anyone? (Michael Rubenstein)
    Re: Perl_for_Win32_FAQ (Martien Verbruggen)
        PerlScript-Cookies??? rohan666@my-dejanews.com
        Please Help! reg expression (David Wee)
    Re: Please Help! reg expression (Sam Holden)
        Problems with A Perl Script <jfunston@connect.ab.ca>
    Re: Q: bulk-assign associative array? <chrisre@ecpi.com>
    Re: Reading Directories w/ Perl (Dave)
    Re: Reading Directories w/ Perl <uri@fastengines.com>
    Re: Send Attachment by Perl CGI <mosheb@duridium.com>
    Re: Send Attachment by Perl CGI (Martien Verbruggen)
        Setting a timer <abeyoshida@btmedia.btco>
    Re: Setting a timer (Erik)
    Re: Setting a timer <rootbeer@teleport.com>
    Re: Two-Part RE question <trikiw@hotmail.com>
    Re: Two-Part RE question <nospam.perl_rocks@hotmail.com>
    Re: Win32 executing a .pl or .cgi <dlsilvia_remove_to_reply_@mediaone.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 18 Nov 1998 22:56:58 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: attaching a jpeg
Message-Id: <72vjbq$uo$1@gellyfish.btinternet.com>

On Tue, 17 Nov 1998 17:14:48 +0000 Gareth Ennis <gary.ennis@strath.ac.uk> wrote:
> Martien Verbruggen wrote:
>  
>> - Never pass strings to a shell unless you know absolutely certain
>>   that there's no problematic character in them.
>> 
>> In the case of sendmail, you just call it with the -t flag. ....
> 
> 
> Thanks for all the advice guys.... ive since changed my scripts to use
> 'sendmail' with the -t flag.....
> 
> Is this really That much safer????
> 

Sure, unless of course someone is able to exploit some security bug in 
some version of sendmail by passing a string whose nature could allow
them unwanted access to your server - but of course one should be using
a version of sendmail in which such a bug if it was known about would
have been fixed ;-}

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Thu, 19 Nov 1998 00:11:09 GMT
From: bigcheese@my-dejanews.com
Subject: Bareword?
Message-Id: <72vnmf$1uu$1@nnrp1.dejanews.com>

What is a Bareword?

"Bareword found where operator expected at line 39"

line 39:
			if ($hd eq "1") {
				$base = "<IMG SRC=k/k1/";


Thanks,
-Dan

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 18 Nov 1998 23:10:17 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: delete/modify DBM
Message-Id: <Pine.GSO.4.02A.9811181508170.27321-100000@user2.teleport.com>

On Thu, 19 Nov 1998, Chris Clark wrote:

> # deleteItem
> 
> sub deleteItem {
> 
>  $database = "mydbm.dbm";
>  dbmopen (%contents, $database, 0700);

Like open(), it's good to check the return value from dbmopen() for
errors. (And do you really want 0700 there? I wouldn't....)

>  $FORM{'newsitem'};

What does this statement do for you? What do you think it does? Have you
turned on warnings in your program?

Hope this helps!

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



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

Date: Wed, 18 Nov 1998 17:58:41 -0400
From: dov1@drive.net (Dov)
Subject: Experts: How to use setvbuf
Message-Id: <dov1-1811981758410001@205.184.111.253>

We are trying to use setvbuf on STDOUT so that we can capture output
before its printed (we do not want to change PRINT or use IO:stringy as
both are not suitable for the end solution).  

We received a few suggestions, with the best one using IO:Handle, but they
did not work on two different setups (SunOS, and MacOS - which does not
seem to support setvbuf at all...).

The idea is to modify the manner in which STDOUT buffers so that we can
capture output into a new buffer - into a scalar of some sort, and when
all PRINTs are completed process the buffer for other purposes.

If you can help, it will be much appreciated.


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

Date: Thu, 19 Nov 1998 01:11:53 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Experts: How to use setvbuf
Message-Id: <F2n9zt.ED5@news.boeing.com>

In article <dov1-1811981758410001@205.184.111.253>, Dov <dov1@drive.net> wrote:
>We are trying to use setvbuf on STDOUT so that we can capture output
>before its printed (we do not want to change PRINT or use IO:stringy as
>both are not suitable for the end solution).  
>
>We received a few suggestions, with the best one using IO:Handle, but they
>did not work on two different setups (SunOS, and MacOS - which does not
>seem to support setvbuf at all...).
>
>The idea is to modify the manner in which STDOUT buffers so that we can
>capture output into a new buffer - into a scalar of some sort, and when
>all PRINTs are completed process the buffer for other purposes.
>

I'm not sure about MacOS but would TIEHANDLE work..., e.g.,
 
use MyStdout;
tie *STDOUT, 'MyStdout';
print "foo...\n"; print "bar...\n";
untie *STDOUT;
 ...
__END__


package MyStdout;
sub TIEHANDLE {
  my $class = shift;
  return bless [] => $class;
}
sub PRINT {
  my $self = shift;
  my $output = shift;
  push @$self, $output ;
}

sub DESTROY {
   my $self = shift;
   for (@$self) {
      ....  # process buffer,  
   }
}
1;
__END__


hth,
--
Charles DeRykus


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

Date: Wed, 18 Nov 1998 23:36:45 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: help ftp yesterdays files - file testing?
Message-Id: <hSI42.42$yI1.189@nsw.nnrp.telstra.net>

[When you send a CC to a poster, please say so in the body of the
message. Otherwise the receiver of the email will not know that the
message was also posted.]

In article <3651CE2E.1A7D@datamail.co.nz>,
	Arran Price <arranp@datamail.co.nz> writes:

> Martien,
> 
> I looked at -M first but couldnt work out how to use it on an array or
> string.  When I posted to the newsgroups I was pointed at the date
> functions in cpan.
> 
> How do you use the file test on something that isnt a file?

Sorry, my booboo. I thought you were looking at a local directory, but
you're actually looking at a listing of some remote FTP server, right?

> $A="-rw-r--r--   1 arranp   staff      16625 Oct 15 14:07 uucp_intro.man";
> when I tried to do the test it tends to look for a file called the above
> rather than testing the contents of the string.

All I can advise for the above is to strip out the date part of the
file (using a regex, most likely), and parsing that with the
Date::Parse module (str2time). Compare its output with the output of
time(). The times should both be in seconds since epoch.

Of course, if the remote machine is in a different time zone, you may
have to correct for that, and str2time allows you to do that nicely.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Hi, Dave here, what's the root
Commercial Dynamics Pty. Ltd.       | password?
NSW, Australia                      | 


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

Date: Thu, 19 Nov 1998 00:14:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: help ftp yesterdays files - file testing?
Message-Id: <WpJ42.48$yI1.189@nsw.nnrp.telstra.net>

Just as an extra comment:

If you use Net::FTP to access your remote machine, which according to
your code, you are doing, then you can use the Net::FTP::mdtm() method
to get the modification time of a file.

I am not sure what format that will be in, but it's likely to be
seconds since epoch. If not, you can always still use Date::Parse to
convert it.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: 18 Nov 1998 10:00:37 GMT
From: "markus.vuori" <marvuo@batman.jytol.fi>
Subject: Help! How to use m// with scalars containing backslashes...?
Message-Id: <72u5s5$h7f$4@mordred.cc.jyu.fi>

Case:

# I'd like write a CGI-script which checks whether
# one path contains another. OS is Win NT 4.0.

$p = "subdir1\\subdir2\\subdir3\\";
$q = "subdir2\\subdir3\\";

$p = quotemeta $p;
$q = quotemeta $q;

if ($p =~ /$q/) {
   print "This works!\n";
}

Question:

 .. why doesn't it print anything?


-- 
   ////////////////////////////////////////
  ///      Markus Vuori, student       ///
 /// Information tech, JyTol, Finland ///
////////////////////////////////////////


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

Date: 19 Nov 1998 01:20:56 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Help! How to use m// with scalars containing backslashes...?
Message-Id: <slrn756sjo.351.sholden@pgrad.cs.usyd.edu.au>

On 18 Nov 1998 10:00:37 GMT, markus.vuori <marvuo@batman.jytol.fi> wrote:

>$p = "subdir1\\subdir2\\subdir3\\";
>$q = "subdir2\\subdir3\\";
>
>$p = quotemeta $p;
 ^^^^^^^^^^^^^^^^^
You don't want to quotemeta this since you aren't using it as a regular
expression... since quotemeta will change it, it won't match anymore...

Add a print $p afterwards to see what I mean (it will escape all the
\s since they are special to the regex...)

>$q = quotemeta $q;
>
>if ($p =~ /$q/) {
>   print "This works!\n";
>}


-- 
Sam

People get annoyed when you try to debug them.
	--Larry Wall


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

Date: Wed, 18 Nov 1998 23:14:01 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: hiding a URL
Message-Id: <Pine.GSO.4.02A.9811181512340.27321-100000@user2.teleport.com>

On Wed, 18 Nov 1998, Gord Barentsen wrote:

> Is there any way to cause the browser to hide the URL of a
> (protected/secure) web page, thus causing the browser NOT to display
> it in the LOCATION field?  Or at least to scramble/encrypt it so that
> it could not be bookmarked/copied?

It sounds as if you want a browser to do something; maybe the docs, FAQs,
and newsgroups about browsers could help. But if a browser can make a
request, it's not hard to find out what that request was. Hope this helps!

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



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

Date: 18 Nov 1998 21:12:56 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Need wlib to install Perl
Message-Id: <72vd8o$ug$1@gellyfish.btinternet.com>

On 09 Nov 1998 00:47:52 GMT mikane@shell3.ba.best.com wrote:
> During the make process for perl5.005_02 I get the
> error message that "wlib" is not found.
> 
> I have learned that wlib is the Watcom Library Manager.
> Does anyone know where I get the source/binary for Solaris/x86?
> 

As far as I know the Watcom compiler is not available on Solaris - this
may be some completely differerent program.

However I would be *very* interested if anyone had succesfully built
Perl with Watcom C (on Win32) - I just havent got the time to sort it out
for myself for the moment.

/J\
-- 
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>


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

Date: Wed, 18 Nov 1998 23:25:47 -0200
From: "Josi Carlos Jeske" <zejeske@zaz.com.br>
Subject: Perl para windows 95
Message-Id: <72vrg2$ii8$1@srv4-poa.nutecnet.com.br>

Onde posso conseguir perl para windows 95




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

Date: Wed, 18 Nov 1998 23:29:44 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <365355C3.C5B19A21@bbnplanet.com>

James wrote:

> Having the 24x7 staff is not failsafe either.
> The bitter sysadmin syndrome pervades the industry.
> The job market is soft.

Nothing makes a site 100% 'failsafe' as there are so many points of
potential failure that even with redundancy it is likely that some
downtime will be experienced. This is where expertise and experience in
site architecture and planning are most valuable. Also, knowing when to
put the smack down on the customer for writing bad perl cgis that kill
the site. SAs are not technically bitter these days, just overworked and
tired of abusive clients who aren't technically skilled passing blame to
them because the servers problem couldn't possibly be their fault. You
get worn down, burnt out and pissy when you are in a 24x7 production
environment and are paged all the time for a high maint client demanding
that you fix their problems pronto at 3am. Perl is both a blessing and a
curse.

> Maybe they're 'underpaying' then?  Are you implying that somebody more
> expensive, such as (ahem, http://www.conservatory.com/resume.public.html)
> *me*, might do a better job for them, playing nethack instead of doom, and
> answering the cell phone *every* time, solving the problem *the first time*
> (every time), and not setting up the open relay in the first place?

Well, by definition, mom&pop shops don't have cash to burn and may not
even know where to go for technical resources. Price doesn't always
ensure quality and would they recognise experienced personnel from the
poseurs? Probably not. 

e.

After all, the cultivated person's first duty is to
always be prepared to rewrite the encyclopedia.  - U. Eco -


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

Date: 18 Nov 1998 19:28:35 -0500
From: ziggy@panix.com (Adam Turoff)
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <72vonj$7km@panix.com>

James  <fishbowl+mail@hosting.netcom.com> wrote:
>In article <72t423$42v@panix.com>, Adam Turoff <ziggy@panix.com> wrote:
>>And there's no way a mom&pop who just want to get their job done would 
>>know the first thing about accidentally acting as an anonomous sendmail
>>redirector because their incompetant admin is overcharging them and playing
>>doom when he's not answering their calls on the red phone.
>
>Maybe they're 'underpaying' then?  

An incompetant admin who plays doom and charges a small shop for 24x7
maintenance but doesn't actually maintain the system is overcharging.

Paying more so that the incompetant admin might lift a finger does not
mean that he was underpaid in the first place.  It means he shouldn't
be in the bidness.

>Are you implying that somebody more
>expensive, such as (ahem, http://www.conservatory.com/resume.public.html)
>*me*, might do a better job for them, playing nethack instead of doom, and
>answering the cell phone *every* time, solving the problem *the first time*
>(every time), and not setting up the open relay in the first place?

I'm implying that paying for no service is overpaying.  Paying the same
amount for someone who actively maintains a system and prevents downtime
or someone who can fix a broken system very quickly whenever there is a 
problem is better than paying a cluebie to pocket a monetary sacrifice 
to The Internet Cabal just to get email on site.

As for nethack vs. doom, the timesink doesn't matter.

>>Sounds like a new class of ISP service - connectivity and such, no questions
>>asked; lease the server and pay the monthly bandwidth bill and we'll take
>>care of the rest.  
>
>That's not a new class of ISP service.  I leased exactly that from ANSnet 
>between 1993 and 1995, for the purpose of running an ISP (~3000 dialups).

I seriously doubt the old Bell type of service has ever been offered from
an ISP.  As overworked as SAs and ISPs are these days, I can't imagine
anyone would be offering _more_ handholding.  It actually sounds like
a losing proposition unless it works at the very small or very large scale.

I'm talking about someone like MCI or Sprint (or someone smaller and
more clueful) taking responsibility for getting the bits off the NIC
in your desktop box and getting them to your final destination, much
like AT&T owned everything from the point where you spoke into the phone
until your voice was reconstructed in the other receiver.  When you 
dropped the telephone in the fishbowl, they replaced it because they
owned the phone and you leased it for a monthly fee.

Z.



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

Date: Thu, 19 Nov 1998 01:29:17 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <3654742f.23619082@nntp.ix.netcom.com>

On Wed, 18 Nov 1998 14:15:18 -0500, John Porter <jdporter@min.net>
wrote:

>Adam Turoff wrote:
>> 
>> I may not be well read in anthropology, but I've never read of a case
>> where neanderthals devolved into 'homo microsofticus'.  That would lead
>> me to believe that our fur-clad relatives were more intelligent than
>> your average ntadmin, teenage boy or otherwise.
>
>Actually, there seems to be some speculation among anthropologists
>lately that the neanderthals may have indeed been more intelligent
>than the sapiens who displaced them.  Wish I had a link or two for you...

The missing link? :-)
--
Michael M Rubenstein


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

Date: Wed, 18 Nov 1998 23:16:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl_for_Win32_FAQ
Message-Id: <gzI42.40$yI1.221@nsw.nnrp.telstra.net>

In article <3652CBE2.71280391@technologist.com>,
	Brent Michalski <perlguy@technologist.com> writes:

> It finally worked for me too!  Once I shut of "Style Sheets" everything
> was fine...

I sent a post in this same thread a few days ago, outlining this exact
problem with the newer win32 FAQs. Didn't my messages make it to other
servers than mine? (dejanews has my article).

I am asking, because I see other threads in which I have participated,
and my post seems to have been ignored totally.

I wonder how many killfiles I am in by now :)

Martien
-- 
Martien Verbruggen                  | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au    | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd.       | I can ask him what he meant - Steven
NSW, Australia                      | Wright


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

Date: Thu, 19 Nov 1998 01:39:55 GMT
From: rohan666@my-dejanews.com
Subject: PerlScript-Cookies???
Message-Id: <72vst9$6ar$1@nnrp1.dejanews.com>

I have a problem.... I need to GET users input from a shopping cart web site
done in JavaScript and take their selection to another domain where a secure
server can process the order. I am working on a Perl Script that can redirect
those selected items to another domain, but I have no clue how to correctly
code the PerlScript on grabbing variables from a JavaScript. AAARRRGGGHHH!!!
If you think you have a plan of action, pleeezz let me know... You can see
the site in question at http://www.wholesalerestaurant.com

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 19 Nov 1998 01:20:40 GMT
From: davecw@soda.CSUA.Berkeley.EDU (David Wee)
Subject: Please Help! reg expression
Message-Id: <72vrp8$1rl$1@agate.berkeley.edu>


if i am using a backreference from a previous reg exp ($2 for instance)
to match a new expression , how do i make it match only for the "full
length" of $2?  

here it is.... 
 the first $1    $2
     |            |
     |            |
     \/          \/
if (/^([0-9]+) (.+)\n/) {
	    print ("The first is $1 and the second is $2\n");
		    if ($std_line =~ /$2/i) { 

etc..}
}


To my displeasure, $std_line =~ /$2/i will be a successful match when only
part of $2 is in $std_line

i.e. if $2 = "A B C"
and $std_line = "C" 

i don't want it being matched.

how do i do this?

thank you.

-- 
David Wee
homepage http://www.ocf.berkeley.edu/~davecw


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

Date: 19 Nov 1998 01:26:00 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Please Help! reg expression
Message-Id: <slrn756st8.351.sholden@pgrad.cs.usyd.edu.au>

On 19 Nov 1998 01:20:40 GMT, David Wee <davecw@soda.CSUA.Berkeley.EDU> wrote:
>
>To my displeasure, $std_line =~ /$2/i will be a successful match when only
>part of $2 is in $std_line
>
>i.e. if $2 = "A B C"
>and $std_line = "C" 
>
>i don't want it being matched.

And perl won't match it anyway... So what is the problem????

You might want to remove regex characters from $2. by quotemeta or \Q.


-- 
Sam

PC's are backwards ... throw them out! Linux is ok though.
	--Rob Pike (on the subject of CR/LF etc)


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

Date: Wed, 18 Nov 1998 06:47:43 -0700
From: "Justin Funston" <jfunston@connect.ab.ca>
Subject: Problems with A Perl Script
Message-Id: <36531e63.0@skylite.connect.ab.ca>

Hello,
I am trying to teach myself perl/cgi.
So far, I have tried writing a couple of scripts, but they don't work. I get
an HTTP 500 error. The files are located at
'http://www.connect.ab.ca/~funston/'
The one file: 'variables.html' & the script is 'variables.pl'.
If anyone could look at it, and tell me what I did wrong, that would be
great.

Thanks,
Justin




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

Date: Wed, 18 Nov 1998 19:58:39 -0600
From: "Chris Reickenbacker" <chrisre@ecpi.com>
Subject: Re: Q: bulk-assign associative array?
Message-Id: <72vsec$27p$1@nntp.smartdna.com>


This is the sweet magic...

local(@STAT_RESULTS{dev, ino, mode, nlink,
                        uid, gid, rdev, size,
                        atime, mtime, ctime,
                        blksize, blocks}) = lstat($file);

Hash of file stats using element name as key. You can do this with anything
that returns a list.

Chris Reickenbacker


Apple-O wrote in message <72v177$12t$1@raven.cybercomm.net>...




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

Date: Wed, 18 Nov 1998 23:30:37 GMT
From: david@pdh.com (Dave)
Subject: Re: Reading Directories w/ Perl
Message-Id: <35ac1bff.88459998@gatekeeper>

On Mon, 13 Jul 1998 20:54:21 GMT, marius77@my-dejanews.com wrote:

>I'm stumped on this and I'm sure there is a very easy solution so hopefully
>someone can help me out.  All I need to do is be able to look at a specific
>directory with my script and get all of the filenames within that directory. 
>It doesn't even need to recursively go through the whole directory tree.
>
>I just want to be able to feed it a directory name and get the names of the
>files it contains...that's all.  Any help would be appreciated.  Thanks!!

Here is a subroutine from one of my programs (that runs on Perl for
Win32) that creates a file called $ScriptFileName containing the names
of all of the files in a directory named $OutputDirectoryName:

sub WriteScriptExe
   {
   my ($FileName, $ScriptFileName, $OutputDirectoryName);

   $OutputDirectoryName = ".\Scripts\";

   unless (opendir(DIRECTORY, $OutputDirectoryName))            # Open the directory for reading
      {
      die("Unable to open directory \"$OutputDirectoryName\"\n");
      }

   $ScriptFileName = $OutputDirectoryName . "script_exe.txt";

   unless (open(SCRIPT_FILE, ">$ScriptFileName"))   # Create output file
      {
      die ("Cannot open output file $ClauseFileName!\n");
      }

   while (defined($FileName = readdir(DIRECTORY)))     # Get listing of directory contents
      {
      if (($FileName ne ".") && ($FileName ne ".."))
         {
         print SCRIPT_FILE ("<header> $FileName <middle> $FileName <footer>\n");
         }
      }

   close(SCRIPT_FILE);
   closedir(DIRECTORY);
   }



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

Date: 18 Nov 1998 18:47:18 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: Reading Directories w/ Perl
Message-Id: <sarbtm4d0mx.fsf@camel.fastserv.com>

>>>>> "D" == Dave  <david@pdh.com> writes:


  D> Here is a subroutine from one of my programs (that runs on Perl for
  D> Win32) that creates a file called $ScriptFileName containing the names
  D> of all of the files in a directory named $OutputDirectoryName:

this is a nice little sub with some nice little problems:

  D>    unless (opendir(DIRECTORY, $OutputDirectoryName))
  D>       {
  D>       die("Unable to open directory \"$OutputDirectoryName\"\n");

good for you, you check the result of open.
use alternate quotes to make this readable and use $! so you can know
why the file could not be opened:

	die( "Unable to open directory '$OutputDirectoryName' $!");

a common idiom for the previous if is

	opendir(DIRECTORY, $OutputDirectoryName) ||
		die( "Unable to open directory '$OutputDirectoryName' $!");

i like this style sometimes:

	opendir(DIRECTORY, $OutputDirectoryName) || die <<DIE ;
Unable to open directory '$OutputDirectoryName' $!
DIE


  D>    unless (open(SCRIPT_FILE, ">$ScriptFileName"))   # Create output file
  D>       {
  D>       die ("Cannot open output file $ClauseFileName!\n");
                                         ^^^^^^^^^^^^^^^
that doesn't match the file you tried to open.
and the other comments above apply as well.

  D>    while (defined($FileName = readdir(DIRECTORY)))     # Get listing of directory contents

try to format for 80 columns. it makes your code easier to read,
especially when posting it.

  D>       {
  D>       if (($FileName ne ".") && ($FileName ne ".."))

better as:

	next if $FileName eq '.' || $FileName eq '..' ;

or
	next if $FileName =~ /^\.{1,2}\z/ ;	# perl 5.005

so you don't need a block here:

  D>          {
  D>          print SCRIPT_FILE ("<header> $FileName <middle> $FileName <footer>\n");
  D>          }

hth,

uri

-- 
Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Thu, 19 Nov 1998 01:45:36 +0200
From: Moshe Bar-Nachoom <mosheb@duridium.com>
Subject: Re: Send Attachment by Perl CGI
Message-Id: <36535C20.8E170808@duridium.com>

What you need to do is use mime and create a message with multipart:

open (MAIL, "|$mail_prog $u_e_mail") || die "Could not open $mail_prog";

print MAIL ("From: <sender e-mail>\n");
print MAIL ("Reply-to: ", <reply to  e-mail>, "\n");
print MAIL ("Subject: <mesage subject>\n");
print MAIL "MIME-Version: 1.0\nContent-type: multipart/mixed;
boundary=\"NextPart\"\n";
# Terminate mail headers.
print MAIL "\n";
# Create the document body
# printing required headers
print MAIL "This is a multi-part message in MIME format.\n\n";
print MAIL "--NextPart\n";
print MAIL "Content-Type: text/plain; charset=us-ascii\n";
print MAIL "Content-Transfer-Encoding: 7bit\n";
print MAIL "... this is where you print your message, can wite multiple
lines\n";
print MAIL "--NextPart\n";
print MAIL "Content-Type: text/html\n";
print MAIL "Content-Disposition: inline;
filename=\"personal.html\"\n\n";
print MAIL "... this is where you put your html code\n";
# Close the command, and send the mail.
close (MAIL);
In this example the mail reader distinguishes the two parts of the
message, showing the text mail message and the html file in the reader
and/or as html file.
By changing the content type for any type of data according to your
needs as long as it's mime compliant you can send attachements.
I only did it with html files, so I don't have the complete experience.
Best way for you is to send yourself a message including attachement,
display all the headers and info in the mail reader and copy, paste and
play with your perl code.
Hop this helps...

--
Moshe Bar-Nachoom
[mailto:mosheb@duridium.com] [http://www.duridium.com]
"Power corrupts. Absolute power is kind of neat."
John Lehman, Secretary of the Navy, 1981-1987




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

Date: Wed, 18 Nov 1998 23:51:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Send Attachment by Perl CGI
Message-Id: <N3J42.45$yI1.189@nsw.nnrp.telstra.net>

In article <36535C20.8E170808@duridium.com>,
	Moshe Bar-Nachoom <mosheb@duridium.com> writes:
> What you need to do is use mime and create a message with multipart:
> 
> open (MAIL, "|$mail_prog $u_e_mail") || die "Could not open $mail_prog";

And in case your $u_e_mail contains shell metacharacters you need to
do something different. If This is on a unix box, and $u_e_mail
contains something like ";rm -rf /" you have a possible serious
problem.

There have been many threads in the past about this. I suggest you
look those up on dejanews or something. If your mail program is
sendmail, use the -t flag. If it's something else, do something
equivalent, or make absolutely 100% sure your email address cannot
contain shell metacharacters.

besides that, you may want to have a look at the faq

# perldoc perlfaq8
     Why doesn't open() return an error when a pipe open fails?

> print MAIL ("From: <sender e-mail>\n");
> print MAIL ("Reply-to: ", <reply to  e-mail>, "\n");
> print MAIL ("Subject: <mesage subject>\n");
> print MAIL "MIME-Version: 1.0\nContent-type: multipart/mixed;

All of this is probably easier done with a here-doc string.

# perldoc perldata
[search for here-doc]

And of course, there are modules out there that do all this hard work
for you.

http://www.perl.com/CPAN/modules

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Wed, 18 Nov 1998 18:44:44 -0500
From: Abe Yoshida <abeyoshida@btmedia.btco>
Subject: Setting a timer
Message-Id: <36535BEC.5A3D@earthlink.net>

I have a Perl script that is set to an infinite loop.  It executes
itself and then sleeps.  Is there a way to get my script to recognize
what time it is and then execute when that time arrives?  The structure
of what I presently have is:

$execute = 1;
while ($execute == 1) {
  do this;
  sleep 600;
}

Could I do something like this?

$execute == 1;
while ($execute == 1) {
  if (the time == 13:00){
    do this;	
  }else{
  sleep;
  }
}

What would I use for the if expression "(the time == 13:00)"?
Thanks for any help.
Abe Yoshida


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

Date: 19 Nov 1998 00:00:57 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Setting a timer
Message-Id: <72vn3p$i79$1@news.cyberhighway.net>

In article <36535BEC.5A3D@earthlink.net>,
	Abe Yoshida <abeyoshida@btmedia.btco> writes:
> I have a Perl script that is set to an infinite loop.  It executes
> itself and then sleeps.  Is there a way to get my script to recognize
> what time it is and then execute when that time arrives?  The structure
> of what I presently have is:

Do you have something against just executing it with cron?
Without cron, you might try something like:

use Time::Local;

$execute = 1;
$seconds = timelocal(0,0,18,18,10,98); # 18th of November 1998 at 18:00
while($execute){
	do_stuff;
	$cur = time;
	sleep ($seconds - $cur);
	do_something_else; # Reset seconds to a different value here
}

Or, you can do an infinite while loop that checks the time every time
around, but that seems to me like a waste of CPU cycles if it's only
going to be happening once an hour or so.

perldoc Time::Local, perldoc -f time for more information.

The code above is tested (well, the part about figuring out how long
to sleep is anyway), but is not guaranteed to be elegant or even
desirable in most cases.

-- 
Erik Nielsen, Cyberhighway Internet Services NOC
It might not be practical, it might not be a good idea, but it could work.
Sort of like Windows. 
             -- berry in a.s.r.


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

Date: Thu, 19 Nov 1998 00:05:24 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Setting a timer
Message-Id: <Pine.GSO.4.02A.9811181604310.27321-100000@user2.teleport.com>

On Wed, 18 Nov 1998, Abe Yoshida wrote:

> Is there a way to get my script to recognize what time it is

Yes; see the entry for time() in perlfunc.

> and then execute when that time arrives?  

But maybe you want cron or at; see your system's manpages for those tools.
Hope this helps!

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



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

Date: Wed, 18 Nov 1998 23:55:50 GMT
From: Ricardo Dague <trikiw@hotmail.com>
Subject: Re: Two-Part RE question
Message-Id: <36535E57.FBB5EDAF@hotmail.com>

sara starre wrote:
>   $i1=index($x,"\[");
>   $i2=index($x,"\]");
>   $y =substr($x,$i1+1,$i2-$i1-1);

I'd do something like
	$x =~ /\[.*?\]/;	#now $& == "[man]"
	$y = substr($&,1,-1);

-- Ricardo
"The question of how I am to start the story properly I have
tried to settle in two ways. First, by scratching my head,
which lead to nothing..." -- Wilkie Collins, The Moonstone


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

Date: Wed, 18 Nov 1998 20:23:56 -0500
From: sara starre <nospam.perl_rocks@hotmail.com>
Subject: Re: Two-Part RE question
Message-Id: <3653732C.5C6E3446@hotmail.com>

Uri & Posters:

Quite right, I apologize for overstating my case- obviously there are many helpful
perl wizards here who generously give their advice to newbies like me. I'm more
than greatful for their assistance, and I pledge to behave myself! I still think
some responders could use some manners, but I had no right to globally assault the
entire group when I meant to address them alone.  Rest assured I've been formally
flogged in email...

HUGS,
-S

PS: The solutions were great! It seemed like some posters thought that the ?'s were
needed in the regex, and others didn't. I'll try it both ways and see which I like,
but I may not stumble on the case(s) that ? was designed to prevent.

Uri Guttman wrote:

> >>>>> "ss" == sara starre <nospam.gear4u@hotmail.com> writes:
>
>   ss> OK, this is a two-part question. The first part is only for the
>   ss> perl newsgroup hoseheads who flame everyone who asks a
>   ss> question. Here is your part, put your might brain to work on it
>   ss> and post your solution to alt.whocares:
>
> i noticed you got technical 3 answers, 2 of which are from those
> "hoseheads" you refer too (including me) and one was from a newbie and
> his answer was correct but not well done.
>
> did you thank anyone for the help? did you acknowledge anyone via email?
> were YOU polite in return?
>
> think about it before you post such an asinine message again. we do help
> those who have tried to help themselves. it is being requested to do all
> the work for the poster that is aggravating.
>
> uri
>
> --
> Uri Guttman                  Fast Engines --  The Leader in Fast CGI Technology
> uri@fastengines.com                                  http://www.fastengines.com

--
"I'll quit using PERL when they pry my cold, dead fingers off the mouse.."
-Sara Starre 1998




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

Date: Wed, 18 Nov 1998 20:33:04 -0500
From: "Don Silvia" <dlsilvia_remove_to_reply_@mediaone.net>
Subject: Re: Win32 executing a .pl or .cgi
Message-Id: <IyK42.134$BP.576509@lwnws01.ne.mediaone.net>


Tom McGee wrote in message ...
>I run Website professional on an NT4 box, and I too can't just type the
>name of the scriptr. I have to type "perl myscript.pl" for it to run from
>the command line.
>
I can type "perl myscript.pl" to run a script on NT4, but not on win95,
though I swear I had it working at my last job.  Anyone got this working on
win95?

>But that doesn't stop my server from running cgi properly.
>
Correct. If the server is IIS, check out
http://www.access.digex.net/~jurlwin/

>Your command prompt issue is a red herring. Check your server docs.
>
>--Tom
>

Don Silvia




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4251
**************************************

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