[22673] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4894 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 25 18:06:32 2003

Date: Fri, 25 Apr 2003 15:05:06 -0700 (PDT)
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, 25 Apr 2003     Volume: 10 Number: 4894

Today's topics:
        "make tardist" does not include subdirectories <pilsl_usenet@goldfisch.at>
    Re: "make tardist" does not include subdirectories (Anno Siegel)
    Re: "make tardist" does not include subdirectories <bigj@kamelfreund.de>
        17015832-WWW-Server testing results here - http://www.s <zmey_i@mail.ru>
    Re: call perl from javascript ?  or use php instead ? <nospam@raytheon.com>
        Errors running Randal and Damian's Parse::RecDescent ex (J. H.)
    Re: Errors running Randal and Damian's Parse::RecDescen (Anno Siegel)
    Re: Getting FULL path+filename from a filehandle <michael.p.broida@boeing.com>
    Re: Getting FULL path+filename from a filehandle <uri@stemsystems.com>
    Re: Getting FULL path+filename from a filehandle <michael.p.broida@boeing.com>
    Re: How to delete the current array element? <skuo@mtwhitney.nsc.com>
    Re: How to delete the current array element? <SeeMessageBody@nospam.com>
    Re: How to delete the current array element? <ethan@draupnir.gso.saic.com>
        How to find out installed packages on Unix <viwang@nortelnetworks.com>
        How to send and receive on IP PORT? <sammie@greatergreen.com>
    Re: How to send and receive on IP PORT? (Walter Roberson)
    Re: Is there an array for ($1, $2, $3, ...) (Anno Siegel)
        Wildcard DNS (Chumley the Walrus)
    Re: Wildcard DNS (Walter Roberson)
        XS or SWIG <peter_wilson@mail.com>
    Re: {newbie} sorting  of files <galenmenzel@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 25 Apr 2003 20:39:29 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: "make tardist" does not include subdirectories
Message-Id: <3ea98120$1@e-post.inode.at>


I've a big module that contains several submodules

like  goldfisch::bigmodule
and  goldfisch::bigmodule::helper1
and  goldfisch::bigmodule::helper2

helper1 and helper2 resides in the subdirectory to bigmodule.
the modules were initally created by 
 h2xs -c -f -X  goldfisch::bigmodule
 h2xs -c -f -X  goldfisch::bigmodule::helper1
 h2xs -c -f -X  goldfisch::bigmodule::helper2

when I do 
"make test" or  "make install" in the main-folder, then all submodules are 
processed also.  But when I do "make tardist" no submodules are included in 
the resulting tar-file.

For I've about 10 submodules I find this very annoying. Whats the trick I 
missed ?

thnx,
peter


-- 
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at



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

Date: 25 Apr 2003 20:10:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: "make tardist" does not include subdirectories
Message-Id: <b8c4nd$5ik$1@mamenchi.zrz.TU-Berlin.DE>

peter pilsl  <pilsl_usenet@goldfisch.at> wrote in comp.lang.perl.misc:
> 
> I've a big module that contains several submodules
> 
> like  goldfisch::bigmodule
> and  goldfisch::bigmodule::helper1
> and  goldfisch::bigmodule::helper2
> 
> helper1 and helper2 resides in the subdirectory to bigmodule.
> the modules were initally created by 
>  h2xs -c -f -X  goldfisch::bigmodule
>  h2xs -c -f -X  goldfisch::bigmodule::helper1
>  h2xs -c -f -X  goldfisch::bigmodule::helper2
> 
> when I do 
> "make test" or  "make install" in the main-folder, then all submodules are 
> processed also.  But when I do "make tardist" no submodules are included in 
> the resulting tar-file.
> 
> For I've about 10 submodules I find this very annoying. Whats the trick I 
> missed ?

Have you re-run "perl Makefile.PL" after adding the additional modules?
That should fix it.

Anno


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

Date: Fri, 25 Apr 2003 23:34:36 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: "make tardist" does not include subdirectories
Message-Id: <pan.2003.04.25.21.29.58.727592@kamelfreund.de>

peter pilsl wrote at Fri, 25 Apr 2003 20:39:29 +0200:

> I've a big module that contains several submodules
> 
> like  goldfisch::bigmodule
> and  goldfisch::bigmodule::helper1
> and  goldfisch::bigmodule::helper2
> 
> helper1 and helper2 resides in the subdirectory to bigmodule.
> the modules were initally created by 
>  h2xs -c -f -X  goldfisch::bigmodule
>  h2xs -c -f -X  goldfisch::bigmodule::helper1
>  h2xs -c -f -X  goldfisch::bigmodule::helper2
> 
> when I do 
> "make test" or  "make install" in the main-folder, then all submodules are 
> processed also.  But when I do "make tardist" no submodules are included in 
> the resulting tar-file.
> 
> For I've about 10 submodules I find this very annoying. Whats the trick I 
> missed ?

Have you tried to write the files of the submodules into the MANIFEST
file?


Greetings,
Janek


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

Date: Fri, 25 Apr 2003 21:49:04 +0000 (UTC)
From: zi <zmey_i@mail.ru>
Subject: 17015832-WWW-Server testing results here - http://www.softrex.com/tornado/eng_test.html
Message-Id: <b8cag6$sna$7@news.rol.ru>

 
   25.04.2003 / 21:49:04 / comp.lang.perl.misc
   -----------------------------------------------------------------------------

   WEB server testing results here: http://www.softrex.com/tornado/eng_test.html

   -----------------------------------------------------------------------------
   Signature=17015832--KKSRWVKC












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

Date: Fri, 25 Apr 2003 13:57:09 -0500
From: Chris Olive <nospam@raytheon.com>
Subject: Re: call perl from javascript ?  or use php instead ?
Message-Id: <Rxfqa.346$35.1067@dfw-service2.ext.raytheon.com>

Eric Osman wrote:
> 
> 
> (note:  If you're a knowledgeable but lazy reader, please skip to
> the last two paragraphs, as maybe you can help me.)
> 
> Hi,
> 
> I have some javascript code that wants some information from the
> server.
> 
> So it seems like I want to call some perl code on the server to
> obtain the information.
> 
> But maybe this isn't easy to do ?  Is it perhaps easier in php ?
> 
> Here are some more specifics of my need.
> 
> The javascript code flashes some pictures on the web page,
> changing the picture every few seconds.
> 
> Right now the names of the picture files are "hard-coded" right
> into my javascript.
> 
> Instead of hard-coding them in, I'd like to call some perl code
> on the server to ~ask~ what the file names are.
> 
> Here's some actual existing javascript:
> 
> var holidayPics = new Array(
>     "images_new/tea_party/tp518.jpg",
>     "images_new/tea_party/tp520.jpg",
>     "images_new/crescent_moon/cm020.jpg"
>     );
> var holidayIndex = -1;
> function holidayFlipper(millis){
>   var nPics = holidayPics.length;
>   if (nPics <= ++holidayIndex)
>       holidayIndex = 0;
>    document.holiday.src=holidayPics[holidayIndex];
>    setTimeout("holidayFlipper(2000)",millis);
>  }
> 
> 
> See that holidayPics array ?  Instead of hardcoding that in, I'd like to
> call a perl function on the server to obtain the list of files.
> 
> The basic conceptual problem I'm having is that all the perl I've used
> so far is triggered by a form action.  And that perl in turn uses print
> to generate an entirely new web page.
> 
> So I don't know how to call perl on an as-needed basis from javascript
> to obtain information.  Perhaps this just isn't possible and that php
> is designed for this purpose ?

Think about using Perl in reverse of how you are presenting it here. 
There is no direct call linkage between client-side JavaScript and 
server-side Perl/CGI.  The common methodology here is to let a Perl CGI 
script generate your JavaScript and present it to the requesting browser 
on-the-fly.  So Perl generates the JavaScript you show in your example 
above, and you build the JS array on the fly.

The only "call linkage" between Perl and JavaScript is a triggered 
submit or window location change and therefore another round-trip to the 
HTTP server, which puts you right back where I'm describing in my 
paragraph above.

Chris
-----
Chris Olive
Systems Consultant
Raytheon Technical Services Corporation
Indianapolis, IN

