[17198] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4610 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 13 18:05:44 2000

Date: Fri, 13 Oct 2000 15: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: <971474717-v9-i4610@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 13 Oct 2000     Volume: 9 Number: 4610

Today's topics:
        ?? about FormMail <nodntap@rglobal.net>
        [Q] "pass along" in AUTOLOAD ? <kj0@mailcity.com>
        Answer. <nodntap@rglobal.net>
    Re: Answer. <uri@sysarch.com>
    Re: Asyncronous Queue (Logan Shaw)
    Re: Best definition of Perl so far in 19100 <rosie@dozyrosy.plus.com>
        Better Idiom for @_ $_ usage? Roy.Ivy.III@nMail.com
    Re: Better Idiom for @_ $_ usage? (Sean McAfee)
    Re: cgi with perl on Apache-1.3.12-Linux-6.2 - beginner abevec@my-deja.com
    Re: Cookieless operation <brondsem@my-deja.com>
    Re: Cookieless operation <bart.lateur@skynet.be>
    Re: Cookieless operation <brondsem@my-deja.com>
        Delete files from CGI? <awamser@haysmed.com>
    Re: Delete files from CGI? <tony_curtis32@yahoo.com>
    Re: Delete files from CGI? <Darryl.Friesen@usask.ca>
    Re: Giant Array Delay (beginner) (Logan Shaw)
    Re: Giant Array Delay (beginner) <godzilla@stomp.stomp.tokyo>
        Help with backup script jkipp@mbna.com
    Re: Help with backup script <krahnj@acm.org>
        Help! binary files=losing my mind! richardstands@my-deja.com
    Re: Help! binary files=losing my mind! <krahnj@acm.org>
    Re: Help! binary files=losing my mind! <jeff@vpservices.com>
        Ho to encode a CGI value into URL/Unix format. <donv@webimpact.com>
    Re: Ho to encode a CGI value into URL/Unix format. <godzilla@stomp.stomp.tokyo>
    Re: Ho to encode a CGI value into URL/Unix format. <aspina@panix.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Oct 2000 11:15:51 -0000
From: "nodntap" <nodntap@rglobal.net>
Subject: ?? about FormMail
Message-Id: <8s7ivp01das@enews4.newsguy.com>

I have a query.  I run a list on egroups.  My question is does anyone know
how I can email directly to my egroups list using your Matt Wright's
FormMail CGI-Perl program?  I have it up and working fine as long as I'm
having the  mail sent to my email address but no matter what I do I can't
get the mail to go directly to my egroups list.  I have a questionnaire on
my web site I need new people to fill out and have it come to the list and
not directly to me.

I think the problem may be that egroups needs a iserid and password sent
along with the FormMail but I have not clue as to how to do this with the
FormMail program.

Any help or suggestions you might have would be greatly appreciated.

Don S. {The HTML Learning Corner on egroups.}





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

Date: 13 Oct 2000 17:07:51 -0400
From: kj0 <kj0@mailcity.com>
Subject: [Q] "pass along" in AUTOLOAD ?
Message-Id: <8s7tj7$4kr$1@panix3.panix.com>




I'm writing AUTOLOAD in a base class to handle some common methods,
but I want it to pass along (to the superclass, typically UNIVERSAL)
all calls to methods whose names are all-caps (e.g. DESTROY).  How is
that done?

Thanks,
KJ


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

Date: Fri, 13 Oct 2000 12:38:56 -0000
From: "nodntap" <nodntap@rglobal.net>
Subject: Answer.
Message-Id: <8s7nru01jqf@enews4.newsguy.com>

> I have a query.  I run a list on egroups.  My question is does anyone know
> how I can email directly to my egroups list using your Matt Wright's
> FormMail CGI-Perl program?  I have it up and working fine as long as I'm
> having the  mail sent to my email address but no matter what I do I can't
> get the mail to go directly to my egroups list.  I have a questionnaire on
> my web site I need new people to fill out and have it come to the list and
> not directly to me.

Never mind, I got the answer from  Chris Wilson at:
scripts-help@tahoenet.com

Thanks anyway.  If anyone would like to know how to send mail directly
to egroups with Matt Wright's FormMail let me know.

Don






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

Date: Fri, 13 Oct 2000 20:26:02 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Answer.
Message-Id: <x7og0owkrp.fsf@home.sysarch.com>

