[8102] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1721 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 24 18:07:06 1998

Date: Sat, 24 Jan 98 15:00:30 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 24 Jan 1998     Volume: 8 Number: 1721

Today's topics:
    Re: Browser Identification? (Mark-Jason Dominus)
    Re: character comparison... (Gabor)
    Re: DBD/DBI and Oracle8 (John D Groenveld)
    Re: DBI::Oracle question (John D Groenveld)
        Download of Perl for IBM? <gloria@akula.com>
    Re: Download of Perl for IBM? (Clay Irving)
    Re: Freidl's book mystery <tchrist@mox.perl.com>
    Re: Help Renaming Files.... <rjk@coos.dartmouth.edu>
    Re: Help w/ regexp (brian d foy)
    Re: Help with Stripping charactes from strings based up <rjk@coos.dartmouth.edu>
    Re: How does perl do "tail -n" ? <markm@nortel.ca>
    Re: IP Address as new File (brian d foy)
    Re: IP Address as new File <rjk@coos.dartmouth.edu>
    Re: IP Address as new File <rjk@coos.dartmouth.edu>
        Looking for licensing software for perl scripts? mahesh@mahesh.com
    Re: Looking for licensing software for perl scripts? <tchrist@mox.perl.com>
    Re: MacPerl CD-ROM, Version 0.5 (Tony L. Svanstrom)
    Re: matrices... (Greg Bacon)
    Re: ORACLE_HOME not set! (John D Groenveld)
    Re: Perl and Oracle's PL/SQL (John D Groenveld)
        Perl, Sybperl, and Year 2000 <atsylvia@erols.com>
    Re: small question about substitution. (brian d foy)
    Re: small question about substitution. (Peter Rowell)
    Re: Sys::Syslog (Lance A. Brown)
    Re: typeglob? (Greg Bacon)
        Unix domain sockets in Perl <sas@arstel.ru>
    Re: Unix domain sockets in Perl <tchrist@mox.perl.com>
    Re: Unix domain sockets in Perl <markm@nortel.ca>
    Re: Unix domain sockets in Perl <jhi@alpha.hut.fi>
        Whats New on remote site <andrew.spiers@virgin.net>
    Re: Whats New on remote site (brian d foy)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 24 Jan 1998 14:30:48 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Browser Identification?
Message-Id: <6adfh8$1qn$1@monet.op.net>
Keywords: Colby integrand Quakeress sagacious

In article <34C929E8.3C17@primary.net>,
darkcyde  <bazaillion@primary.net> wrote:
>I am writing a Perl script to do browser identification, does anyone
>know of a web site that has all the latest UserAgent variables for all
>the latest browsers.

Well, I'm not sure if this is what you want, but you might want to
look at the CGI::MozSniff module, available from

	http://www.perl.com/CPAN/modules/by-module/CGI/



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

Date: 24 Jan 1998 21:24:01 GMT
From: gabor@vnode.vmunix.com (Gabor)
Subject: Re: character comparison...
Message-Id: <slrn6ckmk3.ite.gabor@vnode.vmunix.com>

In comp.lang.perl.misc, Dane Christensen <dane@owlnet.rice.edu> wrote :
# Is there a way to alphebetically compare single characters?
# I've tried ...elsif ($char1> $char2) {... but, unlike C, they don't
# seem to be simply represented by numbers.  Thx.
# 

Try ord.

print "foo\n" if ord "a" > ord $foo;

gabor.
--
    It won't be covered in the book.  The source code has to be useful for
    something, after all...  :-)
        -- Larry Wall in <10160@jpl-devvax.JPL.NASA.GOV>


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

Date: 24 Jan 1998 15:27:03 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBD/DBI and Oracle8
Message-Id: <6adiqn$4nt$1@tholian.cse.psu.edu>

In article <69jir4$rdd$1@owl.slip.net>, David Lee  <dwl@slip.net> wrote:
>Oracle8? I'm having problems updating (failed to prepare update
>statement) Oracle8. Selects work fine. BTW, I'm assuming the
>above versions are the latest. Please let me know if there are
>newer versions I need to get to work with Oracle8.
There maybe a problem with the way the makefile links the Oracle libraries.
See the archive of the dbi-users list @
http://www.rosat.mpe-garching.mpg.de/mailing-lists/PerlDB-Interest/
http://outside.organic.com/mail-archives/dbi-users/ 

