[17235] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4657 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 18 21:05:40 2000

Date: Wed, 18 Oct 2000 18:05:20 -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: <971917519-v9-i4657@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 18 Oct 2000     Volume: 9 Number: 4657

Today's topics:
        ((Float to integer) && (checking for sizeOf file)) pblegend22@my-deja.com
    Re: ((Float to integer) && (checking for sizeOf file)) (Clay Irving)
        Beyond useless (Mark Badolato)
    Re: BrowseForFolder in Win32::FileOp (Gwyn Judd)
    Re: Case Statement? <lr@hpl.hp.com>
    Re: converting a binary file to ascii (Peter McMorran)
    Re: Counter doesn't work (Gwyn Judd)
    Re: CPAN.pm gripe <nospam@david-steuber.com>
    Re: factorial function problem (Gwyn Judd)
    Re: How to send HTML over sendmail??? <bart.lateur@skynet.be>
        Keyboard Hook? (MBeach01)
    Re: Keyboard Hook? (Gwyn Judd)
    Re: Last try - does nobody know this stuff? (Peter McMorran)
    Re: mailq monitoring <elephant@squirrelgroup.com>
        manipulating data files triggerfish2001@hotmail.com
    Re: manipulating data files <rick.delaney@home.com>
    Re: metacharacters (Gwyn Judd)
        overloading of delete() not working <jdb@wcoil.com>
    Re: PERL IIS help <jihad.battikha@sharewire.com>
    Re: PERL IIS help (Craig Berry)
    Re: Perl not functioning in practice as it should in th (Gwyn Judd)
    Re: Perl not functioning in practice as it should in th (Gwyn Judd)
    Re: Perl not functioning in practice as it should in th (Greg Andrews)
    Re: Perl vs C on server side (Craig Berry)
    Re: Perl vs C on server side (Gwyn Judd)
        Programmer needed freestyler1@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 18 Oct 2000 23:39:38 GMT
From: pblegend22@my-deja.com
Subject: ((Float to integer) && (checking for sizeOf file))
Message-Id: <8slcbp$p3p$1@nnrp1.deja.com>

Hello,

I have a value that stores a calculated percentage, but how do I
display the percentage as an integer and not a floating decimal??
For example, I have 65.23455 temporarily stored in $Percent.
How do I display only 65??

I used "man perlfunc" and it said there was a built in function
named "int()".  Anyone familiar with this or what it does??  I guess I
could strip off everything past the ".", but I wanted to keep this
mathematical.


2nd Question:
How do I check for the size of a file and/or how do I check to see if a
file is empty??


Thank you,

Gary


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


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

Date: 19 Oct 2000 00:00:52 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: ((Float to integer) && (checking for sizeOf file))
Message-Id: <slrn8usedk.neg.clay@panix6.panix.com>

On Wed, 18 Oct 2000 23:39:38 GMT, pblegend22@my-deja.com 
<pblegend22@my-deja.com> wrote:

>I have a value that stores a calculated percentage, but how do I
>display the percentage as an integer and not a floating decimal??
>For example, I have 65.23455 temporarily stored in $Percent.
>How do I display only 65??

Try:

  perldoc -q round

>I used "man perlfunc" and it said there was a built in function
>named "int()".  Anyone familiar with this or what it does??  I guess I
>could strip off everything past the ".", but I wanted to keep this
>mathematical.

Try:

  perldoc -f int

>2nd Question:

Hey, wait a minute... This is your 3rd question. You aren't trying to 
sneak a question into this newsgroup, are you?

>How do I check for the size of a file and/or how do I check to see if a
>file is empty??

Try:

  perldoc -f stat

and 

  perldoc perlfunc

In the perlfunc section, read about -X.

-- 
Clay Irving <clay@panix.com>
8 nickels: 2 paradigms


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

Date: 19 Oct 2000 01:04:22 GMT
From: mbadolato@cybernox.com (Mark Badolato)
Subject: Beyond useless
Message-Id: <8FD1B0B20mbadolatocorpquepasa@206.165.3.80>