>>>>> "n" == nodntap  <nodntap@rglobal.net> writes:

  n> Thanks anyway.  If anyone would like to know how to send mail directly
  n> to egroups with Matt Wright's FormMail let me know.

who the hell cares about getting a matt script to work? flushing it to
/dev/null is the best solution.

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: 13 Oct 2000 14:22:40 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Asyncronous Queue
Message-Id: <8s7ne0$nnb$1@muenster.cs.utexas.edu>

In article <x7d7h5xtlx.fsf@home.sysarch.com>,
Uri Guttman  <uri@sysarch.com> wrote:
>Event.pm, POE and (soon) stem, a system i am developing which is network
>application toolkit (see stemsystems.com).
>
>all are much better and higher level than IO::Select.

Thanks.  Those are all useful references.  I'll keep them in mind next
time I try to implement a "do it all at once" daemon like that.

  - Logan


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

Date: Fri, 13 Oct 2000 21:25:30 +0100
From: Rosemary I H Powell <rosie@dozyrosy.plus.com>
Subject: Re: Best definition of Perl so far in 19100
Message-Id: <MPG.14518018d5a6ac509896e8@usenet.plus.net>

In article <brian-ya02408000R0710001723420001@news.panix.com> dated Sat, 
07 Oct 2000 17:23:42 -0400,  our revered colleague brian d foy 
(brian@smithrenaud.com) was so kind as to advise ...

> In article <MPG.144942fa6e1d490b9896e1@usenet.plus.net>, rosie@dozyrosy.plus.com posted:
> 
> > 1) What is CGI?
> > CGI (or Perl) is a specail Internet language that allows you
> > to run 'programs'.....
> 
> The Common Gateway Interface is not a langauge.  it does not
> allow you to run programs.  it only specifies the interface
> between two programs.
> 
> > 2) What is it useful for?
> > Perl is EXTREMELY useful. It's main purpose is to add
> > interactivity to a website.....
> 
> whatever.  very little of Perl's use is for the web even 
> though Perl might be a lot of the web programming out there.
> 
Remind me to post such "Perls of Wisdom" on All Fools Day next time...
Look at the subject again?

Rosemary
-- 
----------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosie@dozyrosy.plus.com    |
|                             Work: r.i.h.powell@rl.ac.uk      |
|                       http://NeedleworkSamplers.com/         |
|                       http://www.CavalierKingCharles.com/    |
----------------------------------------------------------------


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

Date: Fri, 13 Oct 2000 21:23:00 GMT
From: Roy.Ivy.III@nMail.com
Subject: Better Idiom for @_ $_ usage?
Message-Id: <8s7ufc$aqe$1@nnrp1.deja.com>

Is there a better idiom for this?

--- <cut>
sub trim
{
# if no arguments, use $_ as default
# return context = scalar/list => copy arguments and return list
# return context = void        => change arguments directly

	our @out;

	trim ($_) unless (@_ || defined(wantarray)); #??#
	push @_, $_ unless @_;
	defined(wantarray) ? @out = @_ : *out = \@_;

	foreach (@out)
		{
		next if not defined( $_ );
		s/^\s+//;	# remove leading whitespace
		s/\s+$//;	# remove trailing whitespace
		}

	return (defined(wantarray) ? @out : undef);
}
--- <cut>


Specifically, I'd like to get rid of the recursion in the marked line
since "trim;" would be a common usage.

My best alternative is to add an alias to $_ into the @_ array. This
doesn't work because I (can't / don't know how to) do that ... ("push
@_, $_ unless @_;" just adds the value to @_ array).

I haven't found any references to this kind of thing in any of the faqs
or reference books.

Thoughts? Pointers?