>Please respond by e-mail.
Help save the world by posting a summary of the answers.
John
groenvel@cse.psu.edu


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

Date: 24 Jan 1998 16:08:38 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBI::Oracle question
Message-Id: <6adl8m$4qj$1@tholian.cse.psu.edu>

Three tips for the novice and advanced Perl programmer:
	#!/usr/bin/perl -w
	use strict;
	use diagnostics;


Additionally, your code never tests that the DBI functions return true.
my $dbh = DBI->connect('dbi:Oracle:','scott','tiger') or die $DBI::errstr;
while (@row = $cur->fetchrow) {
    die $DBI::errstr if $DBI::err;
}

Finally, I dont think its possible yet to bind arrays with the DBD::Oracle.
John
groenvel@cse.psu.edu

#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect('dbi:Oracle:','scott','tiger') or die $DBI::errstr;
my @array = (1000,2000,3000);
my $array = join(',', @array);
my $cur =$dbh->prepare(qq{
        SELECT ename
        FROM emp
        WHERE
        job=? AND
        sal IN ($array)
}) or die $DBI::errstr;
$cur->execute('ANALYST') or die $DBI::errstr;
my @row;
while (@row = $cur->fetchrow) {
    die $DBI::errstr if $DBI::err;
    print "@row\n";
}
$cur->finish or die $DBI::errstr;
$dbh->disconnect or die $DBI::errstr;


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

Date: Sat, 24 Jan 1998 15:35:20 -0500
From: gloria <gloria@akula.com>
Subject: Download of Perl for IBM?
Message-Id: <34CA5087.DEFE34ED@akula.com>

I am working on Windows NT Server 4.0 with Miscrosoft Internet
Information Server installed. Can anyone tell me where I can download
Perl and the necessary Web Server in order to start learning about Perl
and CGI. I recently made a posting here about Perl/CGI on the Mac
environment. I have to learn it for both platforms. Thank you very much.



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

Date: 24 Jan 1998 17:40:07 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Download of Perl for IBM?
Message-Id: <6adqk7$a3g@panix.com>

In <34CA5087.DEFE34ED@akula.com> gloria <gloria@akula.com> writes:

>I am working on Windows NT Server 4.0 with Miscrosoft Internet
>Information Server installed. Can anyone tell me where I can download
>Perl and the necessary Web Server in order to start learning about Perl
>and CGI. I recently made a posting here about Perl/CGI on the Mac
>environment. I have to learn it for both platforms. Thank you very much.

A *real* good starting point is http://www.perl.com :)

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: 24 Jan 1998 20:45:25 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Freidl's book mystery
Message-Id: <6adjt5$8fp$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, bart.mediamind@tornado.be (Bart Lateur) writes:
:You must have forgotten the leading "^" in those regular expressions.

Yes.
:p.s. I noticed you have the same layout style for blocks as me. You
:don't see that style too much.

Which one?  Seems to me my coding style is standad, and perlstyle(1)
even concurs. :-)

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

With a PC, I always felt limited by the software available.  On Unix, I am
limited by my knowledge.  --Peter J. Schoenster <pschon@baste.magibox.net>


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

Date: Sat, 24 Jan 1998 14:19:29 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: marcin@polaccess.com
Subject: Re: Help Renaming Files....
Message-Id: <34CA3EC0.EE59B519@coos.dartmouth.edu>

[posted and mailed]

> #!/usr/bin/perl
> opendir(DIR,".");
> $count = 1;
> while ($thisfile=readdir(DIR)) 
> {
> $_ = $thisfile;
> if (/\.htm/) 
> {
> $newfile = "xdr" . $count . ".htm";
> system ("mv $thisfile $newfile");
> print "I moved $thisfile $newfile\n";
> }
> }
> exit(0);

$count is never being incremented.
This code will move all files to 'xdr1.htm'.

Chipmunk


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

Date: Sat, 24 Jan 1998 14:00:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Help w/ regexp
Message-Id: <comdog-2401981400010001@news.panix.com>
Keywords: just another new york perl hacker

In article <34CA234D.675BE7C6@coos.dartmouth.edu>, rjk@coos.dartmouth.edu posted:


> You can use the suggestions you've already received in the grep:
> 
> @log = grep {/(\d+)$/ and $1 >= $beg and $1 <= $end} @log

remember that he wanted only the last two characters... :)

 @log = grep {/(\d\d)$/ and $1 >= $beg and $1 <= $end} @log

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Sat, 24 Jan 1998 13:55:15 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: "Russell S. Virgilio" <ccastrv@acmex.gatech.edu>
Subject: Re: Help with Stripping charactes from strings based upon patterns
Message-Id: <34CA3913.FEBFAFEB@coos.dartmouth.edu>

[posted and mailed]

Russell S. Virgilio wrote:
> 
> $_ = `/usr/xpg4/bin/grep -f ether2 list `;
> my ($first, $hostname, $ipmask, $last) = split;
> 
> ...only processes the first line and seems to ignore the rest of
> the lines.  I was considering using a loop of some sort, but i'm not
> familiar with how the split command would work with mulitple lines.

Everything after the first line is being thrown away by the split.

Try using `` in a list context to get an array of lines, and then
looping over each line:

@list = `/usr/xpg4/bin/grep -f ether2 list `;
foreach (@list) {
  my($first, $hostname, $ipmask, $last) = split;
  # whatever you want to do with the split line
}

Chipmunk


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

Date: 24 Jan 1998 15:21:06 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: How does perl do "tail -n" ?
Message-Id: <lq1en1xoc7h.fsf@bmers2e5.nortel.ca>

cberry@cinenet.net (Craig Berry) writes:
> Earl Hood (ehood@medusa.acs.uci.edu) wrote:
> : In article <6aa9dr$sp0$1@news.ml.com>,
> : Michael Wang <mwang@alhena.ibk.ml.com> wrote:
> : >Do you have to read the entire file into memory? What happens if it is a
> : >10MB file? Thanks. 
> : How about (untested):
> :     my $n = 10;
> :     if ($ARGV[0] =~ /^-(\d+)$/) {
> : 	$n = $1;
> : 	shift @ARGV;
> :     }
> :     my @lines = ();
> :     while (<>) {
> : 	push @lines, $_;
> : 	shift @lines  if (@lines > $n);
> :     }   
> :     print @lines;

If one really really really cared about speed... we could optimize the
above to work for speed _and_ large files:

    my $maxlines = 50;
    if ($ARGV[0] =~ /^-(\d+)$/) {
        $maxlines = $1;
        shift @ARGV;
    }

    my @lines = ();
    while (<>) {
        push(@lines, $_);
	splice(@lines, 0, $maxlines) if @lines >= (2 * $maxlines);
    }
    splice(@lines, 0, @lines - $maxlines) if @lines > $maxlines;
    print @lines;

Sorta moving window approach :-) Means we copy memory around a lot less.

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Sat, 24 Jan 1998 14:04:30 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: IP Address as new File
Message-Id: <comdog-2401981404300001@news.panix.com>
Keywords: just another new york perl hacker

In article <01bd28f0$8e66b640$f8a7f3ce@tom>, "InterActive Promotions" <drew@citypost.com> posted:

did you turn on optional warnings using the -w switch?

> open (TEMP_FILE, "$remote_address");

   hmmm... you open a file for reading, but don't check the return
value of open().

> print TEMP_FILE ("$remote_address|$url\n");

then you try to print to a FILEHANDLE open for reading.

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: Sat, 24 Jan 1998 14:26:28 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: IP Address as new File
Message-Id: <34CA4064.5215D8CD@coos.dartmouth.edu>

InterActive Promotions wrote:
> 
> I am trying to create a new file based on a users IP Addrss.
> 
> I have tryed:
> 
> $remote_address = $ENV{'REMOTE_ADDR'};
> 
> open (TEMP_FILE, "$remote_address");
> print TEMP_FILE ("$remote_address|$url\n");
> close (TEMP_FILE);

Did that not work?  If you check the return value of open,
you might find out why:

open (TEMP_FILE, "$remote_address") or
  die "Unable to open $remote_address: $!";

Chipmunk


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

Date: Sat, 24 Jan 1998 14:28:22 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: IP Address as new File
Message-Id: <34CA40D6.4DC95F7D@coos.dartmouth.edu>

