[17466] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4886 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 14:05:52 2000

Date: Tue, 14 Nov 2000 11:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974228718-v9-i4886@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 14 Nov 2000     Volume: 9 Number: 4886

Today's topics:
    Re: A surprise with vec() <joe+usenet@sunstarsys.com>
    Re: activeperl: reading registry <me@privacy.net>
        Directory Size (Matt Daemon)
    Re: Directory Size <newshunter@knowhunter.cjb.net>
    Re: Does  sub foo { 'A'..'Z' }  return a list? <ren.maddox@tivoli.com>
    Re: Handling telnet session termination (malgosia askanas)
        How do I get dateA-daysX=dateB? <geoff@800-800-cruise.com>
    Re: How do I get dateA-daysX=dateB? (Greg Bacon)
    Re: HTML download form - CGI/Perl (dionysus)
        IO::Select Solaris & Win32 jmwjr@my-deja.com
    Re: IP geography (Leon Brocard)
    Re: IP geography <elaine@chaos.wustl.edu>
    Re: IP geography <elijah@workspot.net>
        Is this possible in Perl? <johan.augustsson@adm.gu.se>
    Re: Is this possible in Perl? <aqumsieh@hyperchip.com>
        Lizard gone? <jboes@eomonitor.com>
    Re: Looking for idiom for getting value from @ARGV, or  <ren.maddox@tivoli.com>
    Re: Newbee question, help wanted ! <jeff@vpservices.com>
        newbie perl > html question jponder9@my-deja.com
    Re: Newbie recursion question <ren.maddox@tivoli.com>
        newline in the NT EventLog wslee00@hotmail.com
    Re: OK - I'm stupid. Please help. <geoff@800-800-cruise.com>
        Perl code not doing what I expected <michael.segulja@sgi-lsi.com>
    Re: Perl code not doing what I expected (Rafael Garcia-Suarez)
    Re: Perl code not doing what I expected <camerond@mail.uca.edu>
        Perl with VB Gui <demonic_warrior@bluewin.ch>
    Re: Perl with VB Gui <kstep@pepsdesign.com>
    Re: Perl32 <jeff@vpservices.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 14 Nov 2000 11:09:26 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A surprise with vec()
Message-Id: <m3snour0w9.fsf@mumonkan.sunstarsys.com>

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

> On Mon, 13 Nov 2000 05:28:23 GMT,
> 	Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> > I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
> > say such a terrible thing:
> > 
> >>unpack and vec work on the string part of a scalar. A perl scalar has
> >>an integer part, and a string part, and Perl will convert on the fly.
> > 
> > Dear god. I don't know if I should feel enlightened or appalled :) The
> > documents should spell that out a bit more explicitly I think. Oh well I
> > think I can say I sort of understand vec, pack and unpack now.
> 
> Well, you almost never have to worry about this sort of thing, since
> perl will almost always do what you intended. There are some contexts in
> which a scalar will always be used in a certain way (integer, double, or
> string), and they are loosely documented, sometimes. You know that a
> scalar is always treated as a string when it is used as a hash key, or
> when you use it as an argument to length, or substr. Only in the case of
> numeric functions, or purely numeric contexts (multiplication, addition,
> numerical comparisons, array index, etc..) will a scalar be used as a
> integer or double. Certain arguments to functions are always interpreted
> as a number (chr, offset and length for substr, splice, etc.). In most
> cases it is perfectly clear what you mean, and it is mostly clear to you
> what the argument is supposed to be.

Not always, though- the interpretation occasionally depends on your
perl version:

% cat try.pl
#/usr/bin/perl -wT

$_ = "3626198025";
print join '.', reverse unpack 'C4', pack 'i', $_;
print "\n";
$_ = 3626198025;
print join '.', reverse unpack 'C4', pack 'i', $_;
print "\n";
__END__

% ./try.pl
127.255.255.255
216.35.100.9
% /usr/bin/perl -v

This is perl, version 5.005_03 built for i386-linux
[...]
% /usr/local/bin/perl -wT try.pl
216.35.100.9
216.35.100.9
% /usr/local/bin/perl -v