email: olivec(AT)indy(DOT)raytheon(DOT)com



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

Date: 25 Apr 2003 11:47:23 -0700
From: loopy1@ureach.com (J. H.)
Subject: Errors running Randal and Damian's Parse::RecDescent examples
Message-Id: <6d0c93f5.0304251047.77bb0002@posting.google.com>

I've been trying to learn how to use Parse::RecDescent to parse an
Oracle SQL*Loader control file, and I was having extreme difficulty
getting anything useful to happen. So, I thought, I'll take the
examples in some tutorials out there and run them, just to see if I
can make some progress.

But, I'm having difficulty getting them to work, either. When I run
Randal Schwartz's example from
http://www.stonehenge.com/merlyn/UnixReview/col40.html,
using the following code (against my computer's win.ini file):

#! /usr/bin/perl -w

use Parse::RecDescent;

my $grammar = q{

    file:
    sections /\z/
    { my %return;
      my $sections = $item{sections};
      for my $section (@$sections) {
        my ($section_marker, $definitions) = @$section;
        for my $definition (@$definitions) {
          my ($key, $value) = @$definition;
          for ($return{$section_marker}{$key}) {
            if (not defined $_) {
              $_ = $value;
            } elsif (not ref $_) {
              $_ = [$_, $value];
            } else {
              push @$_, $value;
            }
          }
        }
      }
      \%return;
    }

};

my $parser = Parse::RecDescent->new($grammar);


I get the following error:

Warning: Undefined (sub)rule "sections" used in a production.

(Note that I changed the #! line to disguise the name of my company.)


When I run Damian's Abbott and Costello example from
http://search.cpan.org/src/DCONWAY/Parse-RecDescent-1.80/tutorial/tutorial.html
I get the following error:

ERROR (line -2): Unmatched > found.
                (Hint: Set $::RD_HINT (or -RD_HINT if you're using
"perl -s")
                       for hints on fixing these problems.)

                ERROR: Internal error in generated parser code!
                (Hint: Set $::RD_HINT (or -RD_HINT if you're using
"perl -s")
                       for hints on fixing these problems.)
  Who's on first?
    Yes
Can't call method "Interpretation" on unblessed reference at ./aac
line 115.

Note that I had cut and pasted the code in both cases to limit the
possibility of introducing an error.

These errors are similar to the errors I was getting with my own stuff
(which I had chalked up to my ineptitude). Now I'm wondering if
there's something wrong with my Perl, the version of
Parse::RecDescent, or the cosmos. :-)

I'm using the following (I edited the @INC lines slightly to disguise
my company's name):

Summary of my perl5 (revision 5.0 version 6 subversion 1)
configuration:
  Platform:
    osname=solaris, osvers=2.8, archname=sun4-solaris
    uname='sunos dev00.devel.in.exactis.com 5.8 generic_108528-12
sun4u sparc sunw,ultra-2 '
    config_args='-Dcc=gcc -B/usr/ccs/bin/'
    hint=previous, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
  Compiler:
    cc='gcc', ccflags ='-fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O',
    cppflags='-fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    ccversion='', gccversion='2.95.3 20010315 (release)',
gccosandvers='solaris2.8'
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=16
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib '
    libpth=/usr/local/lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc
    perllibs=-lsocket -lnsl -ldl -lm -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: USE_LARGE_FILES
  Built under solaris
  Compiled at Jan 25 2002 13:43:25
  @INC:
    /opt/perl/5.6.1/lib/5.6.1/sun4-solaris
    /opt/perl/5.6.1/lib/5.6.1
    /opt/perl/5.6.1/lib/site_perl/5.6.1/sun4-solaris
    /opt/perl/5.6.1/lib/site_perl/5.6.1
    /opt/perl/5.6.1/lib/site_perl
    .

My version of Parse::RecDescent is 1.80. My version of Text::Balanced
is 1.83.

Anyway, if anyone has any suggestions, I would greatly appreciate
them. Be gentle, because my brain is small. :-)

TIA,

J.H.


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

Date: 25 Apr 2003 20:49:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Errors running Randal and Damian's Parse::RecDescent examples
Message-Id: <b8c70p$7ir$1@mamenchi.zrz.TU-Berlin.DE>