Reviewing some code on Hotscripts for a script that has good reviews, 
and seems popular, I find this jem in the source code.  I think this 
may take the cake in terms of all time useless...

sub wknd {
	my $died = shift;
	my $used = shift;
	if ($died) {
		return;
	}
	else {
		return;
	}
	return;	
}


Just thought I would share a laugh.

--mark


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

Date: Wed, 18 Oct 2000 23:25:59 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: BrowseForFolder in Win32::FileOp
Message-Id: <slrn8uscc4.bj3.tjla@thislove.dyndns.org>

I was shocked! How could news.hitline.ch <urs.grendelmeier@svema.ch>
say such a terrible thing:

>"Urs Grendelmeier" <ursgrendelmeier@chestonag.ch> schrieb im Newsbeitrag
>news:8sestf$gfk$1@pollux.ip-plus.net...
>> Hi,
>> BrowseForFolder in Win32::FileOp doesn't work with ActivPerl 618. Is there
>> a workaround or an other solution (Tk?) or has anyone the same problems?
>
>I still have the same problem.

I know nothing about Win32, I just want to give you a bit of advice. The
reason noone has answered you is that they are unable to decipher what
you mean. "Doesn't work" is about the most useless way to describe a
problem. Obviously that isn't true (or else why would the module exist
in the first place. Perhaps you need to rephrase the question.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Acid absorbs 47 times it's weight in excess Reality.


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

Date: Wed, 18 Oct 2000 15:48:54 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Case Statement?
Message-Id: <MPG.1457c8b66e34cac998ae46@nntp.hpl.hp.com>

In article <39EE1421.D35B2C2D@vpservices.com> on Wed, 18 Oct 2000 
14:20:33 -0700, Jeff Zucker <jeff@vpservices.com> says...
> JoeCoolCols wrote:

 ...

> > If pick = 1
> >    Write question1 to form
> > else if pick = 2
> >    Write question2 to form
> > ...
> > else write question132 to form
> 
> That doesn't require a case statement, it requires a hash:
> 
>   my %question = (
>       1   => 'What color is an orange?',
>       2   => 'Where do they make swiss cheese?',
>       # ...
>       132 => 'Is this the last question?',
>   );

I would suggest an array instead, with a dummy entry for 0, or 
subtracting one from the index (but NOT "local $[ = 1;" :-).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 18 Oct 2000 20:09:09 -0400
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: converting a binary file to ascii
Message-Id: <39ee3ecd$2$zpzbeena$mr2ice@news.visi.net>

In <8sks87$33$1@news.NERO.NET>, on 10/18/00 
   at 07:04 PM, stanley@skyking.OCE.ORST.EDU (John Stanley) said:

>In article <39EDD9C8.8373E95A@pauls.seanet.com>,
>Paul Spitalny  <pauls@pauls.-nospam-seanet.com> wrote: >Hi
>Larry, et al,
>>This sample output I showed in one of last emails did not include the rest
>>of the output. Basically, all the numbers pastr a certain point are
>>incorrect and think it has something to do with what happenswhen  the end
>>of a line in the binary file is encountered. This sounds similar to what
>>Larry is suggesting.

>There are no lines in binary files. There may be "records".
>Records are not "lines". 

>There may be non-float data stored in your binary file. We don't
>know that since we don't know the format for your file.

>There may also be garbage in the file, if you transferred the
>binary file via FTP in ASCII mode to or from a system which
>differentiates ASCII and IMAGE file types.

>And stop putting your resonse before what you are responding to.

Hi Paul,

Was your file by any chance written by a Fortran program, as
opposed to C or C++? Was it written with
ACCESS=SEQUENTIAL,FORM=UNFORMATTED? If so, there are record marks
at the start and end of each record as it was written. These
record marks are usually the length of the record before and
after the record. This is done by Fortran because it must be able
to BACKSPACE a file like a tape. The C languages do not do this,
but simply write a file as a stream, so no extra bytes are
inserted.

If that's not it, then there is definitely something else in the
file in addition to the blocks of doubles -- maybe an integer
index, or a float time value. Do you have access to the writer
code? If so, all you need to do is make the reader emulate the
writer.

