[7494] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1121 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 3 14:07:12 1997

Date: Fri, 3 Oct 97 11:01:56 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 3 Oct 1997     Volume: 8 Number: 1121

Today's topics:
     sfio on Solaris Intel 2.5.1 (Gene Gotimer)
     Re: Signal handling through CGI <rootbeer@teleport.com>
     STDERR capture <pascal@belnet.be>
     Re: STDERR capture (Jeremy D. Zawodny)
     Re: STDERR capture (Tom Grydeland)
     Re: Syntax  on assignment and undef (M.J.T. Guy)
     Re: System calls (Mike Stok)
     unique elements in a associative array <webadmin@prestel.net>
     Re: unique elements in a associative array (Jeremy D. Zawodny)
     Re: URL Transfer? <rootbeer@teleport.com>
     Why isn't this code working? (Andrew Collington)
     Re: Why isn't this code working? <tycage@infi.net>
     Re: XS & variable-length <sriram@weblogic.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 3 Oct 1997 10:18:27 -0700
From: portinfo@best.com (Gene Gotimer)
Subject: sfio on Solaris Intel 2.5.1
Message-Id: <6139d3$11r$1@shell5.ba.best.com>

Has anyone gotten sfio to build on Solaris Intel 2.5.1?

(comp.lang.perl.misc folks:
I realize this isn't directly Perl related, but I thought someone
might have run into this same problem when adding FCGI, which
is what I am trying to do...)

I got the sfio97.src.unix.tar.gz file from
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/src/misc/

When I do a make CC=gcc:

sfsetbuf.c: In function `sfsetbuf':
sfsetbuf.c:51: `Stat_t' undeclared (first use this function)
sfsetbuf.c:51: (Each undeclared identifier is reported only once
sfsetbuf.c:51: for each function it appears in.)
sfsetbuf.c:51: parse error before `st'
sfsetbuf.c:130: `st' undeclared (first use this function)
make: *** [sfsetbuf.o] Error 1

I grepped my whole /usr/include tree and /usr/local/lib tree, 
and couldn't find Stat_t declared.

Thinking it might be a Solaris Intel vs Solaris Sparc issue,
I looked on a Sparc for Stat_t and couldn't find it there
either. sfio built fine on the Sparc, though.

I think the real problem is that I do not have SparcWorks on
the Solaris Intel box, just GCC. On the Sparc box, both
gcc and cc where able to build sfio.

I don't think it is related, but this warning is displayed 
for a few dozen files:

In file included from /usr/include/fcntl.h:17,
                 from sfhdr.h:62,
                 from sfsetbuf.c:7:
/usr/local/lib/gcc-lib/i386-unknown-solaris2.5.1/2.7.2.2/include/sys/types.h:193: warning: redefinition of `ssize_t'
ast_common.h:99: warning: `ssize_t' previously declared here

I don't think this is a problem (both declare ssize_t as int).


Anyone have any ideas?

Newsgroups: comp.unix.solaris,comp.lang.perl.misc,alt.solaris.x86
Subject: sfio on Solaris x86 2.5.1?
Summary: 
Expires: 
Sender: 
Followup-To: 
Distribution: 
Organization: Best Internet Communications, Inc. - 650 964 BEST
Keywords: 
Cc: 

Has anyone gotten sfio to build on Solaris Intel 2.5.1?

(comp.lang.perl.misc folks:
I realize this isn't directly Perl related, but I thought someone
might have run into this same problem when adding FCGI, which
is what I am trying to do...)

I got the sfio97.src.unix.tar.gz file from
ftp://ftp.cis.ufl.edu/pub/perl/CPAN/src/misc/

When I do a make CC=gcc:

sfsetbuf.c: In function `sfsetbuf':
sfsetbuf.c:51: `Stat_t' undeclared (first use this function)
sfsetbuf.c:51: (Each undeclared identifier is reported only once
sfsetbuf.c:51: for each function it appears in.)
sfsetbuf.c:51: parse error before `st'
sfsetbuf.c:130: `st' undeclared (first use this function)
make: *** [sfsetbuf.o] Error 1

I grepped my whole /usr/include tree and /usr/local/lib tree, 
and couldn't find Stat_t declared.

Thinking it might be a Solaris Intel vs Solaris Sparc issue,
I looked on a Sparc for Stat_t and couldn't find it there
either. sfio built fine on the Sparc, though.

I think the real problem is that I do not have SparcWorks on
the Solaris Intel box, just GCC. On the Sparc box, both
gcc and cc where able to build sfio.

I don't think it is related, but this warning is displayed 
for a few dozen files:

In file included from /usr/include/fcntl.h:17,
                 from sfhdr.h:62,
                 from sfsetbuf.c:7:
/usr/local/lib/gcc-lib/i386-unknown-solaris2.5.1/2.7.2.2/include/sys/types.h:193: warning: redefinition of `ssize_t'
ast_common.h:99: warning: `ssize_t' previously declared here

I don't think this is a problem (both declare ssize_t as int).


Anyone have any ideas?



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

Date: Fri, 3 Oct 1997 06:31:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Fussy <fussy@mpinet.net>
Subject: Re: Signal handling through CGI
Message-Id: <Pine.GSO.3.96.971003063027.27448F-100000@usertest.teleport.com>

On Thu, 2 Oct 1997, Mike Fussy wrote:

> Does anyone know which, if any, signal is sent to the process if a user
> presses stop from the browser? 

If any signal is sent, it would be documented in either the CGI spec or in
the server's docs. If you can't find the answer there, check the docs and
FAQs for a CGI or server newsgroup, since that will be able to give you a
better and more complete answer than we can give here. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 03 Oct 1997 16:35:39 +0200
From: Pascal Delmoitie <pascal@belnet.be>
Subject: STDERR capture
Message-Id: <343502BB.8112157@belnet.be>

Hi,

Newbie to perl, I try to capture the output of STDERR


ex:

$var = `UNIX COMMAND`; (Back quotes)

With success of the UNIX COMMAND I get sthng in $var

With failure I would like to get the result sent to STDERR
in a varaiable in order to analyze it.

How should I do it ?

Thanx

Pascal

------------------------------------------------------
  Pascal Delmoitie
  <pascal@belnet.be>
  
  BELNET Service Support Team
  
  Rue de la Science, 4        Tel. : +32.2.238-3685
  B-1000 BRUSSELS             Fax. : +32.2.513-5730
  BELGIUM
------------------------------------------------------


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

Date: Fri, 03 Oct 1997 14:49:21 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: STDERR capture
Message-Id: <343505c2.155598869@igate.hst.moc.com>