J. H. <loopy1@ureach.com> wrote in comp.lang.perl.misc:
> I've been trying to learn how to use Parse::RecDescent to parse an
> Oracle SQL*Loader control file, and I was having extreme difficulty
> getting anything useful to happen. So, I thought, I'll take the
> examples in some tutorials out there and run them, just to see if I
> can make some progress.

[snip Randal (hey, sorry, no .ini here)]

> When I run Damian's Abbott and Costello example from
> http://search.cpan.org/src/DCONWAY/Parse-RecDescent-1.80/tutorial/tutorial.html
> I get the following error:
> 
> ERROR (line -2): Unmatched > found.
>                 (Hint: Set $::RD_HINT (or -RD_HINT if you're using
> "perl -s")
>                        for hints on fixing these problems.)
> 
>                 ERROR: Internal error in generated parser code!
>                 (Hint: Set $::RD_HINT (or -RD_HINT if you're using
> "perl -s")
>                        for hints on fixing these problems.)
>   Who's on first?
>     Yes
> Can't call method "Interpretation" on unblessed reference at ./aac
> line 115.
> 
> Note that I had cut and pasted the code in both cases to limit the
> possibility of introducing an error.

Well, HTML is tricky and there seems to be a glitch in the page.

Looking for a lone ">", as the error indicates, you'll find the
culprit at the beginning of the $costello grammar, reading

        Interpretation:
                Meaning {prev}> 
                        { $thisparser->{prev} = $item[1] }
              | { choose(@::try_again) }

Apparently, "{prev}>" shouldn't be there, correct it to

        Interpretation:
                Meaning { $thisparser->{prev} = $item[1] }
              | { choose(@::try_again) }
                
This makes more sense.  Remember, stuff in {} is supposed to be Perl
code.  A bare "prev" won't do.  While it's possible that another
alternative belongs there, the demo runs fine with this correction.

> These errors are similar to the errors I was getting with my own stuff
> (which I had chalked up to my ineptitude). Now I'm wondering if
> there's something wrong with my Perl, the version of
> Parse::RecDescent, or the cosmos. :-)

Just web damage.  What else is new?

Why didn't you try the first example (diff reversal) first?  It is
simpler, and it runs as presented.  I expect a similar glitch is
messing up Randal's code.

Anno


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

Date: Fri, 25 Apr 2003 18:43:57 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Getting FULL path+filename from a filehandle
Message-Id: <3EA981ED.A8A26463@boeing.com>

Uri Guttman wrote:
> 
> >>>>> "MPB" == Michael P Broida <michael.p.broida@boeing.com> writes:
> 
>   MPB>  I've been digging through the Camel book and haven't been
>   MPB>  able to find out how to get the FULL path+filename from a
>   MPB>  filehandle.
> 
> you can't.
> 
>   MPB>  At the time the file was opened, I had "current directory"
>   MPB>  and the "filename" (with possible partial/relative path).
>   MPB>  So the "open" worked just fine.  And I could, at that point,
>   MPB>  build the full path from that info.
> 
> so do it there and keep it associated with the handle in a tied object,
> a hash or whatever.

	That's probably what I will have to do.

>   MPB>  I know the OS has that info, but I can't seem to find any
>   MPB>  way to get it in Perl.  Any ideas/pointers??
> 
> how do you know the OS has this? which OS? most actually don't have it.

	Yes, they do.  The actual data connected with the filehandle
	INSIDE the filemanagement handlers/drivers/whatevernameyouwant
	includes the information used to GET to the file to open it.
	Once the file is open, the structure itself is enough to work
	with it, but that info is still there.

	I've worked with a dozen or more OSes and I know for certain
	that at least three of them had this capability built in via
	system calls.  (I don't know if any of the others had it or not
	because I never needed it on those system.)  Hmm, I thought I
	had done this on Solaris six+ years ago (not in Perl), but I
	don't recall the context so I'm unsure about it.

> in fact the whole idea of handles is so you don't need to keep it
> around in the OS.

	No, it's so the user of the file doesn't need to keep referring
	to the file by name/whatever.  The system still has it, though.