If you have access to Unix-like tools, the multi-formatted od
dump program will let you browse the data and try to see what
layout makes sense.

Another thought relates to a similar problem I just ran into. Was
the file written by a C program ported to a Windows system from
Unix? If so, the file may have been opened in mode "w" (text
mode), then written with binary data. This works fine on Unix,
but on a Windows platform, a CR character is automatically
inserted before each LF character detected in the binary data.
The solution is to open the file in binary mode, "wb". od would
certainly show if the file tends to contain 0x0d before every
0x0a byte in the data.

Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: Wed, 18 Oct 2000 23:34:57 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Counter doesn't work
Message-Id: <slrn8uscsu.bj3.tjla@thislove.dyndns.org>

I was shocked! How could Andrew Watts <deward@purdue.edu>
say such a terrible thing:
>
>"Hans Vogel" <hansvog@hetnet.nl> wrote in message
>news:39EDC4A3.24EB7438@hetnet.nl...
>> Hello There!
>> The following CGI code in Perl Does print "1" in gif but doesn't seem
>> to read and write the count.dat file. I did a CHMOD 777 on the dat
>> file but it still doesn't work.  Can anyone tell me what could be
>> wrong?

>>     open (COUNT, "$count");
>
>Try open(COUNT, "<".$count);

And that will produce different results from his original version
exactly how?

>>     $counter = <COUNT>;
>>     close (COUNT);
>>     open (COUNT, ">$count");
>
>Try open(COUNT, ">".$count);

Given that ">$count" is implemented as ">" . $count how is that different?
If you don't know the answer to a question or aren't sure then maybe you
shouldn't post. The obvious answer is that the OP didn't check the
return value of those open()'s. You should also add that he needs to
look into locking the file if he doesn't want the information in the
file to get overwritten.

perldoc -f open
perldoc perlopentut
perldoc -q lock
perldoc -f lock

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
It is easy when we are in prosperity to give advice to the afflicted.
		-- Aeschylus


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

Date: Thu, 19 Oct 2000 00:45:01 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: CPAN.pm gripe
Message-Id: <m3y9zlbqwk.fsf@solo.david-steuber.com>

mgjv@tradingpost.com.au (Martien Verbruggen) writes:

' I hope that my suggestions will be able to alleviate that pain a bit,
' and that you didn't already know about them

I don't recall seeing 'look Module' or 'readme Module' when I typed
help.  So, yes, you helped and gave me something new to try.

Thanks.

-- 
David Steuber | Perl apprentice.  The axe did not stop the
NRA Member    | mops and buckets from flooding my home.
ICQ# 91465842
***         http://www.david-steuber.com/          ***


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

Date: Thu, 19 Oct 2000 00:31:29 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: factorial function problem
Message-Id: <slrn8usg6t.bj3.tjla@thislove.dyndns.org>

I was shocked! How could Tramm Hudson <hudson@swcp.com>
say such a terrible thing:

>Or, something similar to what was discussed in
>
>	http://www.deja.com/=dnc/getdoc.xp?AN=503823326
>
>with the change to memoize the results as they are computed:
>
>
>#!/usr/bin/perl -w
>use strict;
>
>my $f = sub {
>        my $a = shift;
>        my @v = qw/0 1/;
>        sub { $a->( $a, my $n = shift, \@v ) }
>}->( sub {
>        my $n = $_[1]--;
>        push @{$_[2]}, $n * $_[0]->(@_) if @{$_[2]} <= $n;
>        $_[2]->[$n];
>} );
>
>
>print "9! = ", $f->(9), "\n";
>print "3! = ", $f->(3), "\n";
>__END__
>
>
>There, isn't that easier?  It properly uses lexical variables
>for the recursion, is -w and strict clean and now memoizes the
>results.  What else could you want?

I misread the subject and thought it said "fibonacci" instead of
"factorial". I was going to respond with a smart-alec comment like "How
about the Right answer?" before I realised :) Anyway, I rewrote yours
slightly to do that:

#!/usr/bin/perl -w
use strict;