This is perl, v5.6.0 built for i586-linux
[...]


YMMV
-- 
Joe Schaefer


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

Date: Tue, 14 Nov 2000 18:07:35 GMT
From: "EM" <me@privacy.net>
Subject: Re: activeperl: reading registry
Message-Id: <HbfQ5.3391$Nw6.10665@news.iol.ie>

that code doesnt work
heres what i got

C:\WINDOWS\Desktop>d:\perl\bin\perl.exe -w registry.pl
syntax error at registry.pl line 10, near ") ="
Execution of registry.pl aborted due to compilation errors.
        (in cleanup) Can't call method "FETCH" on an undefined value at
D:/Perl/
site/lib/Win32/TieRegistry.pm line 1486 during global destruction.



"Marshall Thomas" <mmthoma@attglobal.net> wrote in message
news:3A11376F.2044C0A4@attglobal.net...
> EM wrote:
> >
> > i have windows me with activeperl installed
> > is there a way to read/write a key from the windows registry?
> >
> > thanks in advance
>
> Since you are running in the Winbloze environment, you should
> check out the Active State port - www.activestate.com
>
> You want the Win32::TieRegistry module.
>
> something like this should work fine:
>
> my $Registry;
> use Win32::TieRegistry 0.20 (
>         TiedRef => \$Registry, Delimiter => "/", ArrayValues => 0,
>         SplitMultis => 1, AllowLoad => 1, AllowSave => 1,
>         qw ( REG_SZ REG_EXPAND_SZ REG_DWORD REG_BINARY REG_MULTI_SZ
>            KEY_READ KEY_WRITE KEY_ALL_ACCESS ),
> );
> my $somevariable;
> #a read of a string value is like this:
> unless ($somevariable) =
> $Registry->{"HKEY_LOCAL_MACHINE/blah/blah//subkey"})
>           {do what you want if the key doesn't exit};
>
> #a write of a string value is like this:
> $Registry->{"HKEY_LOCAL_MACHINE/blah/blah//subkey"}="$somevariable"
>          || some_error_routine();
>
> reading and writing dwords is more tricky. The HTML documentation for
> TieRegistry is something like 30 pages. This subject can get really
> complicated. You've got a start here.
>
> Good Luck,
> /Marshall




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

Date: Tue, 14 Nov 2000 11:44:51 -0600 (CST)
From: matt_daemon@webtv.net (Matt Daemon)
Subject: Directory Size
Message-Id: <29170-3A117A13-11@storefull-242.iap.bryant.webtv.net>

How do I check the size of a directory before writing to it? Before I
write the new file(s) to a directory, I want to make sure that the new
[additional] file(s), won't make the directory exceed 5 Megs, and if
they do, I want the script to print a message, such as "directory is too
full to use."

Thank You
-matt



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

Date: Tue, 14 Nov 2000 18:12:07 +0000
From: "The Know Hunter" <newshunter@knowhunter.cjb.net>
Subject: Re: Directory Size
Message-Id: <8us02f$knh$1@venus.telepac.pt>

In article <29170-3A117A13-11@storefull-242.iap.bryant.webtv.net>,
matt_daemon@webtv.net  wrote:

> How do I check the size of a directory before writing to it? Before I
> write the new file(s) to a directory, I want to make sure that the new
> [additional] file(s), won't make the directory exceed 5 Megs, and if
> they do, I want the script to print a message, such as "directory is too
> full to use."
> 
> Thank You
> -matt
> 

$dirname='/home/xpto/';
while (<$dirname*>) {
	$totsize+=-f $_;
}
if ($totsize > 5*2**20) {
	print "directory full\n";
} else {
	#do anything!
}

-- knowhunter --
--------------------------------------------------------------------------
 Busco o conhecimento absoluto, para poder compreender a todos de igual
   forma e de novo sentir-me plenamente parte de um todo harmonioso.
--------------------------------------------------------------------------
                The Know Hunter - knowhunter@yahoo.com


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

Date: 14 Nov 2000 09:25:03 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Does  sub foo { 'A'..'Z' }  return a list?
Message-Id: <m3pujyh8z4.fsf@dhcp11-177.support.tivoli.com>

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

> On Tue, 14 Nov 2000 14:42:49 +0800,
> 	John Lin <johnlin@chttl.com.tw> wrote:
> > Dear all,
> > 
> > Q1: Is it possible to write the following pieces of code in
> > one statement (so we can save two variables $begin,$end).
> > 
> >     my ($begin,$end) = $object->iterate;
> >     print $object->get($_) for $begin..$end;
> 
> Yes.

[Martien's very nice explanation of the operator omitted]

Martien, you said "Yes" to the OP's question (above) about whether or
not it was possible to omit the $begin and $end variables, but (unless
I missed it) you never told him how.  The OP apparently made the
mistaken assumption that there was a scalar context here when there
isn't, and that lead to the side discussion of the flip-flop operator.

As to the original question, actually I do not think it is possible to
get the magical for/range operator behavior (wherein, for efficiency,
the list is *not* actually created) without it being explicit.  I
could easily be wrong about this, but the point is that I would expect
that the optimization that allows:

for (1..1_000_000) {}

to avoid generating a million element list will not apply if this is
used instead:

sub million { 1..1_000_000 }
for (million) {}

A quick test of each of these was not very conclusive -- the sub
version was certainly slower, but not enough to definitively indicate
that it was allocating all of that memory, at least not to me.

Oh -- never mind.  Changing it to 100 million demonstrates the
difference right away:

% time perl -e 'for (1..100_000_000) {}'
perl -e for (1..100_000_000) {}  66.59s user 0.05s system 99% cpu 1:06.64 total
% time perl -e 'sub million {1..100_000_000};for (million) {}'
Out of memory!
perl -e sub million {1..100_000_000};for (million) {}  0.01s user 0.01s system 181% cpu 0.011 total

To summarize, the only way to get the magical behavior of the range
operator in a for list is for the range operator to explicitly be in
the for list.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 14 Nov 2000 09:42:30 -0500
From: askanas@panix.com (malgosia askanas)
Subject: Re: Handling telnet session termination
Message-Id: <8urj0m$fg4$1@panix6.panix.com>

Ben Kennedy <bkennedy99@home.com> wrote:

>Are you doing something that blocks on STDIN?  Are the signal handles
>getting fired at all?  One way of getting around this may be to ues the
>standard utility 'screen', which creates virtual terminals for foreground
>process that keep running even if the connection is broken.  The terminals
>don't know/care that the interactive user has dropped.

Yes, my program waits for user input on STDIN.  I actually don't know if 
the signal handlers are getting fired, but I assume not, since the only code
in them is "exit", and that's exactly what the program doesn't do.

Could you tell me more about the "screen" utility?  What is it part of?
Is it part of Perl, or Unix?  Also, from your description it sounds to me
(probably incorrectly) as if that utility did the opposite of what I want --
i.e. it sounds like it keeps the terminal process running even if the
interactive user has dropped, whereas what I need is the opposite.  Am 
I reading you wrongly?


-malgosia


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

Date: Tue, 14 Nov 2000 06:48:12 -0800
From: "GC" <geoff@800-800-cruise.com>
Subject: How do I get dateA-daysX=dateB?
Message-Id: <tecQ5.11480$au.512508@nntp3.onemain.com>

I'm lost. I'm trying to get Perl to calculate a date spread and present
the answer to the user. I've checked the FAQ's but I don't seem to get
it.

I need to start from any given date, say 08/15/2001, or 2001/08/15, or
even 20010815 - I don't care - and subtract (or add) an arbitrary number
of days, say 60 then print the results to the screen.

This is straightforward in so many things but I can't seem to "get it"
in Perl.

Any and all help greatly appreciated.
Geoff




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

Date: Tue, 14 Nov 2000 15:11:31 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How do I get dateA-daysX=dateB?
Message-Id: <t12lh3s7rni3ad@corp.supernews.com>

In article <tecQ5.11480$au.512508@nntp3.onemain.com>,
    GC <geoff@800-800-cruise.com> wrote:

: I need to start from any given date, say 08/15/2001, or 2001/08/15, or
: even 20010815 - I don't care - and subtract (or add) an arbitrary number
: of days, say 60 then print the results to the screen.

Use the Date::Calc module that's available on the CPAN:

    <URL:http://www.perl.com/CPAN/modules/by-module/Date/>

You can grab it directly from the developer's website:

    <URL:http://www.engelschall.com/u/sb/download/pkg/Date-Calc-4.3.tar.gz>

Greg
-- 
Sometimes nothing can be a pretty cool hand.
    -- Cool Hand Luke


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

Date: Tue, 14 Nov 2000 17:53:09 GMT
From: dionysus39@hotmail.com (dionysus)
Subject: Re: HTML download form - CGI/Perl
Message-Id: <3a1179fa.49370273@nntp.unsw.edu.au>

On Tue, 14 Nov 2000 13:36:51 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
wrote:

>I was shocked! How could dionysus <dionysus39@hotmail.com>
>say such a terrible thing:
>
>>test. I assume that is because sysread() is reading the file in the
>>same (text-oriented?) way that more reads files...(as more will read
>
>Yup. You need to binmode() the file you are reading from (after you open
>it) and also STDOUT too. Or get a real operating system :) *duck*
hahahaha....I've got red hat 6.2 on my old machine, and have the
apache server installed...but everytime a client requests a page from
it it returns 400 (Bad Request).....
>
>>Problem 2 (minor). - when the user is prompted to download the file,
>>the default filename is not "tiny web server.zip" or "tinywe~1.zip",
>>but "ftest.zip" - where ftest.pl is the name of the perl/cgi
>>script....
>
>Beats me. Sounds like you want to ask this in a CGI group.
Forgive my preemptive crossposting, but such has already been done (I
asked my original question, and the modified followup, in both NGs. So
far you guys are beating them :->).

-d
>
>-- 
>Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
>Missed the train at the railway station
>Oh hell, blast, and damnation!
>Asked a lady in there if she had the time,
>She said "Yes", and a strong inclination.


------------------------------------------------------------
"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler .


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

Date: Tue, 14 Nov 2000 17:37:57 GMT
From: jmwjr@my-deja.com
Subject: IO::Select Solaris & Win32
Message-Id: <8urt9k$avb$1@nnrp1.deja.com>

The following code appears to correctly check the can_read status when
run on Solaris, however on Win32(NT or 2000) the code never stops at
the can_read statement. Nothing is in the ready array, so it just loops
continually.
Why doesnt it pause on the Win32 platform, and how do I get around this.
Active Perl 5.6 on both platforms.
Thanks Mike

use IO::Select;

$s = IO::Select->new();
$s->add(\*STDIN);

while (1) {
  print "Waiting for something to read\n";
  @ready = $s->can_read();
  foreach $fh (@ready) {
    print "Found something to read, Reading from $fh\n";
    while (<$fh>) {
      chomp;
      print "Data: $_\n";
      last;
      }
    }
  @ready = ();
  }


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


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

Date: 14 Nov 2000 15:47:33 GMT
From: acme@ns0.astray.com (Leon Brocard)
Subject: Re: IP geography
Message-Id: <slrn912r6p.hic.acme@ns0.astray.com>

tcblue@my-deja.com typed out randomly:

> does any know if there is a perl module or script that can 'try' and
> detect the physical location of a given IP address or hostname? 

In general, this is a Hard Problem. However, the clever folks over at
Caida have a server (and a Perl module) over at:
http://www.caida.org/tools/utilities/netgeo/

Hope this helps, Leon
-- 
Leon Brocard.............................http://www.astray.com/
yapc::Europe............................http://yapc.org/Europe/

 ... All new improved Brocard, now with Template Toolkit!


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

Date: Tue, 14 Nov 2000 17:24:17 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: IP geography
Message-Id: <5zeQ5.14351$AM5.270098@news1.nokia.com>

"Leon Brocard" <acme@ns0.astray.com> wrote in message
news:slrn912r6p.hic.acme@ns0.astray.com...
> tcblue@my-deja.com typed out randomly:
>
> > does any know if there is a perl module or script that can 'try' and
> > detect the physical location of a given IP address or hostname?
>
> In general, this is a Hard Problem. However, the clever folks over at
> Caida have a server (and a Perl module) over at:
> http://www.caida.org/tools/utilities/netgeo/

Geography is mostly impossible, but topography maps have been around for a
while. Placing a machine in the geographic location that the registrant
has listed is going to be wrong at least if not more than half the cases
especially with domain squatters and co-location sites these days. So, try
is possible but success is tenuous.

e.




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

Date: 14 Nov 2000 18:46:28 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: IP geography
Message-Id: <eli$0011141339@qz.little-neck.ny.us>

In comp.lang.perl.misc, Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> > tcblue@my-deja.com wrote ..
> >>does any know if there is a perl module or script that can 'try' and
> >>detect the physical location of a given IP address or hostname?  I
> > IP addresses can quite easily be classified by country of designation
> No, they cannot. There are a few IP addresses that have spatial meaning.
> The large bulk has none.  Try to guess where IBM's IP addresses hang
 ...
> All you can do is make a guess at it, and get about 60% or so
> (reasonably) right (and that would be based on host names, not IP
> addresses). The other 40 or so % will simply be wrong, undetectably so.

Some folks in my company have been working on this problem for
demographics reasons. They are specifically looking at IP to US
zip code or IP to country. They are using some commercial product
and comparing the results to people who have volluntarily given
us that data.

They find that for 30% of the cases they get a good match. The other
70% are unknown or widely off. They are pretty happy with that level
of success.

Elijah
------
knowing 30% of your demographic is better than known none


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

Date: Tue, 14 Nov 2000 16:14:52 +0100
From: Johan Augustsson <johan.augustsson@adm.gu.se>
Subject: Is this possible in Perl?
Message-Id: <3A1156EC.4AFEE376@adm.gu.se>

Can I do the following with Perl?

Take some specific data from a logfile (which changes every now and
then) and put it into a table in a MySQL-database. As soon as the
logfile is updated with new data I want some of the data to get into my
table in the database.

Johan




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

Date: Tue, 14 Nov 2000 17:28:14 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Is this possible in Perl?
Message-Id: <7ag0ku79ao.fsf@merlin.hyperchip.com>


Johan Augustsson <johan.augustsson@adm.gu.se> writes:

> Can I do the following with Perl?
> 
> Take some specific data from a logfile (which changes every now and
> then) and put it into a table in a MySQL-database. As soon as the
> logfile is updated with new data I want some of the data to get into my
> table in the database.

Yes, you can do this with Perl.

--Ala


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

Date: Tue, 14 Nov 2000 13:42:07 -0500
From: Jeff Boes <jboes@eomonitor.com>
Subject: Lizard gone?
Message-Id: <3a118959$0$30005$44a10c7e@news.net-link.net>

Looks like our local lizard is on vacation, eh? No posts here since
10/30...

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: 14 Nov 2000 10:27:58 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <m3hf5ah629.fsf@dhcp11-177.support.tivoli.com>

Bart Lateur <bart.lateur@skynet.be> writes:

> Garry Williams wrote:
> 
> >>Compact, but actually causes a bug: my password happened to 
> >>be "" so this sets it to undef.
> >
> 
> Simply drop it.
> 
>      $sh->{password} = shift(@args) || $ENV{DBI_PASS};
> 
> Without command line arguments, if the environment variable DBI_PASS
> doesn't exist, this will return undef; otherwise, it will return
> whatever $ENV{DBI_PASS} contains, even if it's "0" or "".

But that still has a problem if "" (or 0) is passed via @args.

  $sh->{password} = @args ? shift @args : $ENV{DBI_PASS};

-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 14 Nov 2000 08:36:39 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Newbee question, help wanted !
Message-Id: <3A116A17.F721F3E7@vpservices.com>

Ray wrote:
> 
>    my $refs = $header_hash{'References'};
>    my $firstref;
>    my $remref;
> 
>    ( $firstref , $remref ) = split(/ /, $refs, 2);
> 
>    $firstref =~ s/^\s+//;
> 
>    print "|".$refs."|".$firstref."|"<br>";

Can you spell R-E-D H-E-R-R-I-N-G?

Try to print $firstref after the split and before the s///.  Your
problem is not with stripping the blanks, it is with knowing how to use
split.  Experiment with things like split(/~/,'~a~b') printing out *all*
of the resulting fields.  What is the first field?  Then experiment 
with stripping blanks on the $refs before doing a split on it.  As I
said before, there is nothing at all wrong with your method of stripping
blanks and it will not (given the lower case \s) ever remove anything
other than blank spaces.  However an empty string, stripped of blanks,
is still empty.

I suspect from that "<br>" you are printing that Martien's PSI::ESP was
working better than mine and that you may also be having an HTML display
problem.  Make sure to debug the script from the command prompt, or at
the very least, to use "View Source" to see what is actually produced
rather than what your browser thinks it should display.


-- 
Jeff


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

Date: Tue, 14 Nov 2000 16:26:39 GMT
From: jponder9@my-deja.com
Subject: newbie perl > html question
Message-Id: <8urp3k$713$1@nnrp1.deja.com>

Hi all,
         I am using Perl on Winnt :-( My question is this - How can i
redirect a page of dynamic html output, to a file instead of just going
to the screen? So that when the file is opened, it displays as an html
format page?

thanx in advance
Jimbo


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


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

Date: 14 Nov 2000 09:08:58 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Newbie recursion question
Message-Id: <m3u29ah9px.fsf@dhcp11-177.support.tivoli.com>

Kai Jang <kai_jang@my-deja.com> writes:

> In article <t06qnq426m7r01@corp.supernews.com>,
>   "Randy Harris" <harrisr@bignet.net> wrote:
> >
> > Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
> > news:MUHM5.162$Bf7.170838528@news.frii.net...
> > > In article <8tvgnn$6d6$1@nnrp1.deja.com>,
> > > Kai Jang  <kai_jang@my-deja.com> wrote:
> > > >Hi.  Long time listner, first time caller.  :o)
> > > >
> > > >sub showit {
> > > > &showit($_[0]);
> > > > push (@dirs, $_) if ((-d $_) && ($_ !~m/^\.$/));
> > > > push (@files, $_) if (-f $_);
> > > >}
> >
> > A fine example of a loop as defined in the camel glossary.
> >
> >
> 
> The problem is that it is giving me that deep recursion error.  I am
> wondering if maybe there is a better way out there to print out the
> whole directory tree.  Maybe chdir???  Any ideas???  Thanks...

Perhaps you missed the point that Chris was making.  Your showit
subroutine immediately calls itself.  It will *never* get beyond that
call.

Does the File::Find module not do what you need?  Or perhaps I should
say, the File::Find module does what you need.  That being said, maybe
you are trying to do something like:

# Not fully tested, only briefly
sub showit {
  opendir my $dir, $_[0];
  chdir $_[0] or return;
  for (readdir $dir) {
    push @dirs, $_ and showit($_) if -d $_ && ! /^\.\.?$/;
    push @files, $_ if -f $_;
  }
  chdir "..";
}


-- 
Ren Maddox
ren@tivoli.com


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

Date: Tue, 14 Nov 2000 18:50:41 GMT
From: wslee00@hotmail.com
Subject: newline in the NT EventLog
Message-Id: <8us1ht$eve$1@nnrp1.deja.com>

Seems like \n is not the newline escape character for the NT EventLog.
What i'm trying to do is write a description in the EventLog that
contains newlines. Is this possible? Is there a different escape
character? Is there a function like newline() a la java that will do
that job?

--
will lee     wslee00@hotmail.com


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


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

Date: Tue, 14 Nov 2000 08:29:53 -0800
From: "GC" <geoff@800-800-cruise.com>
Subject: Re: OK - I'm stupid. Please help.
Message-Id: <jKdQ5.21682$Ma3.801176@nntp2.onemain.com>

This worked wonderfully. Thank you! And thank you for the 'tutorial.'
Armed with your note and briefing I was able to put it all together,
tested, formatted and deployed in < 20 minutes. Thanks again!

Geoff

"Kurt Stephens" <kstep@pepsdesign.com> wrote in message

> I'm not sure that I understand your question, but it sounds like you
want to
> read a file on a remote server from a script running on your domain.
To do
> this, the your server needs to pretend that it's a browser and access
the
> URL of the remote host.  The LWP::UserAgent class allows you to do
just
> that.  The process is fairly simple - read the documentation for the
> LWP::UserAgent, HTTP::Request and HTTP::Response modules.  These are
all
> available as part of the LWP bundle.
>
> # begin code
>
> use LWP::UserAgent;
>
> my $ua = LWP::UserAgent->new;
> my $request = HTTP::Request->new('GET',
> 'http://some.other.domain.com/file.html');
>
> my $response = $ua->request($request);
>
>  if ($response ->is_success) {
>      # Process the html...
>  } else {
>      print $response ->error_as_HTML;
>  }
>
> # end code





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

Date: Tue, 14 Nov 2000 11:03:20 -0600
From: "Michael Segulja" <michael.segulja@sgi-lsi.com>
Subject: Perl code not doing what I expected
Message-Id: <3a116f6a$1_2@newsa.ev1.net>

I have a very simple and plain web page with a drop down list menu to
organize my MP3 files.  Based on the choice, a CGI script will query the
MySQL database and return the appropriate result.  The choices are Artist
Name, Album Name, or Song Name.  I have a field in my database for each
respectively, named 'artist', 'album', 'title'.  My Perl code is below:

-- Begin Perl Code --

#!/usr/bin/perl -w -d

use diagnostics;
use strict;
use CGI;
use DBI;

my $db = "mp3db";
my $host = "localhost";
my $user = "mp3";
my $password = "mp3pass";
my $statementArtist = "SELECT DISTINCT artist FROM mp3main";
my $statementAlbum = "SELECT DISTINCT album FROM mp3main";
my $statementTitle = "SELECT title FROM mp3main";
my @ary;

my $cgiobject = new CGI;
print $cgiobject->header;

# Retrieve CGI paramaters.
my $returnField = $cgiobject->param("query");

print "$returnField\n";

# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host",
      $user, $password, {PrintError => 1, RaiseError => 1});

# Query table mp3main on artist and return the results.
if ($returnField = /artist/) {
      my $ary_ref = $dbh->selectall_arrayref($statementArtist);

 foreach my $item(@$ary_ref) {
       push @ary, $item->[0];
          }
}
else {
 my $ary_ref = $dbh->selectall_arrayref($statementAlbum);

 foreach my $item(@$ary_ref) {
  push @ary, $item->[0];
     }
}

print "$_\n" for @ary;

# Disconnect from the database.
$dbh->disconnect;

-- End Perl code --


Currently, I have the value for $returnField printing to my webpage, and it
is correct based on the choice I make in my drop down menu.  However,
regardless of what I choose, the $statementAlbum query is ran, and I'm not
sure why.  Obviously, '$returnField = /artist/' is not doing what it should.
I haven't even tried to put all three querys in yet until this works.  What
am I doing wrong?  I thought this was the correct way to match a string of
characters, but I'm sure I'm doing something stupid.

I really appreciate any help anybody can give me.

Thanks,

Michael




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

Date: Tue, 14 Nov 2000 17:19:02 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Perl code not doing what I expected
Message-Id: <slrn912t1p.ilu.rgarciasuarez@rafael.kazibao.net>

Michael Segulja wrote in comp.lang.perl.misc:
[snip]
>if ($returnField = /artist/) {
[snip]

if ($returnField =~ /artist/) { ...

or (other choices, depending on your needs):

if ($returnField =~ /artist/i) { ...
if ($returnField eq 'artist') { ...

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 14 Nov 2000 11:34:45 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Perl code not doing what I expected
Message-Id: <3A1177B5.5AD5815E@mail.uca.edu>

Michael Segulja wrote:
> 
> Currently, I have the value for $returnField printing to my webpage, and it
> is correct based on the choice I make in my drop down menu.  However,
> regardless of what I choose, the $statementAlbum query is ran, and I'm not
> sure why.  Obviously, '$returnField = /artist/' is not doing what it should.

You want to do a comparison, but you are actually SETTING the value of
$returnField to /artist/, and since you are doing this, the value of the
if is "true." The numerical comparison operator is "==" but you actually
want the string comparison operator "eq".

See perlop for details.

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Tue, 14 Nov 2000 15:46:10 +0100
From: Marcel Aarts <demonic_warrior@bluewin.ch>
Subject: Perl with VB Gui
Message-Id: <3A115032.52E5E033@bluewin.ch>

I would like to write Perl programs under Win32 and give them a Visual
Basic GUI. Does anyone know where I can find tutors or articles on this?

Thx in advance



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

Date: Tue, 14 Nov 2000 11:31:06 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Perl with VB Gui
Message-Id: <8urpc1$gtv$1@slb0.atl.mindspring.net>

"Marcel Aarts" <demonic_warrior@bluewin.ch> wrote in message
news:3A115032.52E5E033@bluewin.ch...
> I would like to write Perl programs under Win32 and give them a Visual
> Basic GUI. Does anyone know where I can find tutors or articles on this?
>
> Thx in advance
>

Reminds me of the South Park episode about the pig and the elephant  -
haven't you ever heard that song by Loverboy?

One possibility is to use the ActiveState Perl Development Kit (PDK).  This
allows you to create COM components in Perl that you can call from your VB
program.  Unlike Perl itself, this is not freeware - I believe it costs
$129; check out www.activestate.com for details.

If you just want to automate the process of calling scripts, you can gather
user input in VB, construct a command line, and run the script using the VB
shell command.  I have written several Access applications that do just
that.  This is a good way to automate file manipulation and data conversion
tasks that are painful in VB but simple in Perl.

The Win32::OLE module allows you to interact with Windows applications via
OLE automation. For example, you can create a MS Word Application object and
access its various (and many) properties and methods.  Support for events is
new and experimental, so there probably won't be much interaction between
the user and the perl script itself.  This approach would lend itself to the
scenario below:

1) The user clicks a button in the VB app

2) The VB app executes a perl script using the 'Shell' command

3) The perl script performs some actions that you really don't want to do in
VB, runs Excel, creates a new worksheet, saves the workbook and spools the
sheet it to the default printer.

If you want to write GUI programs in Perl, you should look into the Tk
modules - This is a GUI based on the Unix X-Windows system, with
implementations running on Windows, Linux and Macintosh.  The overall
architecture, with callback functions triggered by GUI events is similar to
VB, but the learning curve will still be steep.

Hopefully this helps,

Kurt Stephens
Pepsdesign





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

Date: Tue, 14 Nov 2000 10:27:46 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl32
Message-Id: <3A118422.FB9F9882@vpservices.com>

Marshall Thomas wrote:
> 
> Go ahead and put in the normal stuff like "#!/usr/bin/perl" in your
> source file, you want to maintain platform independence,
> however Winbloze does not care about it at all.

If you mean that it doesn't matter what the shebang line is on a script
running on windows, you are wrong in at least one, and possibly several
ways.  First, when you run a script with a shebang line such as
"#!/usr/bin/perl -Tw" that line will not be used by windows to determine
where the perl executable is, *but* it will be used to set the options
to taint mode and warnings on.  Second, if one is using a web server
such as apache, then, even on windows, apache uses the shebang line to
determine where the perl executable is so it must be correct for the
user's setup.

> I haven't bothered with this on my Win98 machine because the command
> line shell window support is almost worthless on win98.

That is a gross overstatement.  I am able to test 95% of my unix-aimed
scripts on a win98 box and have been doing that since win3.1.  I am no
fan of M$, nor do I particularly like win/DOS, but to mislead newbies
into thinking that they can not do many many things with Perl on a win98
box is, well, misleading.

-- 
Jeff


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

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


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