> and with unix, multiple paths could point to the same file so
> which is the correct one?

	Good point.  All would be "correct", though usually only
	ONE would be the one I would be interested in at any time.
	This would be the most direct expansion of the name used
	to open the file.  In this case, I'm working on Win2k, so
	links don't really come into play here.

> the only proper solution is to track it yourself. but needing a path
> later on for a handle tells me you have a design problem. you should
> have been tracking that all along in a higher level structure and not
> expecting perl or the OS to do it for you.

	I never expected to need the full path in that lowest level.
	Things changed; now I need it.

	I'll look into switching to a hash with the filehandle + the
	filename/path, but I'll still have to build the actual "path+name"
	from the original (possibly partial) path and current directory.
	Not impossible, but I had hoped someone may have already built
	a package to do this.

		Mike


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

Date: Fri, 25 Apr 2003 19:09:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Getting FULL path+filename from a filehandle
Message-Id: <x7he8mgzrk.fsf@mail.sysarch.com>

>>>>> "MPB" == Michael P Broida <michael.p.broida@boeing.com> writes:

  >> how do you know the OS has this? which OS? most actually don't have it.

  MPB> 	I've worked with a dozen or more OSes and I know for certain
  MPB> 	that at least three of them had this capability built in via
  MPB> 	system calls.  (I don't know if any of the others had it or not
  MPB> 	because I never needed it on those system.)  Hmm, I thought I
  MPB> 	had done this on Solaris six+ years ago (not in Perl), but I
  MPB> 	don't recall the context so I'm unsure about it.

and 3 out of a dozen or more is most? i said most don't have it.
and unix flavors in general don't. the internal inode structure does not
have room for a path. it only keeps the inode number.

  >> in fact the whole idea of handles is so you don't need to keep it
  >> around in the OS.

  MPB> 	No, it's so the user of the file doesn't need to keep referring
  MPB> 	to the file by name/whatever.  The system still has it, though.

no, it is because the OS doesn't need it anymore as it can use the
internal file info. this is the common style on unix. on others, i can't
say for sure. do you know OS/390? or RT-11?

  >> and with unix, multiple paths could point to the same file so
  >> which is the correct one?

  MPB> 	Good point.  All would be "correct", though usually only
  MPB> 	ONE would be the one I would be interested in at any time.
  MPB> 	This would be the most direct expansion of the name used
  MPB> 	to open the file.  In this case, I'm working on Win2k, so
  MPB> 	links don't really come into play here.

and you can't tell which is the good one. look at the lsof utility and
see what it does.

  MPB> 	I never expected to need the full path in that lowest level.
  MPB> 	Things changed; now I need it.

anticipating future needs is part of architecture and design. and i
still doubt you need it but i can't know for sure unless i knew your
project. any system i would design that manages multiple files would
probably have a higher level object that could easily be modified to
hold the path name. then i wouldn't have to worry about adding such a
thing in the future.

  MPB> 	I'll look into switching to a hash with the filehandle + the
  MPB> 	filename/path, but I'll still have to build the actual "path+name"
  MPB> 	from the original (possibly partial) path and current directory.
  MPB> 	Not impossible, but I had hoped someone may have already built
  MPB> 	a package to do this.

there are such beasts on cpan that are tied handles. seek and ye shall
find.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 25 Apr 2003 18:53:25 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Re: Getting FULL path+filename from a filehandle
Message-Id: <3EA98425.C806F8D1@boeing.com>

"John W. Krahn" wrote:
> 
> "Michael P. Broida" wrote:
> >
> > I've been digging through the Camel book and haven't been
> > able to find out how to get the FULL path+filename from a
> > filehandle.
> 
> Assuming that you are running Linux:
> 
> my $fullpath = readlink "/proc/$$/fd/" . fileno filehandle;

	Any ideas how to do that on Win2K?  I'm not lucky enough
	to be using any kind of Unix here.  <grin>

	What is the "fileno" in your example??  Oh, I think I see
	it (now that I see what the $$ part was all about).  I don't
	think there's any true parallel to that in Windows, though.

	It seems (from the Camel book) that "readlink" requires a
	symbolic link:
		EXPR should evalute to a filename, the last
		component of which is a symbolic link.
	It also only wants one argument, not two as in your example.

	Well, I'll give it a quick test to see if maybe it will work
	with an actual filename w/o link part.  Then I'll try to dig
	in the perldocs some more on stuff related to readlink.

		Thanks!
			Mike


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