my $f = sub {
        my $a = shift;

        my @v = qw/0 1/;
        sub { $a->( $a, my $n = shift, \@v ) }
}->( sub {
        my $n = $_[1]--;
        push @{$_[2]}, $_[0]->(@_) + $_[2]->[$n-2] if @{$_[2]} <= $n;
        $_[2]->[$n];
} );

chomp && print "Fib of $_ is @{[$f->($_)]}\n" while <>;

Now all we need is for it to be readable for the non Lisp people :)

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Find a job you like and you add five days to every week.
-H. Jackson Browne


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

Date: Wed, 18 Oct 2000 22:47:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to send HTML over sendmail???
Message-Id: <pp9sussgcllggss8f36rvbcse3htjcfgp6@4ax.com>

Bostjan Kocan wrote:

>I would like to send HTML over sendmail?? I know how to send plain text, but
>if I try to send a colored table (or any other HTML code or page) to be
>displayed in the mailer (Outlook, NS Comunicator, etc...) I just receive
>plain HTML code in text back with no colored table to see....:))) I know
>that I am doing it wrong because I am sending HTML as text.... but how to
>send HTML as HTML?? How to tell sendmail that I am sending HTML and not
>text??

HTML is text. First, you can specify a "content-type: text/html" header,
just as in HTTP/CGI. Hey, guess what? The protocol HTTP is actually
based upon the mail format.

But a cleaner way would be to present a dual representation: one part
text, one part HTML, or whatever attachments you like. Well, check out
the MIME modules on CPAN:

	http://search.cpan.org/search?mode=module&query=MIME

MIME::Lite (if you only need the basics -- encoding only) and MIME-tools
(the meat -- both encoding and decoding), both by Eryq, look like they
can do the job. For this job, I'd go for MIME::Lite.

-- 
	Bart.


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

Date: 18 Oct 2000 22:26:08 GMT
From: mbeach01@cs.com (MBeach01)
Subject: Keyboard Hook?
Message-Id: <20001018182608.19389.00000075@ng-mc1.news.cs.com>

Anyone know how to create a keyboard hook in Win32 with perl?  I need to be
able to mimic the keyboard as if someone where sitting at the computer typing
stuff in.  I would think that there would be a simple solution but if there is
I haven't found it yet.

PLEASE HELP!

Michael Beachler


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

Date: Wed, 18 Oct 2000 23:44:41 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Keyboard Hook?
Message-Id: <slrn8usdf7.bj3.tjla@thislove.dyndns.org>

I was shocked! How could MBeach01 <mbeach01@cs.com>
say such a terrible thing:
>Anyone know how to create a keyboard hook in Win32 with perl?  I need to be
>able to mimic the keyboard as if someone where sitting at the computer typing
>stuff in.  I would think that there would be a simple solution but if there is
>I haven't found it yet.

How about a non-perl solution:

cat file_containing_commands.txt | perl my_script.pl

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
IDLENESS

n. A model farm where the devil experiments with seeds of new sins
and promotes the growth of staple vices.


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

Date: Wed, 18 Oct 2000 20:33:47 -0400
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: Last try - does nobody know this stuff?
Message-Id: <39ee4389$3$zpzbeena$mr2ice@news.visi.net>

In <l_wG5.1981$lb5.529183@news.uswest.net>, on 10/15/00 
   at 11:11 PM, "Michael Cook" <mikecook@cigarpool.com> said:

>    Thanks for the reply!
>    I set the flush in CGI (as I understand it) so that there is
>output immediately following the headers so that the brower
>won't time out waiting for a response while the script waits for
>a lock or does it's work on files (or whatever it does). That is
>what made me think that I only need to flush on the first open,
>but I am unsure - maybe waiting for a file lock later in the CGI
>script would take long enough to cause this timeout also, and
>this would prevent it (but maybe it only needs a response after
>the header, which is only given once).
>    I got this from a script by Tom which is used to write a
>counter - but only 1 file was opened in that script. To tell the
>truth, I am only doing it because I want to "do it right" - the
>scripts worked just fine with no flush, and they work with a
>flush on every open.
>    Slippery stuff without much documentation - if I can get
>firm answers, maybe I will write a nice summary on file locking
>& submit it to perl.com & post it here.
>        Michael

