[19092] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1287 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 11 18:05:49 2001

Date: Wed, 11 Jul 2001 15:05:21 -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: <994889121-v10-i1287@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 11 Jul 2001     Volume: 10 Number: 1287

Today's topics:
    Re: Accessing a Variable whose Name is in a String <mjcarman@home.com>
    Re: Active State (Drew)
        argument in regular expression <leclerc.fabrice@wanadoo.fr>
    Re: argument in regular expression <krahnj@acm.org>
        C libraries usage in Perl <kirbyr@ucar.edu>
    Re: C libraries usage in Perl <newspost@coppit.org>
    Re: calling C program executable from perl and return v (F. Xavier Noria)
    Re: Causing a slow page delivery (on purpose) (Scott Porter)
    Re: Causing a slow page delivery (on purpose) <goldbb2@earthlink.net>
    Re: Complete hash of an array <goldbb2@earthlink.net>
        Crypt-SSLeay (Mike)
    Re: Data structures question. ctcgag@hotmail.com
    Re: Data structures question. <iltzu@sci.invalid>
    Re: DBase type for Banner Exchange script (Logan Shaw)
    Re: double key for hashtable <goldbb2@earthlink.net>
    Re: FAQ : How can I open a pipe both to and from a comm <goldbb2@earthlink.net>
        FAQ: Where can I get information on Perl? <faq@denver.pm.org>
    Re: ftp script <goldbb2@earthlink.net>
        Help with a Web page problem <spisholiwriter@hotmail.com>
        How popular is Python, anyway? (was: Long Live Python!) (phil hunt)
    Re: How popular is Python, anyway? (was: Long Live Pyth (Gergo Barany)
        HTML::LinkExtor problem. <zakaria1@hotmail.com>
    Re: HTML::LinkExtor problem. (Eric Bohlman)
    Re: I'm starting to think our 5.6 install is braindead <ns@cfl.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 11 Jul 2001 13:11:23 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Accessing a Variable whose Name is in a String
Message-Id: <3B4C96CB.EC685DE6@home.com>

Tad McClellan wrote:
> 
> Michael Carman <mjcarman@home.com> wrote:
>> Kevin Chen wrote:
>>>
>>> Is it possible to access a variable whose name is in another
>>> variable?
>
>>> What if $b = "2"?  Can I access $name2 or $name[2] using a
>>> combination of $a and $b?
> 
>>There is no good way to access $name2 using (both) $a and $b,
>             ^^^^
> 
> There is _a_ way though:

[snip symref example]

Yes, "good" was the key word there, and the omission of the alternative
was not in error. :)

-mjc


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

Date: 11 Jul 2001 12:21:53 -0700
From: cmdir@juno.com (Drew)
Subject: Re: Active State
Message-Id: <c5ee209c.0107111121.587a7232@posting.google.com>

"Adam Stewart" <Stewy@Chartermi.net> wrote in message news:<tkoose7di0467d@corp.supernews.com>...
> For a while now I have been interested in learning perl. So I recently
> installed Active State Perl on my computer. My operating system is Windows
> 98, just so you know. First thing is it says to run there example program to
> make sure it is working correctly. Now the problem is where do I run this
> program from? It says to type <perl example.pl> at the command line, but it
> doesnt say where this command line is, and i've looked all over with out
> success.
> 
> Does anyone understand what I am saying? Your help is appreciated. Actualy I
> would prefer for you to email me than to respond here as I may not get back
> here for a few days.
> 
> Thank you,
> Stewyyyyyyyy


"Command line" refers to does command prompt.  click "start" -> "run"
-> type "command".  use the CD command to get the directory where the
file is.  then type "perl example.pl".


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

Date: Wed, 11 Jul 2001 22:58:44 +0200
From: Fabrice Leclerc <leclerc.fabrice@wanadoo.fr>
Subject: argument in regular expression
Message-Id: <leclerc.fabrice-DA71A5.22584411072001@news.wanadoo.fr>