Date: Fri, 25 Apr 2003 11:19:37 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: How to delete the current array element?
Message-Id: <Pine.GSO.4.21.0304251118240.14346-100000@mtwhitney.nsc.com>

On Fri, 25 Apr 2003, John wrote:

> I put the lines of a report into an array and used "pop" and "shift" to trim
> it down to the goodies.
> 
> The remaining lines begin with a keyword.  Unless that keyword exists in my
> hash, I want that line out of the array.  This would be easily accomplished
> by putting the lines into another hash (using that keyword as the key), but
> that would lose their order.  The order of these lines is definitely *not*
> trivial, and that's why I want to keep them in an array.  I wouldn't be able
> to re-order them.
> 
> #
> #  Go through @lines and remove those that don't exist in %myhash...
> #
> foreach (@lines) {
>         if (/(^\w+)/) {                         # Grab that keyword from the
> beginning of this line...
>            unless exists $myhash{$1} {      #  ...unless it exists as a key
> in %box, get rid of it.
>                 #  How to delete the current line from the array?  That's
> the $64 question.
>            }
> }
>  
[ snipped ]



Use grep:

@lines = grep /^(\w+)/ && exists $myhash{$1}, @lines;

-- 
Hope this helps,
Steven



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

Date: Fri, 25 Apr 2003 18:34:56 GMT
From: "John" <SeeMessageBody@nospam.com>
Subject: Re: How to delete the current array element?
Message-Id: <kdfqa.41762$4P1.3809735@newsread2.prod.itd.earthlink.net>


"Steven Kuo" wrote:
>
> Use grep:
>
> @lines = grep /^(\w+)/ && exists $myhash{$1}, @lines;

WHOA!  I didn't realize Perl had a grep *operator*!  I thought there was
only the grep utility on Unix!  (I see it in the later pages of my book now.
Maybe I should finish reading it!)

Perl is just too convenient!  I'm surprised somebody hasn't banned it!   :^)

> Hope this helps,

Boy, did it!  Thanks, Steven!  Gosh, I replaced a loop with one line!  You
are awesome, Dude.




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

Date: 25 Apr 2003 11:46:00 -0700
From: Ethan Brown <ethan@draupnir.gso.saic.com>
Subject: Re: How to delete the current array element?
Message-Id: <vr65p2bel3.fsf@draupnir.gso.saic.com>