Michael,

What you are setting is the autoflush for the file handle, not
just flushing the file once. Every time data is written to that
handle, it will be sent, even though it is not a complete disk
buffer. So, there is no need to repeat setting autoflush for the
same handle. As you say, there is some timeout issue for the web
server, based on rules defined by the server configuration. If it
requires that data continue to arrive at regular intervals, then
you might be tripped by a lock that took a long time to acquire.
But there's nothing more you can do with autoflush to prevent
this.

If there is a problem, you may need to structure your design to
avoid it, possibly by using a single lock as a semaphore for
updating all the files the program requires. Of course, this
requires that all writers play by the same rules. Or you might
fork another process to update the other file, so it wouldn't tie
up writing of the CGI output.

Maybe folks in CGI newsgroups would have some more specific
experience.


>"James Taylor" <james@NOSPAM.demon.co.uk> wrote in message
>news:ant1604266d2fNdQ@oakseed.demon.co.uk...
>> In article <bbvG5.1934$lb5.466096@news.uswest.net>, Michael Cook
>> <URL:mailto:mikecook@cigarpool.com> wrote:
>> > Thanks James! Should I flush for each different file opened in a script?
>>
>> It is my understanding that files are flushed when closed anyway.
>> I cannot see any reason to set autoflush on a file handle unless
>> it needs to be immediate or interactive in some way. If you tell
>> us what kind of application you're writing and why you think you
>> need to flush output, then I or someone else may be able to comment.
>>
>> I tend to set autoflush at the top of scripts that prompt for user
>> input, otherwise the prompt does not appear when it should. I also
>> tend to set autoflush within CGI scripts but if I'm completely
>> honest I don't really know why this should be necessary - I've just
>> seen it done in the books. This of course is very "cargo-cultish"
>> of me and I really ought to find out exatly when and why it is
>> needed within CGI scripts. Perhaps someone here will enlighten us.
>>
>> > This script does work very well - I just want to do it right.
>> > Ought I post a complete script for you to see? I got this file
>> > locking code from language.perl.com (Tom Christiansen wrote it).
>>
>> Pah! If Tom Christiansen wrote it, then who am I to critique it?
>> I'm nobody. I wouldn't even *dream* of questioning it.
>>
>> --
>> James Taylor <james (at) oakseed demon co uk>
>> PGP key available ID: 3FBE1BF9
>> Fingerprint: F19D803624ED6FE8 370045159F66FD02
>>



Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: Thu, 19 Oct 2000 12:00:28 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: mailq monitoring
Message-Id: <MPG.145900c7782d826498982a@localhost>

Karsten Perlich wrote ..
>I want to monitor the mail-queue of a remote system. To see how long the
>mailq is, something like the response of "mailq | head -1 | cut -f2
>-d'(' | cut -f1 d' '" shot end in a local variable of my perl-script.

  perldoc -f open

or the Regexp Quote-Like Operators section of

  perldoc perlop

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 18 Oct 2000 15:23:20 -0700
From: triggerfish2001@hotmail.com
Subject: manipulating data files
Message-Id: <8sl7so0cv4@drn.newsguy.com>

Hi,

I have just basic knowledge of perl. The task I need to accomplish is as
follows:

source file needs to be converted to target file.

source file will be a fixed column length ASCII file of data.

target file will be a PIPE ('|') seperated ASCII file of data.

For eg:-
source file will be as follows:

John Smith           745-678-089011-10-1955
Robert IhaveAlongName345-567-453219-04-1967

Here the first 22 char is fixed length for name
Starting from 23rd char next 12 char is for SSN
Starting from 35th char next 10 char is for DOB.

Now this needs to be changed to
John Smith|745-678-0890|11-10-1955|
Robert IhaveAlongName|345-567-4532|19-04-1967|

The reason for this is that informix dbload or high performance loader needs
a field delimiter.

How can this be achieved in perl.

thanks.



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