Hi,
I'm just stating to use perl for some search of regular patterns. I'm 
trying to pass an argument in a regular expression and I have some 
trouble with the syntax.
Can somebody give the correct syntax in the following example ? 
I use a loop to increment i from 1 to 3000 in the following command:

perl -ne '$/ = "\n\n"; print if (/position:$i-/);' input >> output

what is the correct syntax to have the variable i replaced in the 
searched pattern by its value ?


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

Date: Wed, 11 Jul 2001 21:42:07 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: argument in regular expression
Message-Id: <3B4CC82B.590A8A17@acm.org>

Fabrice Leclerc wrote:
> 
> Hi,
> I'm just stating to use perl for some search of regular patterns. I'm
> trying to pass an argument in a regular expression and I have some
> trouble with the syntax.
> Can somebody give the correct syntax in the following example ?
> I use a loop to increment i from 1 to 3000 in the following command:

There is no loop incrementing $i in your example.


> perl -ne '$/ = "\n\n"; print if (/position:$i-/);' input >> output
> 
> what is the correct syntax to have the variable i replaced in the
> searched pattern by its value ?

Are you trying to find a string with the text "position:" followed by a
number in the range 1-3000 followed by "-"?

perl -ne '$/ = "\n\n"; print if /position:(\d+)-/ and $1 >= 1 and $1 <=
3000;' input >> output



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 11 Jul 2001 13:13:00 -0600
From: Rob Kirby <kirbyr@ucar.edu>
Subject: C libraries usage in Perl
Message-Id: <3B4CA53C.5DD666D4@ucar.edu>


Hi,

I am fairly new to Perl in the respect that my experience is
in writing textbook code and inheriting a lot of code, but all within the
realm of stuff I can easily find in my Perl books.

I have also inherited a massive amount of C code that I am 
trying to support and it makes calls to shared libraries. I believe
I could rewrite much of the C code in Perl, but there are some
shared libraries that are vendor supplied and I can't rewrite
those. 

So, here is my newbie question. I want to be able to integrate
calls to a vendor supplied API, which consists basically of one
C include file and the shared library. I'm sure there is a way
to do this, and I just need a push in the right direction.

Thanks,


-- 
Rob Kirby - [mailto:kirbyr@ucar.edu][http://www.ncar.ucar.edu]
--
"We can do noble acts without ruling the earth and sea." Aristotle


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

Date: Wed, 11 Jul 2001 17:10:54 -0400
From: David Coppit <newspost@coppit.org>
To: kirbyr@ucar.edu
Subject: Re: C libraries usage in Perl
Message-Id: <3B4CC0DE.8090805@coppit.org>

[posted & mailed]

Rob Kirby wrote:

> So, here is my newbie question. I want to be able to integrate
> calls to a vendor supplied API, which consists basically of one
> C include file and the shared library. I'm sure there is a way
> to do this, and I just need a push in the right direction.


Welcome to Perl. :)

Two ways:
- Painful XS: "perldoc xstut" to get started
- Less painful (even fun) way: get "Inline" from CPAN, "perldoc Inline"

David



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

Date: 11 Jul 2001 22:26:01 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: calling C program executable from perl and return value...
Message-Id: <9iijpp$3fv995@news1s.iddeo2.es>

On Tue, 10 Jul 2001 15:00:16 -0700, Mike Goettemoeller <goette@ti.com> wrote:

: I'm trying to call the 'system' function to execute a C executable and
: return the value sent to STDOUT to a variable in Perl.  I'm sure this is
: easy...but, am having difficulty.
: 
: I tried this:
: 
: $val = system("/users/x/c_program")

perldoc -q 'get the output of a command'

-- fxn


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

Date: Wed, 11 Jul 2001 18:27:43 GMT
From: scott@nospamthankx.javascript-games.org (Scott Porter)
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3b4c9a58.384140@news.freeserve.co.uk>

On Tue, 10 Jul 2001 21:16:47 GMT, Akira Yamanita <ayamanita.nospam@bigfoot.com>
wrote:

>Scott Porter wrote:
>> 
>> I'm using the apache server on Linux; my goal is to delivery a page incrementally to
>> the browser, so it can delivery constantly changing data as a "stream". While this
>> works fine with a java app, bypassing apache, it doesn't give the required results
>> under apache. The page shows no data until the perl script exits. Is it possible to
>> send content that forces apache to flush whatever the perl script has passed on to
>> the browser, or is it impossible?
>> 
>> The reason for having to serve via apache is because my web host doesn't allow java
>> servlets, or "persistant" scripts (which kind of rules out writing a daemon!)
>> 
>> Any help appreciated!
>
>Disable output buffering. Put the following line at/near the beginning
>of your script.
>$| = 1;

Hmm, just tried that and still the same results. Maybe I need to add more headers? At
present I just send out the usual "Content-type: text/html\n\n" header. Could I send
more, or does Apache intercept this?



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

Date: Wed, 11 Jul 2001 17:39:59 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Causing a slow page delivery (on purpose)
Message-Id: <3B4CC7AF.1086AB3A@earthlink.net>

Scott Porter wrote:
> 
> I'm using the apache server on Linux; my goal is to delivery a page
> incrementally to the browser, so it can delivery constantly changing
> data as a "stream". While this works fine with a java app, bypassing
> apache, it doesn't give the required results under apache. The page
> shows no data until the perl script exits. Is it possible to send
> content that forces apache to flush whatever the perl script has
> passed on to the browser, or is it impossible?
> 
> The reason for having to serve via apache is because my web host
> doesn't allow java servlets, or "persistant" scripts (which kind of
> rules out writing a daemon!)

There are a number of possible reasons.
 * Consider is $|, which controlls buffering.  Turn it off if you want
to avoid buffering.
 * If you are ending lines with \n, and the browser is reading lines
split on \r\n, it will not display until it either sees a \r\n or an
EOF.
 * If you have some piece of html which your browser can't display until
it's recieved all of it.  Tables are one of the most common sources of
this problem -- to fix it, you need a COL or COLGROUP tag.  Images are
similar -- add a width and a height.
 * A proxy may be present, possibly doing some buffering itself.  How to
turn off buffering there depends on the proxy.

I would suggest you try the following CGI program:

#! perl -w
use strict;
my $crlf = "\015\012"; # \r\n
print "Content-type: text/plain", $crlf x 2;
for( 1..20 ) {
	print "x" . "\012";
	sleep 3;
	print "y" . $crlf;
	sleep 3;
}

If the program doesn't print at all, then the problem is due to a proxy.
If the program prints 'xy', then pauses, then prints xy, etc. then the
problem can be seen to be your newline.  If it prints x, pauses, prints
y, pauses, etc, then the problem is due to a piece of html which needs
to be entirely recieved before the browser can display it.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Wed, 11 Jul 2001 14:26:40 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Complete hash of an array
Message-Id: <3B4C9A60.5F23BC0@earthlink.net>

JohnShep wrote:
> 
> I thought I had this array/hash business figured but I'm really losing
> it on this one.
> 
> my %ratings;
> while (my $ref = $sth->fetchrow_arrayref) {
> 
>      if (!$ratings{$$ref[3]}{"now"}) {
>           $ratings{$$ref[3]}{"now"} = 1000;
>           $ratings{$$ref[3]}{"max"} = 1000;
>      }
> 
>      (ratings{$$ref[3]}{"now"})  = get_rating_now($$ref[3]);
>      (ratings{$$ref[3]}{"max"})  = get_rating_max($$ref[3]);
> }

This code can't work, since you don't have a $ in front of ratings in
the latter two places you use it.  I'm guessing you copied rather than
cut&pasted it.  Don't do that.  Also, this could be made clearer if you
use some temp variables.

my %ratings;
$sth->bind_col( 4, \(my $name) );
while( $sth->fetch ) {
	my $rats = ( $ratings{$name} ||= {} );
	@$rats{now,max} = (1000, 1000) unless $rats->{now};
	$rats{now} = get_rating_now $name;
	$rats{max} = get_rating_max $name;
}