InterActive Promotions wrote:
> 
> open (TEMP_FILE, "$remote_address");
> print TEMP_FILE ("$remote_address|$url\n");
> close (TEMP_FILE);

BTW, the real problem is that you are opening
TEMP_FILE for input, and the trying to use it
for output:

open (TEMP_FILE, ">$remote_address") or
  die "Unable to open $remote_address: $!";

But you should still check the return value of open.

Chipmunk


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

Date: Sat, 24 Jan 1998 15:01:13 -0600
From: mahesh@mahesh.com
To: mahesh@mahesh.com
Subject: Looking for licensing software for perl scripts?
Message-Id: <885675421.1840578569@dejanews.com>
Keywords: perl licensing

Netters,

I am looking for some solution to prevent the piracy of our
perl scripts :-) I am thinking about giving a key based on
the hostname, virtual domainname (optional), directory path
(or any ideas are welcome)

Please send a copy of your response by email.

Thanks for your time,

BG Mahesh
mahesh@mahesh.com

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 24 Jan 1998 21:38:45 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Looking for licensing software for perl scripts?
Message-Id: <6adn15$dqf$1@csnews.cs.colorado.edu>
Keywords: perl licensing

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, mahesh@mahesh.com writes:
:I am looking for some solution to prevent the piracy of our
:perl scripts.

I suggest the Netscape Solution.  Stop being paranoid and make
the source available, but keep your copyright etc.

--tom


-- 
	Tom Christiansen	tchrist@jhereg.perl.com
And don't tell me there isn't one bit of difference between null and space,
because that's exactly how much difference there is.  :-)
        --Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>


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

Date: Sat, 24 Jan 1998 20:43:38 +0100
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: MacPerl CD-ROM, Version 0.5
Message-Id: <1d3dnqm.wafm81ev9mp6N@du98-6.ppp.algonet.se>

Chris Nandor <pudge@pobox.com> wrote:

> In article <1d3d3n4.1p1grp615sdli8N@du31-253.ppp.algonet.se>,
> tony@svanstrom.com (Tony L. Svanstrom) wrote:
> 
> # Rich Morin <rdm@cfcl.com> wrote:
> # 
> # > Prime Time Freeware (PTF; http://www.ptf.com) is pleased to announce the
> # > MacPerl CD-ROM (Version 0.5).  This disc,
> # 
> # Is this a good buy for someone that wants to learn Perl when the scripts
> # will be used on UN*Xmachines only?
> 
> If you will only be using Unix, no.  It is an HFS (Mac-format) disk.  If
> you will be using MacPerl to write scripts for use on Unix, then yes, it
> is good for that.

My questions should really have been: If it works on UN*X does it then
work on Mac, and if it works on a Mac...?


You made a misstake with your sig., It should be "-- " and not "--"


     /Tony
-- 
                               /\___/\ 
                               \_@ @_/ 
        ---------------------oOO-(_)-OOo----------------------
           "We only live to please those we love" -- Aphrael
        ----------------------ttt---ttt-----------------------
          http://tls.base.org \O/   \O/ )Tony Svanstrom 1997


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

Date: 24 Jan 1998 22:27:27 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: matrices...
Message-Id: <6adpsf$1q0$2@info.uah.edu>

[Posted and mailed]

In article <34C9C118.41C6@unipg.it>,
	Pallotta Marco <marcop@unipg.it> writes:
: How can I do if I want to use matrices in Perl ????????

    @matrix = (
        [ 1, 2, 3 ],
        [ 4, 5, 6 ],
        [ 7, 8, 9 ],
    );

: That is, if I want (for istance) a 7 x 2 array how can i do?
: I have an array with the days of the week:
: @days = (mon,tue,wed,thu,fri,sat,sun);
: I want associate every short name with the long name (mon with monday,
: ecc. .....), and I want to create a 7 x 2 array.