Date: Wed, 18 Oct 2000 23:38:51 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: manipulating data files
Message-Id: <39EE3771.17A9DD88@home.com>

[posted & mailed]
[comp.databases.informix removed]

triggerfish2001@hotmail.com wrote:
> 
> Hi,
> 
> I have just basic knowledge of perl. The task I need to accomplish is as
> follows:
> 
> source file needs to be converted to target file.
> 
> source file will be a fixed column length ASCII file of data.

Use unpack to get your fields into an array.  See perlfaq4:

    How do I extract selected columns from a string?

and 

  perldoc -f unpack

> target file will be a PIPE ('|') seperated ASCII file of data.

Now just print the array with '|' as the separator.

  perldoc -f join

Something like this:

    while (<>) {
        my @a = unpack('A21 A12 A10', $_);
        print join('|', @a), "\n";
    }

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 18 Oct 2000 23:53:40 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: metacharacters
Message-Id: <slrn8use01.bj3.tjla@thislove.dyndns.org>

I was shocked! How could pepite@hotmail.com <pepite@hotmail.com>
say such a terrible thing:
>Can someone tell me what the synatx is for
>validating that my string has uppercase letters from A-Z exluding for
>example H and J and R and S and whatever else there are about 7 or 8
>letters I want to excluse.
>
>The Variable would be
>$variable
>and it would contain something like this  J7:Y7:Q7:B7:H7:M7:N7:V7:K7:L7

if ($variable !~ /[HJRS]|[^A-Z:7]/)
{
    # $variable is okay
}

You haven't really defined the format of your string so I left out
checking if it matched 'letter''number'':' repeated but that shouldn't
be difficult to add in if necessary. See:

perldoc perlre
perldoc perlop

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Elbonics, n.:
	The actions of two people maneuvering for one armrest in a movie
	theatre.
		-- "Sniglets", Rich Hall & Friends


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

Date: 18 Oct 2000 23:58:51 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: overloading of delete() not working
Message-Id: <8sldfr$sal$0@206.230.71.38>

greets perlfolk,

I have made this test module:

package test;
sub import {
    *{"main::delete"} = sub { print "del: @_" }
};
1;


And I try to test it with this one-liner:

% perl -Mtest -e 'delete @_[0]'

I dont care whats in @_ right this moment. The point here is that I never
even see the print statmenent in the closure, well, sub ref. The test script
just exits with no output, instead of the expected "del: ". Yes, I have read
perlsub, perlfunc, and a host of others. and all that. To quote perlsub:

        Overriding may be done only by importing the name from a
module--ordinary predeclaration isn't good enough.

Alonng with the rest of the context that that is found in implies that this
example above should work. Yet I can't get it to utter a single line of
"del: ". I know that import() is being called because ive added a print
trace statement in it, but i never see the "del: " string.

Does anyone have any ideas as to how to get this to work? Thanks for any
help in advance!

--
$from = <$josiah>;







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

Date: Wed, 18 Oct 2000 18:12:45 -0400
From: Jihad Battikha <jihad.battikha@sharewire.com>
Subject: Re: PERL IIS help
Message-Id: <39EE205D.B626BA3@sharewire.com>

Hou-Gee Michael Wong wrote:

> I'm trying to use a perl library (.pm) in my perl cgi scripts
> under IIS and it's returning me with a can't locate xxxxxx.pm
> in @INC error.
> 
> ...When the script executes, instead of looking for the .pm
> file in the same directory of the script, it looks for the
> .pm file in the web root c:\inetpub\wwwroot.

Some configurations of IIS appear to wrongly think '.' (current
directory) means the web root rather than the actual current working
directory.  A quick (but possibly non portable) way to fix this is to
push your .pm folder into Perl's @INC array from within a BEGIN block.

ex.
BEGIN { push (@INC, 'c:\inetpub\wwwroot\subfolder') }

If you want it to be dynamically portable, you need to use some
(possibly unreliable) heuristics on some environment variables, $0, and
whatever else is available to first determine the current working
directory and then push that onto @INC.  You could also try using the
Cwd module distributed with Perl but I've tried this myself but found it
unreliable when running under some IIS configurations.  Perhaps use it
as a last resort.