P.S. Is there any common practice for (wantarray ? ...) returns? I've
seen "return wantarray ? @out : $out[0];". But, given the behavior
of "$c = ('a', 'b', 'c');", I'd think "return wantarray ? @out : $out
[$#out]" would be more appropriate, or even just "return @out".

Please cc: replies to my email.

- Roy Ivy
Roy.Ivy.III@nMail.com


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


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

Date: Fri, 13 Oct 2000 21:53:11 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Better Idiom for @_ $_ usage?
Message-Id: <bvLF5.6912$O5.145713@news.itd.umich.edu>

In article <8s7ufc$aqe$1@nnrp1.deja.com>,  <Roy.Ivy.III@nMail.com> wrote:
>Is there a better idiom for this?
>--- <cut>
>sub trim
>{
># if no arguments, use $_ as default
># return context = scalar/list => copy arguments and return list
># return context = void        => change arguments directly

>Thoughts? Pointers?

Here's what I came up with:

sub trim {
    if (defined wantarray) {
        trim(my @copy = @_ ? @_ : $_);
        wantarray ? @copy : $copy[0];
    } else {
        foreach (@_ ? @_ : $_) {
            s/^\s+//;
            s/\s+$//;
        }
    }
}

>P.S. Is there any common practice for (wantarray ? ...) returns?

Nope, none.

>I've
>seen "return wantarray ? @out : $out[0];". But, given the behavior
>of "$c = ('a', 'b', 'c');", I'd think "return wantarray ? @out : $out
>[$#out]" would be more appropriate,

But what if $#out is -1?

>or even just "return @out".

In scalar context this would return the size of @out, not its last element.
Lists and arrays are not the same.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Fri, 13 Oct 2000 18:59:45 GMT
From: abevec@my-deja.com
Subject: Re: cgi with perl on Apache-1.3.12-Linux-6.2 - beginner
Message-Id: <8s7m2u$37h$1@nnrp1.deja.com>

In article <IWAF5.363$Uy5.24989@news000.worldonline.dk>,
  Anders Lund <anders@wall.alweb.dk> wrote:
> abevec@my-deja.com wrote:
>
> > I created a cgi Perl script in my cgi-bin directory that is suppose to
> > get executed on an "get" html command.  But the Appache server comes
> > back with an error.  I'm the server administrator.  All the
> > files/directories are mode 755 protected.  Any ideas how to correct this
> > problem.
>
> use CGI::Carp qw/fatalsToBrowser/;
>
> will let you know if and why your script fails if it parses, and even if
> the error happens in the last stage of the parsing.
>

Get the bugs out of your perl script by running it standalone first.
> use CGI;
>
> This will let you run your script in a term interactively, meaning you can
> provide params to it. Don't forget the -w scwitch!
>
> If you transferred oyur script to the server using FTP, and didn't set
> ascii ftp mode, you have some control chars at the top of the file.
>
> -anders
>
> --
> [ the word wall - and the trailing dot - in my email address
> is my _fire_wall - protecting me from the criminals abusing usenet]
>


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


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

Date: Fri, 13 Oct 2000 17:55:21 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Cookieless operation
Message-Id: <8s7ia6$vvt$1@nnrp1.deja.com>

In article <B3GF5.15470$QB1.4116274@typhoon.southeast.rr.com>,
  "Philip Garrett" <philipg@atl.mediaone.net> wrote:
> <yossariancomputing@my-deja.com> wrote in message
> news:8s77au$lpo$1@nnrp1.deja.com...
> > Hi,
> >
> > I want to maintain state within a web application without using
> > cookies, as personally I detest the things, and besides, I don't
want
> > to worry if a user hates them too and thus can't use my application
> > because they've turned them off.
> >
> > So somehow I suppose I need to use a manually created sessionid of
some
> > sort.
> >
> > I'm using perl 5.006 (with libwww-perl), apache, mysql on a FreeBSD
> > machine.
> >
> > Any tips?
>
> Try Apache::Session.  Use a hidden session_id field in your forms
instead of
> a cookie.

What if they save the html locally, change the session_id and then
submit the form?

You'll have to add extra security, like checking the IP address and/or
browser name.  But then you must also take into consideration that
multiple people could have the same browser and the same IP address (an
office, for example).  But that would be rare.

>
>

--
Dave Brondsema


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


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

Date: Fri, 13 Oct 2000 18:58:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Cookieless operation
Message-Id: <tkmeuso1nn0jg3kpsupeodi0hn7mlnr9c8@4ax.com>

Dave Brondsema wrote:

>What if they save the html locally, change the session_id and then
>submit the form?

My idea on this is that if you give enough pseudo-random characters to
your session ID's, and store alist of them locally, this is not a
problem. Not only would they have to edit their form, but they'd also
have to pick an existing session ID. The chance of this happening can be
made very slim.

Usually it's not even worth for them to bother. Why would you, for
example, want to pretend to be another Amazon customer?

-- 
	Bart.


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

Date: Fri, 13 Oct 2000 21:36:37 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: Cookieless operation
Message-Id: <8s7v95$bd9$1@nnrp1.deja.com>

In article <tkmeuso1nn0jg3kpsupeodi0hn7mlnr9c8@4ax.com>,
  Bart Lateur <bart.lateur@skynet.be> wrote:
> Dave Brondsema wrote:
>
> >What if they save the html locally, change the session_id and then
> >submit the form?
>
> My idea on this is that if you give enough pseudo-random characters to
> your session ID's, and store alist of them locally, this is not a
> problem. Not only would they have to edit their form, but they'd also
> have to pick an existing session ID. The chance of this happening can
be
> made very slim.

Good idea.  I incorrectly assumed that you would use increment numbers.

>
> Usually it's not even worth for them to bother. Why would you, for
> example, want to pretend to be another Amazon customer?
>

Steal a credit card number?  Wreak a little havoc?  Lots of people
aren't very considerate nowadays.

--
Dave Brondsema


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


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

Date: Fri, 13 Oct 2000 14:31:26 -0500
From: Alan Wamser <awamser@haysmed.com>
Subject: Delete files from CGI?
Message-Id: <39E7630E.B59ED4DF@haysmed.com>

I have a cron job that goes out every 5 min and checks the status of a
system.  If it finds something wrong it creates a dat file with a
description of the problem.  I then have a web page that refreshed every
min and checks the dir for new files.  If it finds one it parses it and
displays it on the page for tech to take care of.  Once the issue is
resolved they can click on the delete button beside the issue and file
will be removed.  I can't get the file to delete.

Apache is installed under /usr/local/apache and the dat files are
/usr/local/sysop/log.  How do I setup Apache to allow me to delete the
files from the cgi??

Thanks



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

Date: 13 Oct 2000 14:41:50 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Delete files from CGI?
Message-Id: <874s2g1qbl.fsf@limey.hpcc.uh.edu>

>> On Fri, 13 Oct 2000 14:31:26 -0500,
>> Alan Wamser <awamser@haysmed.com> said:

> I have a cron job that goes out every 5 min and checks
> the status of a system.  If it finds something wrong it
> creates a dat file with a description of the problem.  I
> then have a web page that refreshed every min and checks
> the dir for new files.  If it finds one it parses it and
> displays it on the page for tech to take care of.  Once
> the issue is resolved they can click on the delete
> button beside the issue and file will be removed.  I
> can't get the file to delete.

> Apache is installed under /usr/local/apache and the dat
> files are /usr/local/sysop/log.  How do I setup Apache
> to allow me to delete the files from the cgi??

Perl relevance: 0

Hi, try asking in a group that has some relevance to your
problem, e.g. 

  comp.infosystems.www.servers.unix

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 13 Oct 2000 15:19:29 -0600
From: "Darryl Friesen" <Darryl.Friesen@usask.ca>
Subject: Re: Delete files from CGI?
Message-Id: <8s7u80$sm2$1@tribune.usask.ca>

> I have a cron job that goes out every 5 min and checks the status of a
> system.  If it finds something wrong it creates a dat file with a
> description of the problem.

> Apache is installed under /usr/local/apache and the dat files are
> /usr/local/sysop/log.  How do I setup Apache to allow me to delete the
> files from the cgi??

What user does the cron job run as?  What user does the web server run as?
Bet they're not the same.  This is a file permission problem.

Have the cron job create (or even chmod or chown later) the dat files so
that user nobody (assuming Apache is running as the default user 'nobody')
can delete them.


- Darryl

 ----------------------------------------------------------------------
  Darryl Friesen, B.Sc., Programmer/Analyst    Darryl.Friesen@usask.ca
  Education & Research Technology Services,     http://gollum.usask.ca/
  Department of Computing Services,
  University of Saskatchewan
 ----------------------------------------------------------------------
  "Go not to the Elves for counsel, for they will say both no and yes"





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

Date: 13 Oct 2000 14:37:24 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Giant Array Delay (beginner)
Message-Id: <8s7o9k$nrt$1@muenster.cs.utexas.edu>

In article <8s64cd$r3g$1@nnrp1.deja.com>,  <peliknish@my-deja.com> wrote:
>Got a script working (by Matt Wright) that picks random strings from a
>list of strings in a text file delimited by whatever.
  :
  :
>So my question is:  How do i need to alter this script so that it will
>work with a giant file like mine? It appears to me that the problem is
>that the array of 60,000 is re-created with every call of the
>script. True?

Yes, that's the problem.  That design is perfectly O.K. for small
lists, but it's bad for large lists, since you don't even need to load
the whole thing in.

Probably the easiest solution is to load the whole thing into a DBM (or
DB or similar) file.  These are files that have special support for
indexing data based on keys and values (like hashes).  The great thing
about them is that you can read only the parts of the file that you
need.  In fact, just think of them as hashes on disk.

So, if you have five quotations, you could store them like this:

	key	value
	---	-----
	0	A penny saved is a penny earned.
	1	A stitch in time saves nine.
	2	Everything should be made as simple as possible,
		but no simpler.
	3       Perfection is achieved not when there is nothing more
		to add, but rather when there is nothing more to take
		away.
	4	Never say never.
	count	5

Now, to pick one at random, look at the entry under "count"; this tells
you how many you have.  Then, just pick a random number between 0 and
count-1, and then use that to look up the quotation that you want.

"perldoc -f tie" will tell you how to tie a hash to a file, so that its
storage is on disk rather than in memory.

Of course, you'll have to write a program to convert your text file
into this file format, but that's as simple as reading in the text file
(which you already have code to do) and writing each line into the tied
hash, and then writing a special "count" key into the hash, and then
doing an untie() (to clean up).

Hope that helps.

  - Logan


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

Date: Fri, 13 Oct 2000 13:27:35 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Giant Array Delay (beginner)
Message-Id: <39E77037.128FD62C@stomp.stomp.tokyo>

peliknish@my-deja.com wrote:

> Got a script working (by Matt Wright) that picks random strings from a
> list of strings in a text file delimited by whatever.
 
> The problem is I want to use it with a huge file--60,000 words--and it
> doesn't work.  The SSI returns nothing, I guess due to some kind of
> time out.
 
> So my question is:  How do i need to alter this script so that it will
> work with a giant file like mine? It appears to me that the problem is
> that the array of 60,000 is re-created with every call of the
> script. True?


"It appears to me...."

You have run tests using a very small file in place of
your large file, right? This type of logical thinking
will help you to avoid indicating "It appears...." and
help you to confidently indicate a specific problem.

This large file, you have made sure it employs the
correct formatting per Matt's script, correct? If
not correctly formatted, there is a good chance
Matt's script is returning all sixty kilobytes of
your file or, crashing and burning without termination.

You are using Server Side Includes. Here is an entire
script to do what you want, after adding a Perl locale
line and making a decision on html inclusion.

You can include html by surrounding your SSI call with
html tags in your static html page or, include html
tags in your script output return print.

Split your large correctly delimited file into six
files, each roughly ten kilobytes. Name these files
0.dat through 5.dat, inclusively. Which file is opened,
zero through five, will be determined by a random number.

This method enhances your random quality by random selection
of a file and, random selection of text to print.


my ($random) = int (rand(6));
if (!($random))
 {
  srand;
  $random = int (rand(6));
 }

open (RANDOM, "/your/path/to/$random.dat"); #optional error check
@Random = <RANDOM>;
close (RANDOM);

my ($output) = $Random[rand(@Random)];

print "Content-type: text/plain\n\n";

print $output;

exit;


There ya go.  A dozen lines of simple code which
is clean, fast and efficient.



Godzilla!
-- 
Are You Ready For Roberta The Remarkable Robot?


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

Date: Fri, 13 Oct 2000 19:20:27 GMT
From: jkipp@mbna.com
Subject: Help with backup script
Message-Id: <8s7n9k$4am$1@nnrp1.deja.com>

On my NT box I have 2 directories that have important files that I want
to back up across the wire to a Zip drive that is shared on a win95 PC
(I have a drive mapped from my NT box to the Win 95 box Zip Drive).
Until now I have been using a batch file that is crude and unreliable.
So Perl to the rescue.
I need to write a script that I can schedule to run with AT that will
Copy those 2 directories to the shared zip drive. But there are some
subdirectories on these 2 directories that I don't want to be copied,
so I need those filtered out.

Here is what I have so far. note: I only worked on one of the dirs so
far. I will not be able to test it until I get home (in 2 days). Just
looking for suggestions, corrections, whatever.
Thanks

Jim
---------------------------

use strict;
use File::copy;

my $dir = 'd:\program files\netscape\users\me\mail'

&ScanDir($dir);


sub ScanDir{
	my $dir = @_;  # or shift, what is better to use here and why ??
	my @dirs;
	my $target = 'n:\nets_back'; # zip drive on Win95 machine

	opendir(DIR, $dir) or die "Can't open directory: $!\n";
	my @dirs = grep (!/^\.\.?$/) readdir(DIR);
	closedir(DIR);


	foreach my $name (@dirs) {
		if (-d $name) && (&CheckDir($name))  {
			&ScanDir($name);
			next;
			}
		}
	copy("$name","$target");
}


sub CheckDir{
	my ($name) = shift;
	if ($name !~ /^dirs|don't|want|copied$/) {
		return 1;

	}
}






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


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

Date: Fri, 13 Oct 2000 14:26:58 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Help with backup script
Message-Id: <39E77E22.D6F50FC8@acm.org>

jkipp@mbna.com wrote:
> 
> On my NT box I have 2 directories that have important files that I want
> to back up across the wire to a Zip drive that is shared on a win95 PC
> (I have a drive mapped from my NT box to the Win 95 box Zip Drive).
> Until now I have been using a batch file that is crude and unreliable.
> So Perl to the rescue.
> I need to write a script that I can schedule to run with AT that will
> Copy those 2 directories to the shared zip drive. But there are some
> subdirectories on these 2 directories that I don't want to be copied,
> so I need those filtered out.
> 
> Here is what I have so far. note: I only worked on one of the dirs so
> far. I will not be able to test it until I get home (in 2 days). Just
> looking for suggestions, corrections, whatever.
> Thanks
> 
> Jim
> ---------------------------
> 
> use strict;

use File::Copy;
use File::Find;

my $dir = 'd:/program files/netscape/users/me/mail'
my $target = 'n:/nets_back'; # zip drive on Win95 machine

find( \&wanted, $dir );

sub wanted {
    return if $File::Find::dir =~ m-/(dirs|don't|want|copied)$-;
    copy( $File::Find::name, "$target/$_" );
}


HTH

John


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

Date: Fri, 13 Oct 2000 20:32:24 GMT
From: richardstands@my-deja.com
Subject: Help! binary files=losing my mind!
Message-Id: <8s7rgo$885$1@nnrp1.deja.com>

Gah! I had a problem with Compress::Zlib(I am running ActiveState Perl
5.6.0) and tracked it down to file sizes. So I created a script that
simply opens a binary file and writes all the data in it to a new
binary file. However it only reads up to byte 1574 and then stops as if
it were done. The original file is not corrupt or bad as Adobe
Photoshop can open it fine(the new file locks adobe up). What am I
missing here??

The following perl code:

use strict;
my $input = 'test.gif';
my $output = 'foo.gif';
my $buffer = '';
my $bytes;
binmode( IN );
binmode( OUT );
open( IN, "<$input" ) or die( $! );
open( OUT, ">$output" ) or die( $! );
print( "Size of input file is ", ( -s $input ), "\n" );
while ( 1 ) {
    $bytes = read( IN, $buffer, ( -s $input ) );
    print( "read in $bytes bytes\n" );
    print( OUT $buffer );
    last unless( $bytes > 0 );
}
close( IN );
close( OUT );
print( "Size of output file is ", ( -s $output ), "\n" );
exit( 1 );

Prints:

Size of input file is 174465
read in 1565 bytes
read in 0 bytes
Size of output file is 1574

I'm sure the problem is something minor but I just can't see what's
wrong. Thanks!!!

-Rich


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


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

Date: Fri, 13 Oct 2000 14:35:50 -0700
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Help! binary files=losing my mind!
Message-Id: <39E78036.A60C553C@acm.org>

richardstands@my-deja.com wrote:
> 
> Gah! I had a problem with Compress::Zlib(I am running ActiveState Perl
> 5.6.0) and tracked it down to file sizes. So I created a script that
> simply opens a binary file and writes all the data in it to a new
> binary file. However it only reads up to byte 1574 and then stops as if
> it were done. The original file is not corrupt or bad as Adobe
> Photoshop can open it fine(the new file locks adobe up). What am I
> missing here??
> 
> The following perl code:
> 
> use strict;
> my $input = 'test.gif';
> my $output = 'foo.gif';
> my $buffer = '';
> my $bytes;
> binmode( IN );
> binmode( OUT );
> open( IN, "<$input" ) or die( $! );
> open( OUT, ">$output" ) or die( $! );
> print( "Size of input file is ", ( -s $input ), "\n" );
> while ( 1 ) {
>     $bytes = read( IN, $buffer, ( -s $input ) );
>     print( "read in $bytes bytes\n" );
>     print( OUT $buffer );
>     last unless( $bytes > 0 );
> }
> close( IN );
> close( OUT );
> print( "Size of output file is ", ( -s $output ), "\n" );
> exit( 1 );
> 
> Prints:
> 
> Size of input file is 174465
> read in 1565 bytes
> read in 0 bytes
> Size of output file is 1574
> 
> I'm sure the problem is something minor but I just can't see what's
> wrong. Thanks!!!

Change the order of these lines

binmode( IN );
binmode( OUT );
open( IN, "<$input" ) or die( $! );
open( OUT, ">$output" ) or die( $! );

To

open( IN, "<$input" ) or die( $! );
binmode( IN );
open( OUT, ">$output" ) or die( $! );
binmode( OUT );


John


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

Date: Fri, 13 Oct 2000 13:55:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help! binary files=losing my mind!
Message-Id: <39E776C0.22FD6B62@vpservices.com>

richardstands@my-deja.com wrote:
> 
> binmode( IN );
> binmode( OUT );
> open( IN, "<$input" ) or die( $! );
> open( OUT, ">$output" ) or die( $! );

From perldoc -f binmode:

  binmode() should be called after open() but before any I/O is
  done on the filehandle.

HTH,

-- 
Jeff


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

Date: Fri, 13 Oct 2000 15:00:21 -0400
From: Don Vaillancourt <donv@webimpact.com>
Subject: Ho to encode a CGI value into URL/Unix format.
Message-Id: <39E75BC5.EC757E65@webimpact.com>

Is there a module that will do this.

Example:

$keyword = "Hello World!";

print "<a href=\"http://www.com?value=$keyword\">click here</a>";
When I move my mouse the above should appear similar to:

http://www.com?value=hello+world%36

and not

http://www.com?value=hello world!



Thanks

Don




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

Date: Fri, 13 Oct 2000 12:33:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Ho to encode a CGI value into URL/Unix format.
Message-Id: <39E76389.1BB0DA9@stomp.stomp.tokyo>

Don Vaillancourt wrote:

(hot hyperlinks killed)
 
> Is there a module that will do this.
 
> Example:
 
> $keyword = "Hello World!";
 
> print "<a href=\"http..//www.com?value=$keyword\">click here</a>";
> When I move my mouse the above should appear similar to:
 
> http..//www.com?value=hello+world%36
 
> and not
 
> http://www.com?value=hello world!


"...appear similar to...."

Do you want your string to look exactly as you
have exemplified or would something similar but
not exactly as you show, suffice?

How about, "hello&world" ?? This is similar and
exhibits the same semantic meaning.

Do you want your first letter of each word
capitalized or not? Your examples contradict
your variable parameters. 

Yes there is a module to do this. This module
is commonly called a "keyboard" by most.

$keyword = "hello+world";

There, all done and no need for a module.
I would not bother with an exclamation
mark. It is exceptionally rare you will
find a query string terminated with such.

Should you elect to have your program
perform unwarranted tasks,

$keyword = "hello world";
$keyword =~ tr/ /+/;


Godzilla!
-- 
Kira, Professional Poker Player
  http://la.znet.com/~callgirl/android/poker.cgi


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

Date: Fri, 13 Oct 2000 16:28:35 -0400
From: "Anthony Spina" <aspina@panix.com>
Subject: Re: Ho to encode a CGI value into URL/Unix format.
Message-Id: <8s7rfu$fps$1@news.panix.com>

I think what you are looking for is URI::Escape...

"Don Vaillancourt" <donv@webimpact.com> wrote in message
news:39E75BC5.EC757E65@webimpact.com...
> Is there a module that will do this.
>
> Example:
>
> $keyword = "Hello World!";
>
> print "<a href=\"http://www.com?value=$keyword\">click here</a>";
> When I move my mouse the above should appear similar to:
>
> http://www.com?value=hello+world%36
>
> and not
>
> http://www.com?value=hello world!
>
>
>
> Thanks
>
> Don
>
>




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

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


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