When you want to express an association in Perl, you should immediately
think `hash', not matrix (or array).

    %fullname = (
        mon => 'Moday',
        tue => 'Tuesday',
        wed => 'Wednesday',
        thu => 'Thursday',
        fri => 'Friday',
        sat => 'Saturday',
        sun => 'Sunday',
    );

Read the perldata manpage for more details.

Hope this helps,
Greg
-- 
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 24 Jan 1998 15:31:02 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: ORACLE_HOME not set!
Message-Id: <6adj26$4ok$1@tholian.cse.psu.edu>

In article <01bd278d$46f3d9a0$1a2bcbd0@mzelmanov.qquest.com>,
Mikhail Zelmanov <mzelmanov@qquest.com> wrote:
>HI.
>
>I installed Perl 5 and Oracle 7 on win95.
>Then I installed DBI 90 and DBD 47.
>What I have to set for ORACLE_HOME var on win95 when I am connecting to
>ORACLE ?

I'm fairly certain Oracle for Windows should have set ORACLE_HOME in your
AUTOEXEC.BAT. Otherwise, SET ORACLE_HOME=c:\orawin or whatever.
John
groenvel@cse.psu.edu


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

Date: 24 Jan 1998 15:19:49 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Perl and Oracle's PL/SQL
Message-Id: <6adid5$4n2$1@tholian.cse.psu.edu>

In article <34BB65EA.B51FB85B@tietogroup.com>,
Kari Marttila  <Kari.Marttila@tietogroup.com> wrote:
>I would like to know if it is possible to embed Oracle's PL/SQL scripts
>into a perl script. And if it is, how is this done?
http://www.dejanews.com archives answers to many of life's questions.

>I would appreciate a personal reply also! Thanks!
I would appreciate a promise to summarize the answer before I'll
send a personal reply.

John
groenvel@cse.psu.edu


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

Date: Sat, 24 Jan 1998 17:27:57 -0500
From: Aaron Sylvia <atsylvia@erols.com>
Subject: Perl, Sybperl, and Year 2000
Message-Id: <34CA6AED.EA9B9B70@erols.com>

Anyone,

I have read the FAQ for Perl 5.x and it states that it should not cause
any year 2000 compliance problems (haven't found anything on Sybperl,
yet...).

Has anyone had any experience with this?  Has anyone done any testing
and found anything?  (Obviously I am researching this for the company
that I work for)

Thanks for any information!

Aaron Sylvia
State Street Corporation



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

Date: Sat, 24 Jan 1998 14:23:36 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: small question about substitution.
Message-Id: <comdog-2401981423360001@news.panix.com>
Keywords: just another new york perl hacker

In article <34C8DC8A.127D@cse.bridgeport.edu>, seong@cse.bridgeport.edu posted:


> $tmp = ~ s/^\/opt\/guide\/acumedia/http:\/\/www\.seong\.com/;

what's that whitespace doing between = and ~ ?

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: 24 Jan 1998 11:27:20 -0800
From: thirdeye@sonic.net (Peter Rowell)
Subject: Re: small question about substitution.
Message-Id: <6adfao$8c3@bolt.sonic.net>

In article <34C8DC8A.127D@cse.bridgeport.edu>,
Seong Y. Kim <seong@cse.bridgeport.edu> wrote:

>$tmp = ~ s/^\/opt\/guide\/acumedia/http:\/\/www\.seong\.com/;
[ snip ]
>when i run it, it gives me -1

The operator is =~ NOT = ~
                        ^ note the space

By using "= ~" you are saying is (I believe):

	1. perform a substitution on the default variable $_
		which apparently failed, yielding 0 as a result.
	2. perform a bit-wise negation of the return value of s///
	    0 == 0x00000000, ~0 == 0xffffffff  which happens to == -1
	3. store the result in $tmp.

    Hope this helps,
    Peter
    peter@thirdeye.com


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

Date: 24 Jan 1998 15:03:20 -0500
From: brown9@niehs.nih.gov (Lance A. Brown)
Subject: Re: Sys::Syslog
Message-Id: <yd1wwfpbpx3.fsf@splat.niehs.nih.gov>

If you are running on a Linux box you need to change the init.d script 
for syslog and add a -r switch to the invokation of syslogd in order
to make it open an IP socket.

--[Lance]



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

Date: 24 Jan 1998 22:22:50 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: typeglob?
Message-Id: <6adpjq$1q0$1@info.uah.edu>

[Posted and mailed]

In article <34CA120E.27402122@internetmci.com>,
	George Cyriac <gcyriac@internetmci.com> writes:
: -- 

:-(.  That is a cut line, and it is for marking the beginning of your
 .signature.  Please don't use it elsewhere.

: Can anyone explain to me what a typeglob does(*)?  I have programming
: perl but I still can't understand?

Typeglobs are described in the perldata manpage (and there are
references to other sources of information).  Recall that in Perl
there are seven namespaces for identifiers:

    scalar      $foo
    array       @foo
    hash        %foo
    subroutine  &foo
    format      foo
    iohandle    foo
    label       foo

Think of the star in front of a globhandle as a shell-style glob for
the funny character that might or might not be in front of the
identifier.  A typeglob is an internal type for representing the
symbol table entry for six of those identifiers (labels don't get
symbol table entries).

Back in the days of perl version 4, people used typeglobs to pass
filehandles or other types by reference, e.g.

    sub do_something {
        local(*HANDLE, *hash) = @_;

        print <HANDLE>;

        for (keys(%hash)) {
            ...;
        }
    }

    open(FILE, "/path/to/file") || die "Failed open: $!\n";
    %name = ( 'john', 'doe', 'jane', 'lane' );
    &do_something(*FILE, *name);

Can you see that when code in &do_something uses the filehandle HANDLE,
it's really referring to FILE?  The same is true of %hash and %name.
Don't try this with lexical variables.

: What is the difference between:
: &search(@words);
: and 
: &search(*words);

@words is an array and *words is a typeglob (that contains a pointer
to @array, $array, etc).

: I have used a typeglob when using cgi-lib.pl, but I don't know the
: difference?

Big mistake.  Use the CGI module that now ships with Perl!

Hope this helps,
Greg
-- 
open G,"|gzip -dc";$_=<<EOF;s/([0-9a-f]+)/print G pack"h*",$1/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Sat, 24 Jan 1998 23:24:40 +0300
From: Alexander Slinkin <sas@arstel.ru>
Subject: Unix domain sockets in Perl
Message-Id: <34CA4E07.561266B4@arstel.ru>

Hi Perl gurus,

I'm new to Perl and this is my first time in this newsgroup, so don't
blame
on me for probably obvious question. I want to write a script used as a
client
for testing a server written in C. The IPC used is UNIX domain sockets.
I
have reduced the problem down to the following server-client pair
written
completely in Perl and based on the example in perlipc man page.

This is the server:

#!/usr/local/bin/perl

use Socket;

my $NAME = '/tmp/catsock';
my $uaddr = sockaddr_un($NAME);

socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Error creating socket:
$!\n";
unlink($NAME);
bind(SOCK, $uaddr);
listen(SOCK,5);

for (; ;) {
    accept(CLI, SOCK) || die "Error accepting: $!\n";
    $line = <CLI>;
    print CLI $line;  # HERE'S THE PROBLEM
    close CLI;
}

And this is the client:

#!/usr/local/bin/perl

use Socket;

socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Error creating socket:
$!\n";
connect(SOCK, sockaddr_un('/tmp/catsock')) || die "Connect: $!\n";
print SOCK "Hello, there\n"; # HERE'S THE PROBLEM
while ($line = <SOCK>) {
   print $line;
}
exit;

If I start the server and the client, the latter hangs in the while
loop.
Actually the deeper investigation (with server part written in C) shows
that
the message "Hello, there" does not reach the server. But let's modify
both
scripts by replacing "print" with "send" (modified lines are marked with

comment # HERE'S THE PROBLEM):

In the server:
    send(CLI, $line, 0) || die "Send: $!\n";

In the client:
    send(SOCK, "Hello there\n", 0) || die "Send: $!\n";

In this case client receives "Hello, there" echoed by the server and
prints
it as expected.

So why "print" (that AFAIK is implemented via fwrite) does not work,
while
"send" (implemented via sendto) works fine? Has it something to do with
buffering? If so, how to avoid this?

I'm running Perl 5.004.001 (dynamic version) under SCO OpenServer
5.0.0d.

Please answer also by e-mail (sas@arstel.ru) as I don't read this group
often
Alexander Slinkin



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

Date: 24 Jan 1998 21:03:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Unix domain sockets in Perl
Message-Id: <6adkve$a72$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, sas@arstel.ru writes:

You forgot to flush.  See the perlipc and perlfaq5 looking
for flush.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

	    Sword and sward, retain and Britain.
	    (Mind the latter, how it's written.)


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

Date: 24 Jan 1998 15:57:27 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Unix domain sockets in Perl
Message-Id: <lq1btx1oaiw.fsf@bmers2e5.nortel.ca>

Alexander Slinkin <sas@arstel.ru> writes:
> I'm new to Perl and this is my first time in this newsgroup, so don't
> blame on me for probably obvious question. I want to write a script used
> as a client for testing a server written in C. The IPC used is UNIX domain
> sockets. I have reduced the problem down to the following server-client pair
> written completely in Perl and based on the example in perlipc man page.

The answer off the top of my head is that print() is buffered IO. You need
to do one of these before the print() statement.

    use FileHandle;
    SOCK->autoflush(1);

    #or,
    select(SOCK); $| = 1; select(STDOUT);

This should be done on both the server and the client.. i'll put code
insertions below where i think it might be preferable for them to go.

> This is the server:
  #!/usr/local/bin/perl
 
+ use FileHandle;
  use Socket;
 
  my $NAME = '/tmp/catsock';
  my $uaddr = sockaddr_un($NAME);
  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Error creating socket:
  $!\n";
  unlink($NAME);
  bind(SOCK, $uaddr);
  listen(SOCK,5);
  for (; ;) {
      accept(CLI, SOCK) || die "Error accepting: $!\n";
+     CLI->autoflush(1);
 
      $line = <CLI>;
      print CLI $line;  # HERE'S THE PROBLEM
 
      close CLI;
  }
 
> And this is the client:
 
  #!/usr/local/bin/perl
  
+ use FileHandle;
  use Socket;
  
  socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Error creating socket: $!\n";
  connect(SOCK, sockaddr_un('/tmp/catsock')) || die "Connect: $!\n";
+ SOCK->autoflush(1);
 
  print SOCK "Hello, there\n"; # HERE'S THE PROBLEM
  while ($line = <SOCK>) {
     print $line;
  }
  exit;

> If I start the server and the client, the latter hangs in the while loop.
> Actually the deeper investigation (with server part written in C) shows
> that the message "Hello, there" does not reach the server. But let's modify
> both scripts by replacing "print" with "send" (modified lines are marked with
> comment # HERE'S THE PROBLEM):
> In the server:
>     send(CLI, $line, 0) || die "Send: $!\n";
> In the client:
>     send(SOCK, "Hello there\n", 0) || die "Send: $!\n";
> In this case client receives "Hello, there" echoed by the server and
> prints
> it as expected.
> So why "print" (that AFAIK is implemented via fwrite) does not work,
> while "send" (implemented via sendto) works fine? Has it something to do
> with buffering? If so, how to avoid this?

exactly.

> I'm running Perl 5.004.001 (dynamic version) under SCO OpenServer
> 5.0.0d.
> Please answer also by e-mail (sas@arstel.ru) as I don't read this group
> often
> Alexander Slinkin

will cc: you.

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 25 Jan 1998 00:30:39 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Unix domain sockets in Perl
Message-Id: <oeebtx1ijxs.fsf@alpha.hut.fi>


Tom Christiansen <tchrist@mox.perl.com> writes:

> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, sas@arstel.ru writes:
> 
> You forgot to flush.  See the perlipc and perlfaq5 looking
> for flush.
> 
> --tom

In this case, didn't he also forget to blush, for not looking first at
the basic docs...?

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Sat, 24 Jan 1998 19:19:50 +0000
From: Andrew Spiers <andrew.spiers@virgin.net>
Subject: Whats New on remote site
Message-Id: <34CA3ED6.42A2B764@virgin.net>

Would it be possible to run a Whats New Script against another site so
that you could see what the new pages where on someone elses site ?

Thanks.



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

Date: Sat, 24 Jan 1998 14:27:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Whats New on remote site
Message-Id: <comdog-2401981427220001@news.panix.com>
Keywords: just another new york perl hacker

In article <34CA3ED6.42A2B764@virgin.net>, andrew.spiers@virgin.net posted:

> Would it be possible to run a Whats New Script against another site so
> that you could see what the new pages where on someone elses site ?

depends on how you want to find files.  finding files not referenced
by other files would not be so easy.

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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

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

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1721
**************************************

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