Ex.
BEGIN {
  use Cwd;
  my $cwd;
  if ($0 =~ /(.*)[\\\/]/) {
    $cwd = $1;
  } else {
    $cwd = cwd();
  }
  push (@INC, $cwd || 'c:\inetpub\wwwroot\subfolder');
  undef $cwd;
}

-- 
Jihad Battikha <jihad.battikha@sharewire.com>
  Sharewire, Inc. --- http://www.sharewire.com/
    - Free forms, programs, and content for web sites.
    - No assembly required.

Disclaimer:
Before sending me commercial e-mail, the sender must first agree
to my LEGAL NOTICE located at: http://www.highsynth.com/sig.html




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

Date: Wed, 18 Oct 2000 22:36:58 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: PERL IIS help
Message-Id: <sus9gaqm5dc992@corp.supernews.com>

Jihad Battikha (jihad.battikha@sharewire.com) wrote:
: Some configurations of IIS appear to wrongly think '.' (current
: directory) means the web root rather than the actual current working
: directory.

Well, it's hard to call it 'wrong', given that the cwd has no 'correct'
value for a CGI app.  I'll certainly agree that pointing cwd somewhere
other than the CGI app's home dir is massively inconvenient. 

: A quick (but possibly non portable) way to fix this is to
: push your .pm folder into Perl's @INC array from within a BEGIN block.
: 
: ex.
: BEGIN { push (@INC, 'c:\inetpub\wwwroot\subfolder') }
: 
: If you want it to be dynamically portable, you need to use some
: (possibly unreliable) heuristics on some environment variables, $0, and
: whatever else is available to first determine the current working
: directory and then push that onto @INC.

The FindBin module does this quite well.  Rather than pushing it onto
@INC, I tend to cd to this directory.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Wed, 18 Oct 2000 23:14:22 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl not functioning in practice as it should in theory.  - test.pl (0/1)
Message-Id: <slrn8usbmc.bj3.tjla@thislove.dyndns.org>

I was shocked! How could /michael </michael>
say such a terrible thing:
>Please look at this script.  It should find every sub directory
>recursively but stops for some reason.  Id anyone could figure this
>out I would greatly appreciate it.  

Others have already told you how to use File::Find to do what you want.
I think that they are right, however I'll point out the bugs in your
current script anyway :)

>#!/usr/bin/perl

I very much recommend that you use the following:

#!/usr/bin/perl -w
use strict;

This turns on all warnings and makes the compiler a bit stricter in what
it will accept.

>@directory = ('/home/users/michael');

That should be:

my @directory = '/home/users/micheal';