[cc'd automagically to original author]

On Fri, 03 Oct 1997 16:35:39 +0200, Pascal Delmoitie
<pascal@belnet.be> wrote:

>$var = `UNIX COMMAND`; (Back quotes)
>
>With success of the UNIX COMMAND I get sthng in $var
>
>With failure I would like to get the result sent to STDERR
>in a varaiable in order to analyze it.
>
>How should I do it ?

Read the answer to the question "How can I capture STDERR from an
external command?" in the Perl FAQ, as found at the Perl web site,
http://www.perl.com/

That's where *I'd* start.

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: 3 Oct 1997 14:50:50 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: STDERR capture
Message-Id: <slrn63a1ia.nkr.Tom.Grydeland@mitra.phys.uit.no>

On Fri, 03 Oct 1997 16:35:39 +0200,
Pascal Delmoitie <pascal@belnet.be> wrote:
> Newbie to perl, I try to capture the output of STDERR

This is a Frequently Asked Question (FAQ)
Answers to FAQs are provided with every legal distribution of Perl, and
it is considered a minimum of independent research to consult your
manual pages and the FAQ before posting your question to the world.

man perlfaq
man perlfaq8

look for "capture" or "STDERR"

> How should I do it ?

By reading the documentation provided with Perl.

> Thanx


>   Pascal Delmoitie

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 3 Oct 1997 16:16:22 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Syntax  on assignment and undef
Message-Id: <6135om$6qa$1@lyra.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>On 29 Sep 1997, Jason Gloudon wrote:
>
>> Interesting sideline here.
>> This compiles and does absolutely nothing.
>> 
>> () = (1,23);
>
>What would you want it to do?

Well, I use the string "() = " to substitute for the "array" keyword
(or is it "list" ?) which inexplicably seems to have been omitted from Perl.


Mike Guy


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

Date: 3 Oct 1997 13:36:41 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: System calls
Message-Id: <612sd9$ku5@news-central.tiac.net>

In article <34342BB7.40BC979D@goweb.lu>, Bosch Patrick  <bosch@goweb.lu> wrote:

>I just wanted to know wich is the excact way to execute system commands within
>Perl. I have tried
>
>print '/usr/bin/tar -cvf $file $directory';
>
>But all he did was printing to standard output.

One way to do it is

  system "/usr/bin/tar -cvf $file $directory";

assuming that you want $file and $directory to have their values
interpolated into the command.

If you have web access then you'll find a couple of other ways to do it
mentioned in the FAQ (frequently asked questions) which can be found at
http://www.perl.com/ by following the FAQs link.  If you use FTP then
there's the master site of the comprehensivew perl archive network (CPAN)
which also holds this information at ftp.funet.fi under
/pub/languages/perl/CPAN

In section 8 of the FAQ there's this section:

       Why can't I get the output of a command with system()?

       You're confusing the purpose of system() and backticks
       (``).  system() runs a command and returns exit status
       information (as a 16 bit value: the low 8 bits are the
       signal the process died from, if any, and the high 8 bits
       are the actual exit value).  Backticks (``) run a command
       and return what it sent to STDOUT.

           $exit_status   = system("mail-users");
           $output_string = `ls`;


       How can I capture STDERR from an external command?

       There are three basic ways of running external commands:

           system $cmd;                # using system()
           $output = `$cmd`;           # using backticks (``)
           open (PIPE, "cmd |");       # using open()

       With system(), both STDOUT and STDERR will go the same
       place as the script's versions of these, unless the
       command redirects them.  Backticks and open() read only
       the STDOUT of your command.

       [...]

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Fri, 03 Oct 1997 16:43:07 +0100
From: webadmin <webadmin@prestel.net>
Subject: unique elements in a associative array
Message-Id: <3435128B.2798ED4A@prestel.net>

Hi

I have an associative array, I need to ensure the values for each some
of the keys are individual

e.g name1=john
    name2=peter
    name3=john  *this should throw error. I know there is a long winded
way of doing it, I thought there might be a one liner
    address=john **this should not throw error cause key is different

Any ideas...

Iqbal


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

Date: Fri, 03 Oct 1997 16:12:23 GMT
From: zawodny@hou.moc.com (Jeremy D. Zawodny)
Subject: Re: unique elements in a associative array
Message-Id: <34351813.160287651@igate.hst.moc.com>

[cc'd automagically to original author]

On Fri, 03 Oct 1997 16:43:07 +0100, webadmin <webadmin@prestel.net>
wrote:

>I have an associative array, I need to ensure the values for each some
>of the keys are individual
>
>e.g name1=john
>    name2=peter
>    name3=john  *this should throw error. I know there is a long winded
>way of doing it, I thought there might be a one liner
>    address=john **this should not throw error cause key is different
>
>Any ideas...

Yes, read the FAQ at http://www.perl.com/ and look for the question
"How can I extract just the unique elements of an array?"

BTW, I simply searched it for "unique" and got right to what you need.

Jeremy
-- 
Jeremy Zawodny
Internet Technology Group
Information Technology Services
Marathon Oil Company, Findlay Ohio

http://www.marathon.com/

Unless explicitly stated, these are my opinions only--not those of my employer.


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

Date: Fri, 3 Oct 1997 06:43:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gary Fitch <gefitch@info-partners.com>
Subject: Re: URL Transfer?
Message-Id: <Pine.GSO.3.96.971003064232.27448J-100000@usertest.teleport.com>

On Fri, 3 Oct 1997, Gary Fitch wrote:

> Anyone know how to dynamically force a url transfer via perl code?

You shouldn't force anything. But you can use the LWP module to ask a
server nicely if it will give you a web page. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 3 Oct 1997 16:30:09 +0100
From: avert@dial.pipex.com (Andrew Collington)
Subject: Why isn't this code working?
Message-Id: <MPG.e9f1fda391e135a989681@news.dial.pipex.com>

Hi, everyone.

I wonder if any of you can help me out with this piece of code, or tell 
me where my thinking is going wrong.
Now what I *think* the code should be doing is going through a file and 
reading it it.  Then stripping the <html> tags, and any - or '.  Then it 
should save it into a db file.
Here is the code snippet.


$directory='/usr/home/me'; 

dbmopen(%final,"searchindex",0666);
&scan_files($directory);

sub scan_files {
  my $dir=$_[0];
  my 
(@dirs,@files,@results,$filename,$shortfilename,$newdir,$list,%words);
  print "Scanning: $dir\n";
  opendir(dir,$dir);
  @dirs=grep {!(/^\./) && -d "$dir/$_"} readdir(dir);
  rewinddir(dir);
  @files=grep {!(/^\./) && (/html$/ || /htm$/) && -T "$dir/$_"} 
readdir(dir);
  closedir(dir);
  for $list(0..$#dirs) {
    if (!($dirs[$list]=~/graphics/ || $dirs[$list]=~/cgi/)) {
      $newdir=$dir."/".$dirs[$list];
      &scan_files($newdir);
      }
    }
  for $list (0..$#files) {
    undef(%words);
    undef(@result);
    $filename=$dir."/".$files[$list];
    $shortfilename=$filename;
    $shortfilename=s/$directory//;
    open(FP,$filename);
    @file=<FP>;
    $file=join(" ",@file);
    $file=~s/<[^>]*>/ /gs;
    $file=~tr/A-Z/a-z/;
    @results=split(/[^\w-']+/,$file);
    foreach (@results) {
      s/^'//;
      s/'$//;
      s/^-//;
      s/-$//;
      if (length($_)>=3) {
        $words{$_}=1;
        }
      }
    foreach (keys(%words)) {
      $final{$_}.="#$shortfilename";
      }
    }
  return 1;
 }



What this does appear to do, when I list the db file with 'foreach $key 
(%keys)' (or similar) it gives me a loooong list of either a lot of 
spaces, % signs, -'s, ''s or similar..
Can anyone see my mistake?  I'd appreciate knowing, or being told a fix 
if you have one! :)

Thanks very much for any help you are able to give.

Regards, Andy


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

Date: Fri, 03 Oct 1997 13:24:57 -0400
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: Why isn't this code working?
Message-Id: <34352A69.735C0B7F@infi.net>

Andrew Collington wrote:
> 
> Hi, everyone.
> 
> I wonder if any of you can help me out with this piece of code, or tell
> me where my thinking is going wrong.
> Now what I *think* the code should be doing is going through a file and
> reading it it.  Then stripping the <html> tags, and any - or '.  Then it
> should save it into a db file.
> Here is the code snippet.
 ...
[some code snipped to save space]
 ...
> 
>   for $list (0..$#files) {
>     undef(%words);
>     undef(@result);
>     $filename=$dir."/".$files[$list];
>     $shortfilename=$filename;
>     $shortfilename=s/$directory//;
>     open(FP,$filename);
>     @file=<FP>;
>     $file=join(" ",@file);
>     $file=~s/<[^>]*>/ /gs;
>     $file=~tr/A-Z/a-z/;
>     @results=split(/[^\w-']+/,$file);
                      ^^^^^^^

My guess would be that this is the problem.
the - positioned where you have it makes
\w-' a range of characters.  I'm not sure
what that range would be, but off the top
of my head without any testing I'd guess it's
something like [0-9a-Za-z_-'], but like I said
that's just a guess.

Try moving the - to the end of the class and
see what happens. i.e.
[^\w'-]

[more code snipped to save space]
 ...


Hope this helps, 
(hell, I hope it's even right),

    Ty
-- 
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
Homepage: http://tazer.engrs.infi.net/~tycage
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78  B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------


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

Date: Fri, 03 Oct 1997 10:27:37 -0700
From: Sriram Srinivasan <sriram@weblogic.com>
To: Kaylene Thaler <thalerk@vrinet.com>
Subject: Re: XS & variable-length
Message-Id: <34352B09.63E423A0@weblogic.com>

Kaylene Thaler wrote:
> 
> I am trying to use perl to access a C function, and have been
> almost successful.  The prototype for the C function is:
> 
> extern void mlog(int severity, int msg_num, ...)
> 
> It uses the va_list, va_start, etc to deal with the unknown
> number of parameters.
> 
> void
> mlog(severity, msg_num, ...)
>         int severity
>         int msg_num
> 
> (and that's it)
> 
> How do I get the additional arguments passed to my C function?  It
> seems
> to be passing the 2 integer fields without problems, but not getting
> any of the unknown number of others.

Well, you have some more work to do. The perl passes all its 
parameters to the subroutine as an array of scalar values (SVs).
If you look at the code generated by the XS compiler, you'll see
something like this:
    int severity = (int) SvIV(ST(0));
    int msg_num = (char *) SvPV(ST(1), na);

That is, it converts the scalar values in the stack to corresponding
C variables. It is able to do so only because you have specified
the types of these variables in the .XS file. For the part that's
elided, the XS compiler does not have this information, so it
lets it remain on the stack. 

You have to do this manually. You have two pieces of information
made available to you. The number of items on the stack, in a 
C variable called "items" (xsubpp declares it for you), and
the stack, which you can access by saying SvIV(i), SvPV(i) and so on,
i being the position of the argument. Clearly, you must know 
the type of parameters to expect, so you can use the appropriate
Sv macro (the severity and msg_num must be an indication).

Read the perlxs documentation for a discussion of "PPCODE", and
if it is not clear, ask.

Sketchy details, admittedly, but hope this helps.

-Sriram

________________________________________________________________________
Principal Engineer      WebLogic, San Francisco        www.weblogic.com 
"Advanced Perl Programming" : http://www.ora.com/catalog/advperl/


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

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

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