>>>>> "John" == John  <SeeMessageBody@nospam.com> writes:

    John> I put the lines of a report into an array and used "pop" and "shift" to trim
    John> it down to the goodies.

    John> The remaining lines begin with a keyword.  Unless that keyword exists in my
    John> hash, I want that line out of the array.  This would be easily accomplished
    John> by putting the lines into another hash (using that keyword as the key), but
    John> that would lose their order.  The order of these lines is definitely *not*
    John> trivial, and that's why I want to keep them in an array.  I wouldn't be able
    John> to re-order them.

    John> #
    John> #  Go through @lines and remove those that don't exist in %myhash...
    John> #
    John> foreach (@lines) {
    John>         if (/(^\w+)/) {                         # Grab that keyword from the
    John> beginning of this line...
    John>            unless exists $myhash{$1} {      #  ...unless it exists as a key
    John> in %box, get rid of it.
    John>                 #  How to delete the current line from the array?  That's
    John> the $64 question.
    John>            }
    John> }

Hi John--

Seems like grep would work well for this.  Think of grep as a filter
that only allows the array elements you want.  Your array order will
be maintained:

@lines = grep {exists $myhash{(/(^\w+)/)[0]}} @lines;

or 

@lines = grep {/(^\w+)/; exists $myhash{$1}} @lines;

if that's clearer.

--Ethan Brown
--Keyboards: "The Fabulous Pelicans" (www.pelicans.com)
--In a band?  Use http://www.WheresTheGig.com for free.



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

Date: Fri, 25 Apr 2003 14:28:19 -0700
From: "Wang, Vincent" <viwang@nortelnetworks.com>
Subject: How to find out installed packages on Unix
Message-Id: <3EA9A873.EA35E48C@nortelnetworks.com>

How are you?

Do you know how to find out the Perl packages that already installed on
my UNIX or Linux, like “ppm query” does on win32?

Thanks,
Vincent




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

Date: Fri, 25 Apr 2003 21:26:46 GMT
From: "Brad Walton" <sammie@greatergreen.com>
Subject: How to send and receive on IP PORT?
Message-Id: <qKhqa.379953$Zo.88046@sccrnsc03>

I am looking for information on how to send information and receive (listen)
for information on a port. For example, I want to have a perl program
running on one PC, while another sits on a remote machine and listens for
incoming data on a specified port. What would this process be called? And
are their any examples or tutorials of how this is accomplished?

Thanks,
Sammie




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

Date: 25 Apr 2003 21:44:12 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: How to send and receive on IP PORT?
Message-Id: <b8ca7c$gnj$1@canopus.cc.umanitoba.ca>

In article <qKhqa.379953$Zo.88046@sccrnsc03>,
Brad Walton <sammie@greatergreen.com> wrote:
:I am looking for information on how to send information and receive (listen)
:for information on a port. For example, I want to have a perl program
:running on one PC, while another sits on a remote machine and listens for
:incoming data on a specified port. What would this process be called? And
:are their any examples or tutorials of how this is accomplished?

I'm not overly familiar with PCs, but you can probably treat the
IR port as a serial port with a slightly different device name.

There's almost certainly a CPAN module for dealing with serial ports.


On the other hand, if you want to be transfering files and such then you
might want to look at the (non-perl) pilot-tools suite, which knows
about all the higher-layer protocols that have been developed for use
with IR. That would be a much better approach if you hoped to be
able to have arbitrary PCs, laptops, or PDAs connect up.
-- 
When your posts are all alone / and a user's on the phone/
there's one place to check -- / Upstream!
When you're in a hurry / and propagation is a worry/
there's a place you can post -- / Upstream!


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

Date: 25 Apr 2003 18:19:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is there an array for ($1, $2, $3, ...)
Message-Id: <b8bu7c$2cf$1@mamenchi.zrz.TU-Berlin.DE>

Sara <genericax@hotmail.com> wrote in comp.lang.perl.misc:
> "Janek Schleicher" <bigj@kamelfreund.de> wrote in message
> news:<pan.2003.04.25.14.02.32.366977@kamelfreund.de>...
> > Sara wrote at Fri, 25 Apr 2003 06:12:20 -0700:
> > 
> > > Of course we can use @ARGV for ($ARGV[0], $ARGV[1], ...)
> > > and @_ for ($_[0], $_[1],...)
> > > 
> > > Is there an array defined for ($1, $2, $3,...)  after a regex defines
> > > them? I did a perldoc -q on regex and some other keywords but I didn't
> > > discover anything related.
> > 
> > Well, normally you won't need a special array,
> > as you can always do something like
> > 
> > @array = $string =~ /match/;
> > 
> > and now @array contains ($1, $2, $3, ...)
>   .
>   .
> 
> Thanks both of you- I never saw that before. It doesn't come up often
> that I'd need an array like that but on occasion it may be useful.

Ah, but watch out for occasions to use m// in list context.  It comes
more up more often than is apparent, and it's much more stylish to write

    my ( $source, $target) = m/.()..()../;

instead of

    m/.()..()../;
    my ( $source, $target) = ( $1, $2);

don't you think?

Used in assignments like this it's an alternative to split(), sometimes
superior.  As Randal's Rule has it, "If you know what to throw away, use
split().  If you know what to keep, use m//."

That's only assignment.  There are clever little loops, like

    ... for m/.../g;

and similar tricks.  You'll find them when you look for them.  These
things make up another of Perl's virtues: Making trivial things trivial.

Anno


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

Date: 25 Apr 2003 11:39:40 -0700
From: springb2k@yahoo.com (Chumley the Walrus)
Subject: Wildcard DNS
Message-Id: <1ef65641.0304251039.3fbd8eec@posting.google.com>

Does Wildcard DNS allow you to create domain aliases on your server?

myalias.mydomain.com , for example?

Is this something that a website operator (other than system
administrator )can implement on unix and linux servers easily?

thx
Chum


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

Date: 25 Apr 2003 18:58:50 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Wildcard DNS
Message-Id: <b8c0ha$cgr$1@canopus.cc.umanitoba.ca>

In article <1ef65641.0304251039.3fbd8eec@posting.google.com>,
Chumley the Walrus <springb2k@yahoo.com> wrote:
:Does Wildcard DNS allow you to create domain aliases on your server?

That isn't a perl question.

:myalias.mydomain.com , for example?

No, not really.


:Is this something that a website operator (other than system
:administrator )can implement on unix and linux servers easily?

Wildcard DNS is usually only used for MX (Mail Exchanger)
records and NS (Name Server) records.

With your reference to websites, what I -suspect- you are trying
to ask about is something usually referred to as "Virtual Hosts".
Each different variety of WWW server configures these differently;
it is relatively easy to configure Virtual Hosts in the
{fairly common} Apache http server. It is, though, relatively
useless for the server operator to configure virtual hosts
without the cooperation of the DNS administrator to add in
the appropriate DNS reference.


I guess it would be possible in theory to deliberately wildcard a
CNAME (Canonical Name) record so that the http server administrator
could configure any virtual host in that subdomain, but I don't
think this would be at all common, and I would expect most
DNS administrators to be reluctant to impliment this. [Also,
I'd want to check the DNS RFC, as I have a vague memory that
it recommends against this or forbids it.]
-- 
   I was very young in those days, but I was also rather dim.
   -- Christopher Priest


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

Date: Fri, 25 Apr 2003 18:07:43 +0000 (UTC)
From: "Peter Wilson" <peter_wilson@mail.com>
Subject: XS or SWIG
Message-Id: <b8bthf$oog$1@sparta.btinternet.com>

Hi All

Imp trying to call a dll with lots of different functions in it (some of
them return data structures (records of data I want to read)). Up until now
I have been avoiding all my issues using Win32::API but it would appear that
I am now forced into needing to use more a complex route to get at the
returned data structures (or at least I think I do). From what I read I
think that SWIG or XS are needed. Does anyone know of a book / web site /
set of examples of how to write XS or SWIG or have any advice on which is
best to use. I have a header file (.h) and the library (.dll) and no source
files.

Oh and my C is very bad thus I am trying to avoid it as much as I can. From
an example in C the function I am trying to call simply calls

ad_textul->ad_name

returning the ad_name from the structured definition ad_textul or at least
that's what I think its doing.

Anyway sorry if this is the wrong group but I cant find anyone talking about
XS (as this is what I think im going to end up using).

Help please anything will be kindly received and considered progress.

Peter




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

Date: 25 Apr 2003 18:14:17 GMT
From: Galen Menzel <galenmenzel@yahoo.com>
Subject: Re: {newbie} sorting  of files
Message-Id: <slrnbaiutq.sj.galenmenzel@localhost.localdomain>

In article <x77k9jjpxk.fsf@mail.sysarch.com>, Uri Guttman wrote:
>>>>>> "BS" == Bill Smith <wksmith@optonline.net> writes:
> 
>  BS> "Uri Guttman" <uri@stemsystems.com> wrote in message
>  BS> news:x765p3lh0y.fsf@mail.sysarch.com...
>  >> >>>>> "o" == oracle1  <santyspamsharma@hotmail.com> writes:
>  >> 
>  o> sub by_time_and_files {
>  o> $file_hash{b} <=> $file_hash{a}
>  >> $b                $a
> 
> 
>  BS> This is the kind of error that use strict usually finds.  I understand
>  BS> that this is a special casek and it would not have helped, but my advice
>  BS> is still "always use strict".
> 
> what does strict have to do with this? $foo{a} is valid at all times
> in perl.  nothing could detect that bug automatically since
> barewords are legal keys.

That's why he should have used a pseudohash.  That would have solved
all his problems!

Oh, wait...

galen


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

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


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