> OK so far I think, but how do I iterate through %ratings to update the
> database with the new values ?

This is two questions: how do I iterate, and how do I update?
The first is easier: use keys or each.
The second is harder: it depends on what kind of database you're using.

To use each to iterate, do something like this:
	while( my ($key, $val) = each %hash ) {
		# do stuff with $key and $val.
	}

To use keys to iterate, do something like tihs:
	for my $key (keys %hash) {
		my $val = $hash{$key};
		# do stuff with $key and $val.
	}

Unless you need to work in sorted order, then you should use the
while/each construct instead of the for/keys construct.

And for updating...
$sth = $dbh->prepare( q{
	UPDATE tablename
	SET now = ?, max = ?
	WHERE col3name = ?
} );
while( my( $name, $rats ) = each %ratings ) {
	$sth->execute( @$rats{name,max}, $name );
}
$dbh->commit unless $dbh->{AutoCommit};
$dbh->disconnect;

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: 11 Jul 2001 13:15:34 -0700
From: michael_of_neb@yahoo.com (Mike)
Subject: Crypt-SSLeay
Message-Id: <5a10590e.0107111215.6ac35b92@posting.google.com>

Hi.
I have ben trying to get SSLeay to work on my system(s).

The Active state version of Perl on my Windows 98 box, version
ActivePerl-5.6.0.623-MSWin32-x86-multi-thread.msi
has not presented any other significant problems so far..

BUT
when I try to do: 
C:\Perl> ppm
PPM> install Crypt-SSLeay
Install package 'Crypt-SSLeay?' (y/N)y
Installing package 'Crypt-SSLeay'...

I get a litle red and blue window:
 This program has performed an illegal operation
 and will be shut down.
 If the problem persists, contact the program
 vendor.

Does anyone have a solution for this ?

Mike


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

Date: 11 Jul 2001 20:15:47 GMT
From: ctcgag@hotmail.com
Subject: Re: Data structures question.
Message-Id: <20010711161546.494$e0@newsreader.com>

garry_short@hotmail.com (Garry) wrote:
> Hello.
>
> I'm trying to work out one of two things, assuming either is possible.

Of course they are.

> The first option is a 2d array, 9 columns wide by 10k+ rows deep.

OK, I'll assume that's @x[$col][$row]

> Is
> it possible to sort the array by the nth row?

I'll assume you mean $nth column, just because that's the way I think of
it, and I'm pretty sure that's what you meant anyway.

> If so, could anyone give
> me some pointers on how to do it?

assuming that you want to sort text (rather than numbers), here's a way:

@index = sort {  $x[$nth][$a] cmp $x[$nth][$b] } (0..$#x);
@sortedx= @x(@index);

You can chain together to get rid of the @index variable if you want.
It's there for pedagogical poirposes only.

> Better still, can I sort that array by multiple columns, as per Excel?

@index = sort {  $x[$nth1][$a] cmp $x[$nth1][$b]
                              ||
                 $x[$nth2][$a] cmp $x[$nth2][$b]
                              ||
                 $x[$nth3][$a] cmp $x[$nth3][$b]  } (0..$#x);

Here, you only look at the $nth3 column if both $nth2 and $nth1 have
already compared equal.


> If so, does anyone what's the maximum number of columns I can sort by?

Depends on where/when your computer pukes.

Xho


> --
>
> Assuming that's not possible, has anyone got any suggestions on
> implementing the following data structure :
>
> array of (unique SRC_IP,
>   array of (unique SRC_PORT,
>     array of (unique DEST_IP,
>       array of (unique DEST_PORT,
>         array of (unique PROTOCOL,
>           array of (unique DATE,
>             array of (unique TIME,
>               array of (TYPE, CODE)
>             )
>           )
>         )
>       )
>     )
>   )
> )

I would suggest not implementing it.  Or at least implementing it as
chained hashes rather than chained arrays.


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
                    Usenet Newsgroup Service


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

Date: 11 Jul 2001 20:18:40 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Data structures question.
Message-Id: <994881363.25260@itz.pp.sci.fi>

In article <bdcefd33.0107100629.7e970dcf@posting.google.com>, Garry wrote:
>
>The first option is a 2d array, 9 columns wide by 10k+ rows deep. Is
>it possible to sort the array by the nth row? If so, could anyone give
>me some pointers on how to do it?

You mean by the Nth column, right?  Easy enough:

  my @sorted = sort { $a->[23] <=> $b->[23] } @array_of_arrays;


>Better still, can I sort that array by multiple columns, as per Excel?

Sure!

  my @sorted = sort {
      $a->[5] <=> $b->[5] or  # ascending numerical by col 5..
      $b->[7] cmp $a->[7] or  # descending lexicographic by col 7..
      $a->[0] cmp $b->[0] or  # ascending lexicographic by col 0..
      $b->[4] <=> $a->[4] or  # descending numerical by col 4..
      0;  # okay, they're equal then!
  } @unsorted;

      
>If so, does anyone what's the maximum number of columns I can sort by?

As many as you want.  Just keep adding lines to the code above.


>Again, any pointers on how to do it would be appreciated!

There are some advanced sorting techniques that aim to speed up the
comparisons by precomputing a sort key for each record, but for simple
cases like yours they're probably overkill.  Even for 10k+ rows.

If you're interested, look up "Schwartzian transform" and "Guttman-
Rosler transform" on the web.  I think there are also some related
modules at the CPAN -- typing "Sort" at http://search.cpan.org/ should
find them.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post something,
we discuss its implications.  If the discussion happens to answer a question
you've asked, that's incidental."           -- nobull in comp.lang.perl.misc

 


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

Date: 11 Jul 2001 16:10:56 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: DBase type for Banner Exchange script
Message-Id: <9iifd0$d19$1@charity.cs.utexas.edu>

In article <tkp3namcllk38d@corp.supernews.com>,
Mr. Ed <giddeyup@derby.com> wrote:
>I'm creating a banner exchange script  in Perl on Unix that will allow users
>to sign up online and do the normal process of entering their info - I'm
>wondering about the database, as I am more an ASP programmer- what would be
>the best way to go as far as a flat-file database process, or similar one
>that would work with a dynamic environment.

Since the database presumably will be small and will change
infrequently, a flat file database is a reasonable decision.
(Well, unless you need to access it from multiple machines.)

In fact, under the right conditions (a really small amount of
data and few changes to it), reading a flat file will require
a lot less overhead than querying a "real" database.

To make sure the flat file doesn't get corrupted, you'll
want to use locking:  shared locks for processes that
read it and exclusive ones for processes that update it.
"perldoc -f flock" will give you information on how to do
shared and exclusive locks.

As for the format, that depends on what you're going to store in it.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Wed, 11 Jul 2001 15:38:38 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: double key for hashtable
Message-Id: <3B4CAB3E.2752DD05@earthlink.net>

Mark Grimshaw wrote:
> 
> Benjamin Goldberg wrote:
> >
> > Torsten Drees wrote:
> > >
> > > Hi people,
> > >
> > > i have an interesting problem. i wrote two records in a hash table
> > > with the same key. Is it possible to get back, both records.
> > > If not, is it possible to define a subkey?
> >
> > You can, though it's not exactly pretty.
> >
> > use DB_File;
> > $DB_TREE->{flags} |= R_DUP; # allow duplicate keys.
> >
> > my $d = tie my %hash, "DB_File", undef, O_CREAT|O_RDWR, undef, $DB_TREE;
> > # create an in-memory db_file.
> 
> Perhaps I'm wrong, but isn't that $DB_BTREE?  I'm going off pp 387-392
> of Camel 2nd. edition.
>                                       ^

Yes, I typoed.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Wed, 11 Jul 2001 14:48:50 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: FAQ : How can I open a pipe both to and from a command?
Message-Id: <3B4C9F92.1499AD55@earthlink.net>

Gildas PERROT wrote:
> 
> Hi,
> 
> I saw the FAQ about that question in
> http://www.perldoc.com/perl5.6/pod/perlfaq8.html but I have
> difficulties to implement it. Here is the program :
> 
> #!/usr/bin/perl
> 
> $cmd = "grep test";
> $in = "test\nteste\n";
> 
> require 'Comm.pl';
> &Comm'init();
> 
> $ph = open_proc($cmd);
> print $ph $in;
> while ($out = <$ph>) {
> print "OUT : $out\n";
> }
> 
> The first problem is the warning message I have on Redhat 6.2 :
> 
> stty: standard input: Inappropriate ioctl for device
> 
> The second one is that I need to be root to launch that program or I
> have :
> 
> could not open slave, /dev/pts258, errno=Permission denied at
> /usr/lib/perl5/site_perl/5.005/Comm.pl line 1342.
> 
> Any idea about those problems ? Thanks in advance for your help.

Yes, the solution is to not use Comm.pl, which appears [from the way you
use it, as I haven't actually looked if I have it on my system, nor
looked what it contains], to be a perl4 library.

#!/usr/bin/perl -w
use IPC::Open2;
local (*GREPIN, *GREPOUT);
my $pid = open2( \*GREPOUT, \*GREPIN, "grep test" )
	or die "Couldn't fork: $!\n";
print GREPIN "test\nteste\n";
close GREPIN;
print "OUT: $_" while( <GREPOUT> );
waitpid($pid, 0) or die "Waitpid failed: $!"
if( $? ) {
	my( $ret, $sig ) = ( $?/256, $?%256 );
	die "grep died from signal $sig\n" if $sig;
	die "grep exited with code $ret\n" if $ret;
} else {
	print "grep exited successfully\n";
}

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Wed, 11 Jul 2001 18:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: Where can I get information on Perl?
Message-Id: <yK037.28$T3.170758656@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Where can I get information on Perl?

    The complete Perl documentation is available with the Perl distribution.
    If you have Perl installed locally, you probably have the documentation
    installed as well: type "man perl" if you're on a system resembling
    Unix. This will lead you to other important man pages, including how to
    set your $MANPATH. If you're not on a Unix system, access to the
    documentation will be different; for example, documentation might only
    be in HTML format. All proper Perl installations have fully-accessible
    documentation.

    You might also try "perldoc perl" in case your system doesn't have a
    proper man command, or it's been misinstalled. If that doesn't work, try
    looking in /usr/local/lib/perl5/pod for documentation.

    If all else fails, consult http://perldoc.cpan.org/ or
    http://www.perldoc.com/ both offer the complete documentation in html
    format.

    Many good books have been written about Perl--see the section below for
    more details.

    Tutorial documents are included in current or upcoming Perl releases
    include the perltoot manpage for objects or the perlboot manpage for a
    beginner's approach to objects, the perlopentut manpage for file opening
    semantics, the perlreftut manpage for managing references, the perlretut
    manpage for regular expressions, the perlthrtut manpage for threads, the
    perldebtut manpage for debugging, and the perlxstut manpage for linking
    C and Perl together. There may be more by the time you read this. The
    following URLs might also be of assistance:

        http://perldoc.cpan.org/
        http://www.perldoc.com/
        http://reference.perl.com/query.cgi?tutorials
        http://bookmarks.cpan.org/search.cgi?cat=Training%2FTutorials

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           02.08
-- 
    This space intentionally left blank


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

Date: Wed, 11 Jul 2001 17:12:22 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ftp script
Message-Id: <3B4CC136.BA312131@earthlink.net>

Todd Smith wrote:
> 
> How can I write a script to try to log in to an ftp server for me, and
> if there are too many users, wait a few minutes and try again? But the
> thing is, if it gets in, I need to have a normal ftp shell and I need
> it to keep the connection alive until I check back with the program.

Use the Expect module.

use Expect;

my $remotehost = "hostname";
my $userid = "anonymous";
my $passwd = "email@host.com";
my $ftp;
{
	open2( \*RD, \*WR, "ftp", $remotehost );
	select( (select WR, $|=1)[0] );
	$ftp = Expect->new( \*RD );
	defined $ftp->expect( undef, -re => qr/^Name .*: /s ) or redo;
	print WR $userid, "\n";
	defined $ftp->expect( undef, -re => qr/^Password: / ) or redo;
	print WR $passwd, "\n";
	defined $ftp->expect( undef, -re => qr/^230 / ) or redo;
}
if( my $pid = fork ) {
	$ftp->interact;
} elsif( defined $pid ) {
	print while <WR>;
} else {
	die "Couldn't fork: $!\n";
}
__END__
	

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Wed, 11 Jul 2001 20:59:21 GMT
From: "Sector" <spisholiwriter@hotmail.com>
Subject: Help with a Web page problem
Message-Id: <J6337.40384$J91.1928985@bgtnsc06-news.ops.worldnet.att.net>

I need help with a web page problem. My page displays someone else's page on
the left frame. I have a link on my frame that the person can click to find
information about the other persons webpage. I have the script to get
information about there website. I just need some code to add to my script,
that can display the right frame's full url so my script can find the page
on the other server. Maybe putting that URL into a scalar variable. If
anyone can help it will be greatly appreciated.




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

Date: Wed, 11 Jul 2001 15:26:02 +0100
From: philh@comuno.freeserve.co.uk (phil hunt)
Subject: How popular is Python, anyway? (was: Long Live Python!)
Message-Id: <slrn9koofo.mjk.philh@comuno.freeserve.co.uk>

On Tue, 10 Jul 2001 15:31:11 -0700, Paul Prescod <paulp@ActiveState.com> wrote:
>Perl, Java and PHP all grew popular by solving a particular problem at a
>particular time, better than any other language. (I'm thinking of system
>administration/CGI, Applets and web page generation). Perl and Java grew
>into general purpose languages over time. The jury is still out on PHP.

Popularity as a langauge for open source projects can be measured
by looking at Sourceforge's statistics.

From http://sourceforge.net/softwaremap/trove_list.php?form_cat=160
we have these figures:

C++      4078
C        4889
Java     2739 
Perl     2142 
PHP      1999 
Python    934
Shell     439
VB        390
Tcl       326 

So Python is the 6th most popular language for open source development.

Out of interest, here's the figures for some other languages:

JavaScript  269
Delphi   252
Pascal   110
Object Pascal 59 (total pascal-like = 421)
PL/SQL 237
Ruby 31
Lisp 122
Scheme  74  (total lisplike = 196)
Smalltalk 20



On 27 April 2001, I took this list from Sourceforge:

C         4250
C++       3458
Java      2252
Perl      1840
PHP       1652
Python     773
Unix Shell 380
Visual Basic 306
Tcl        279
Delphi     191
JavaScript 183


That was about 2 1/2 months ago. Subtracting, we can see what's
popular for new development. Analysing these figures, we get:

Language  27Apr 11Jul %age   diff %age   Diff %age
C         4250  4889  26.49  639  22.09  -4.4
C++       3458  4078  22.09  620  21.43  -0.66
Java      2252  2739  14.84  487  16.83   1.99
PHP       1652  1999  10.83  347  11.99   1.16
Perl      1840  2142  11.61  302  10.44  -1.17
Python     773   934   5.06  161   5.57   0.5
JavaScript 183   269   1.46   86   2.97   1.52
VBasic     306   390   2.11   84   2.9    0.79
Delphi     191   252   1.37   61   2.11   0.74
Shell      380   439   2.38   59   2.04  -0.34
Tcl        279   326   1.77   47   1.62  -0.14

Total    15564 18457        2893

In terms of new projects, Python is still 6th, but its %age
share has gone up. This means it is increasing in popularity
compared to the other languages in the table (though not 
necessarily compared to all languages).

The lang with the biggest increase in share is Java. The one
with the diggest decrease is C, though is is still the most popular
lang for new OSS projects.


-- 
## Philip Hunt ## philh@comuno.freeserve.co.uk ##




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

Date: 11 Jul 2001 21:20:02 GMT
From: gergo.barany@gmx.net (Gergo Barany)
Subject: Re: How popular is Python, anyway? (was: Long Live Python!)
Message-Id: <slrn9kpgtq.5ug.gergo.barany@hold.otthon.at>

phil hunt <philh@comuno.freeserve.co.uk> wrote:
> [snip flamebait crap]

If anyone is going to to respond to this thread, *please* take
comp.lang.c out of the Newsgroups: list. We don't do advocacy here.
Followups set.
Thanks,

Gergo

-- 
When in doubt, follow your heart.


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

Date: Wed, 11 Jul 2001 11:00:43 -0400
From: zak <zakaria1@hotmail.com>
Subject: HTML::LinkExtor problem.
Message-Id: <3B4C6A1B.3C352E17@hotmail.com>

Hi,
I am using the HTML::linkExtor to parse a file in my computer, I used:

my $parser = HTML::LinkExtor->new();
 $parser->parse_file("index.htm");
 my($tag, %links)=$parser->links();
 print "$tag @{[%links]}\n";

the output looks like :
(0x17996e4) ARRAY(0x1794878) ARRAY(0x179497
ARRAY(0x17948e4)  ARRAY(0x17aee98) ARRAY(0x
ef04) ARRAY(0x17949d4) ARRAY(0x17997f8) ARR
0x1794bcc) ARRAY(0x17aeda8) ARRAY(0x1765170
RRAY(0x1792d10) ARRAY(0x1792c98) ARRAY(0x17

when I tried to use :

my ($ref)= $links{$key};
my ($url)= $ref->as_string();

I got an error saying cant use as_string() with a non-blessed reference.
I dont understand the message and I dont know how to make the results as
a viewable text.

Please help.



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

Date: 11 Jul 2001 21:23:15 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: HTML::LinkExtor problem.
Message-Id: <9iig43$52p$1@bob.news.rcn.net>

zak <zakaria1@hotmail.com> wrote:
> Hi,
> I am using the HTML::linkExtor to parse a file in my computer, I used:

> my $parser = HTML::LinkExtor->new();
>  $parser->parse_file("index.htm");
>  my($tag, %links)=$parser->links();

links() returns a list of array references; each array looks like what you 
have there.  So you need to loop over the references:

foreach ($parser->links()) {
  my($tag,%links)=@$_;
  # do something with info
}


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

Date: Wed, 11 Jul 2001 20:34:56 GMT
From: tuxy <ns@cfl.rr.com>
Subject: Re: I'm starting to think our 5.6 install is braindead
Message-Id: <3B4CB940.7E7E1903@cfl.rr.com>

Philip Newton wrote:
> 
> On Tue, 10 Jul 2001 22:07:34 GMT, tuxy <ns@cfl.rr.com> wrote:
> 
> > OK, I'm in the debugger (perl -wd) and I'm examining a scalar. Watch and
> > be amused:
> >
> >
> >  91:             $c += 2;
> >   DB<55> x $c
> >  0  106
> >   DB<56> x $c+2
> >  0  108
> >    DB<57> s
> >  doctorLine(x.pm:93):
> >  93:         s/^(\s*TEST\s+)\S+$/$1$c/;
> >   DB<57> x $c
> >  0  0
> >
> > Wow. So line 91 is add 2 to $c. Prior to stepping thru that line, $c is
> > 106, and I can do arithmetic on it. I step thru line 91 and voila', $c
> > is now 0. It doesn't matter what arithmetic I do- any math on C seems to
> > make it 0.
> 
> WAG: $c is block scoped and the block ends on line 92. Can you post,
> say, lines 80-95 of that program?
> 
> Cheers,
> Philip
> --
> Philip Newton <nospam.newton@gmx.li>
> That really is my address; no need to remove anything to reply.
> If you're not part of the solution, you're part of the precipitate.

WAG: Quite right- good catch.. The debugger doesn't show me the blocks
as it steps. I'm new with it, so this is a good lesson. As soon as you
said SCOPE I slapped my forehead and said "Doh!!"

Cheers,
tuxy


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

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

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 V10 Issue 1287
***************************************


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