>sub openDir {
>
>   my ($ImageDir) = @_;
>
>   opendir(LS,$ImageDir);
>      @file = readdir(LS);
>   closedir(LS);
>
>   foreach $file (@file) {
>      if ((-d $file)&&(!($file =~ /\./))) {

Should be:

       if (-d "$ImageDir/$file" && $file !~ /^\./)

This is because you are not necessarily in the same directory as
$ImageDir. Also you probably want to anchor the regex at the start
(unless you want to exclude directories with a dot anywhere in the name).

That said, File::Find is a lot simpler to use and really is the standard
way to do these things. Also it is a lot more extensible than your code.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
All the men on my staff can type.
		-- Bella Abzug


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

Date: Wed, 18 Oct 2000 23:20:10 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl not functioning in practice as it should in theory.  - test.pl (0/1)
Message-Id: <slrn8usc18.bj3.tjla@thislove.dyndns.org>

I was shocked! How could /michael </michael>
say such a terrible thing:
>On 18 Oct 2000 18:20:32 +0100, nobull@mail.com wrote:
>
>></michael> writes:
>>
>>> Please look at this script.  It should find every sub directory
>>> recursively but stops for some reason.
>>
>>Why are you re-inventing File::Find?
>
>I'm not trying to re-invent File::Find.   I'm trying to batch process
>contents of directories recursively.  This part was not in what I

That is what File::Find does. Why are you reinventing File::Find? :) I
think you don't really understand how it works.

>>Forgetting to my() your variables will cause trouble for you sooner or
>>later.  In the case of recursive programs it is thankfully sooner
>>rather than later.
>
>Please enunciate or give an example. 
>
>Do you mean adding or removing my()?

Yeah, he means that if you 'use strict' as is recommended here, you need
to declare your variables. Quite often, the best way to do that is by
using 'my':

my $file = 'blah.txt';

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Oh this age!  How tasteless and ill-bred it is.
		-- Gaius Valerius Catullus


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

Date: 18 Oct 2000 23:57:26 GMT
From: gerg@panix.com (Greg Andrews)
Subject: Re: Perl not functioning in practice as it should in theory.  - test.pl  (0/1)
Message-Id: <8sldd6$t7d$1@news.panix.com>

Jeff Zucker <jeff@vpservices.com> writes:
>
>Well this is totally unhelpful to your problem but your subject line
>gives me an excuse to post one of my favorite quotes, anyone know its
>source?
>
>  In theory practice and theory are the same, but in practice they
>aren't.
>

The version I first encountered in 1993 was:

  The difference between Theory and Practice
  is greater in practice than it is in theory.


  -Greg
-- 
:::::::::::::::::::  Greg Andrews   gerg@panix.com  :::::::::::::::::::
ObDrieux:  MODERN PROBLEMS: Hi Diddle Diddle, The Cat and the Fiddle,
			    The Cow Blew Up on the Launching Pad
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


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

Date: Wed, 18 Oct 2000 22:33:34 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Perl vs C on server side
Message-Id: <sus99udgg74s18@corp.supernews.com>

Uri Guttman (uri@sysarch.com) wrote:
[re 'Why are server daemons written in C rather than Perl?']
: because that is one area where speed makes a difference. the faster and
: more efficient a server is, the more clients and requests it can handle.
: and that speed also lowers the cost of the needed hardware.

 ...which of course is also true of any Perl apps invoked by these daemons.
It's all a question of tradeoffs.

: but there are plenty of smaller servers written in perl for which speed
: is not a major issue but simplicity or ease of coding are. those can be
: done in perl and i would never think about doing them in c.

Exactly.  All other things being equal, and for smallish, one-person
projects, I will *always* choose Perl.  Development goes much faster and
programs tend to be much shorter. 

: BTW this is from someone who has code many client/server systems in both
: c and perl. each has its strengths and weaknesses.

I've actually prototyped client-server pairs in Perl just to refine the
protocols and so forth, then re-implemented in C for production later.
It's a great strategy.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Quidquid latine dictum sit, altum viditur."
   |


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

Date: Wed, 18 Oct 2000 23:58:18 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl vs C on server side
Message-Id: <slrn8use8o.bj3.tjla@thislove.dyndns.org>

I was shocked! How could rosenb_m@my-deja.com <rosenb_m@my-deja.com>
say such a terrible thing:

>I don't have statics comparing speed between tasks
>written in C and perl, but, it's often said that:
>"the little speed gain that C provides it's too
>expensive compared to the easy-coding that perl
>provides".

Perl doesn't have to be slower. At the things it does well (hashes,
regexes &c) you will be hard pressed to write an equivalent solution in
C that runs faster.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I hate small towns because once you've seen the cannon in the park
there's nothing else to do.
		-- Lenny Bruce


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

Date: Wed, 18 Oct 2000 23:01:59 GMT
From: freestyler1@my-deja.com
Subject: Programmer needed
Message-Id: <8sla52$n7t$1@nnrp1.deja.com>

What I need is basically a ftp search script.

A person submits their ftp site through the script, in which the script
creates a "file library" of what files are within the ftp.

This file library is searchable throughout the site. It should be
updated every few hours. If an ftp doesn't respond, the file library
would be put into a temporary folder that keeps getting checked also.
If those ftp's don't come back online after a few days, they would be
taken off the script.

The search would only return results that were online.

That's what i'm looking for. The script is basic. Right now i'm working
under a Unix.

Also, is it possible for a script to randomly search for ftps online
and automatically store them on the site?


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


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

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


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