[13278] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 688 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 31 14:07:19 1999

Date: Tue, 31 Aug 1999 11:05:09 -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           Tue, 31 Aug 1999     Volume: 9 Number: 688

Today's topics:
    Re: @INC question. <makkulka@cisco.com>
    Re: @INC question. <sg@midwal.ca>
    Re: @INC question. <makkulka@cisco.com>
    Re: a simple POST request <makkulka@cisco.com>
    Re: Auto actions on popup_menu's <makkulka@cisco.com>
    Re: Case insensitive SQL query <hartleh1@westat.com>
        Delete (Jimtaylor5)
    Re: Delete <rra@stanford.edu>
    Re: Desperately searching for perl lint (M.J.T. Guy)
        filefield from CGI module, why are my binarys getting c <davem@skantech.net>
    Re: how to make sort() case insensitive? <baal@c2i.net>
        Java parser in perl <caitchison@novell.com>
        Mail including HTML tag... <wcube@thrunet.com>
    Re: newbie needs help <r.mangol@radium.ncsc.mil>
    Re: perl equivalent of a Unix command line sort? (Paul L. Lussier)
        Perl On NT <billtucker@lucent.com>
    Re: Perl Y2K Bugs on the Internet <phill@myriad.com>
    Re: Posting forms with Perl <makkulka@cisco.com>
    Re: Problem with <!--#exec cgi=/scripts/script.pl%22--> <ehpoole@ingress.com>
    Re: Problem with <!--exec cgi="/scripts/script.pl"--> i <lisa_mcnally@mail.crc.com>
    Re: regex bug: (?:\d{3})+ loses count (M.J.T. Guy)
    Re: Request for Comments: www.perl.com (Chris Nandor)
    Re: Sockets and Threads <aqumsieh@matrox.com>
    Re: Using grep to match complete words <yunus000@england.com>
    Re: Using grep to match complete words (Larry Rosler)
    Re: Using grep to match complete words <Joe.Kline@sdrc.com>
    Re: using the exec command. (Alan Curry)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Tue, 31 Aug 1999 10:23:19 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: @INC question.
Message-Id: <37CC0F86.C0D8B495@cisco.com>

[ SG wrote:

> Unfortunately the directories and disk names are different at these two
> machines, so the value of @INC is now wrong.

What exactly is wrong in @INC? Is is not finding a Module(s)? If this
is the case then you can modify @INC.

> How can I modify @INC to reflect a new environment?

Just add your new directory paths to @INC in a BEGIN block.
--



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

Date: Tue, 31 Aug 1999 17:46:17 GMT
From: SG <sg@midwal.ca>
Subject: Re: @INC question.
Message-Id: <37CC135E.210C0882@midwal.ca>



Makarand Kulkarni wrote:

> [ SG wrote:
>
> > Unfortunately the directories and disk names are different at these two
> > machines, so the value of @INC is now wrong.
>
> What exactly is wrong in @INC?

Names of all directories in i@INC are from the 1-st
computer: /apps/.../perl5/site_perl/5.005
instead of
 /home/.../name/site_perl/5.005
which I have at the 2-nd one.


> Is is not finding a Module(s)? If this
> is the case then you can modify @INC.
>
> > How can I modify @INC to reflect a new environment?
>
> Just add your new directory paths to @INC in a BEGIN block.
> --





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

Date: Tue, 31 Aug 1999 10:52:12 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: @INC question.
Message-Id: <37CC164B.2EDF9FE2@cisco.com>

[ SG wrote:

> Names of all directories in i@INC are from the 1-st
> computer: /apps/.../perl5/site_perl/5.005
> instead of
>  /home/.../name/site_perl/5.005
> which I have at the 2-nd one.

If running this one liner

perl -e 'print "@INC\n"' does not show paths that are on the 2-nd machine it
means that your Perl installation is not correct. The perl stuff (I am
referring
to Perl and Modules themselves ) were not moved correctly.  Modification
of @INC is advisable iff you have modules installed elsewhere other
than directories mentioned in @INC.  @INC has to have
correct paths at run time.
--



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

Date: Tue, 31 Aug 1999 10:34:16 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: a simple POST request
Message-Id: <37CC1217.33F41B25@cisco.com>

[ vengence7140@my-deja.com wrote:

> ..send a post request to a server, followed by
> a body of text. What I want to do on server
> side is to get the body of text and process it.

Your question is not clear. Your body of text ( for example
this could be some amount of text from a textarea element
inside a HTML form ) has to be sent as a value in a name/value
pair. On the server side you get the value (which is the body)
of text then do whatever you like. For example using CGI.pm
you will do something like this --

$long_text_element = $CGIObject->param ('name');
where 'name' is the name of the textarea element in the HTML form.
--



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

Date: Tue, 31 Aug 1999 10:28:35 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Auto actions on popup_menu's
Message-Id: <37CC10C3.5F7B099@cisco.com>

Aaron Lister wrote:

> How do I have an action run automatically when an item is selected from a
> popup_menu in a per/cgi script without using JavaScript?

There is no way to do this ( without using JavaScript ). No action can happen
unless
you do a "submit".
--




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

Date: Tue, 31 Aug 1999 12:31:08 -0400
From: HHH <hartleh1@westat.com>
Subject: Re: Case insensitive SQL query
Message-Id: <37CC034C.B7BFD7E3@westat.com>

select fldGroupID, fldGroupName from tblPhotoGroup where
upper(fldGroupNa
me) like 'DOR;

elephant wrote:
> 
> mrbog@my-deja.com writes ..
> 
> <completely irrelevant to Perl question deleted>
> 
> >Do any of you know how to do that?  (I know this isn't exactly a perl
> >question, sorry..)
> 
> not "exactly" a Perl question ? .. it's not a Perl question at all -
> MySQL has a HEAP of documentation .. and a HEAP of mailing lists for
> asking these kinds of questions
> 
> you're far more likely to find someone there that'll be able to answer
> your question .. we know about Perl - not MySQL .. if I were to take a
> wild stab in the dark - I'd say their web page is probably www.mysql.com
> 

Actually, it is http://www.tcx.se/

In answer to the original question:

  select from dbname where UPPER(name) like "%JOE%";

Naturally, you can use LOWER() as well.  Don't forget to make the
pattern match the function.

Henry


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

Date: 31 Aug 1999 17:23:37 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Delete
Message-Id: <19990831132337.07525.00002402@ng-cj1.aol.com>

Is there a safe way to unlink all files in a directory with only numbers as the
name while leaving the other files intact? For example, I have message files
that I want to occassionally reset. i.e., 231.txt 232.txt 233.txt. How would I
accomplish this and leave, use.txt, dat.txt, or even d11.txt untouched.




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

Date: 31 Aug 1999 10:32:31 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Delete
Message-Id: <ylwvubetzk.fsf@windlord.stanford.edu>

Jimtaylor5 <jimtaylor5@aol.com> writes:

> Is there a safe way to unlink all files in a directory with only numbers
> as the name while leaving the other files intact? For example, I have
> message files that I want to occassionally reset. i.e., 231.txt 232.txt
> 233.txt. How would I accomplish this and leave, use.txt, dat.txt, or
> even d11.txt untouched.

opendir (D, 'directory') or die "Can't open directory: $!\n";
my @files = grep { /^\d+\.txt$/ } readdir D;
for (@files) {
    unlink "directory/$_" or warn "Unable to unlink directory/$_: $!\n";
}
closedir D;

readdir returns a list of files in the directory, and the grep returns
just those files in that list that match the regular expression.  The
above then steps through the resulting list and unlinks them one at a
time.  unlink can take a list of files to unlink, but then if any of the
unlinks fail, you don't know which one failed and can't report it.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 31 Aug 1999 16:06:50 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Desperately searching for perl lint
Message-Id: <7qguiq$2ms$1@pegasus.csx.cam.ac.uk>

Ala Qumsieh  <aqumsieh@matrox.com> wrote:
>Yes. But this only works on variables in the symbol table, and not on
>lexically scoped vars.
>
>Witness:
>
>% perl -w
>my $x;
>__END__
>% perl -w
>local $x;
>__END__
>Name "main::x" used only once: possible typo at - line 1.
>
>
>It will be nice to be able to check for that. Btw, is this a bug?

Nope.   It's entirely deliberate.   -w warnings aren't there just to
harrass innocent programmers  -  they're there to catch common and/or
dangerous mistakes.

So what's this check *for*?    The message offers a hint, and the perldiag
entry elaborates on this:

     Name "%s::%s" used only once: possible typo
         (W) Typographical errors often show up as unique
         variable names.  If you had a good reason for having a
         unique name, then just mention it again somehow to
         suppress the message.  The use vars pragma is provided
         for just this purpose.

Consider the various ways a variable name might be misspelt:

a)  if the misspelling is the same as another variable (lexical or global)
    we can't distinguish this from correct usage, so no warning.   Tough.

b)  if it is different from any other variable, it will be global by
    default, so you'll get the warning as desired.

c)  in the special case where the variable is after 'my', so lexical,
    the effect depends on whether the variable is otherwise referred to.
    If there are other references, they will generate "used once" or
    "use strict" errors, since the lexical declaration has been lost.

d)  if the variable after 'my' has no other references, changing its
    name has no effect on the semantics of the program.   So no need
    for an error.



Mike Guy


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

Date: Tue, 31 Aug 1999 13:51:22 -0400
From: "David Mears" <davem@skantech.net>
Subject: filefield from CGI module, why are my binarys getting corrupted
Message-Id: <37cc164d.0@news.skantech.net>

    $theupload = $g->param('uploadfile');
      if (<$theupload>)
    {
     if (!$theupload && $g->cgi_error)
       {
        print $g->header(-status=>$g->cgi_error);
         exit 0;
       }
       $Wtype = $g->uploadInfo($theupload)->{'Content-Type'};
       unless (($Wtype eq 'image/gif') or ($Wtype eq 'image/jpeg'))
       {
        die "Uploads can only be gifs or jpegs.  Please hit the back
button.";
       }
       $dirref =
"D:\\InetSrv\\wwwroot\\skantech\\GAIN\\Classifieds\\attach\\$cname";
     ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
     $filestub = $year . '_' . $yday . "_" . $hour . "_" . $min . "_" .
$sec;
     if ($Wtype eq 'image/gif')
     {
      $fileref = $filestub . ".gif"
     }
     else
     {
      $fileref = $filestub . ".jpg"
     }

     mkdir($dirref,666);
       chdir $dirref or die "\nCan't Change to the proper directory:
\"$dirref\"";
#     close($theupload);
     binmode($theupload);
     copy($theupload,$dirref . "\\" . $fileref) or die "Move Failed!";
      print {NEWDB} "\@PHOTO:",
"http:\/\/www.greenvillenc.net\/Classifieds\/attach\/", $cname, "\/" ,
$fileref, "\n";
    }
     else
     {
      print {NEWDB} "\@PHOTO:\n";
     }

    $itemhigher = 3;
    $foundit = 3;
   }

the file I end up getting seams to be smaller than the original and somewhat
useless.  I'm trying to take a file uploaded from the browser and copy it to
a place and name of my choosing.. however, it seams what I'm getting isn't
the original gif or jpg.. but rather just crud..  I can't tell if the copy
function is bombing out or the upload aspect or where the problem is.  I
thought binmode would be helpful, but it seams ineffectual.  I would prefer
to move as opposed to copy, but that bombs out with an error message.
(it's running on NT 4, service pack 5, running active state perl 5.005_03
build 517.  I've checked the faq and newsgroups and haven't seen this
particular problem faced in a way that leads me towards a solution. Any help
would be greatly appreciated.  Thanks in advance.




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

Date: Tue, 31 Aug 1999 16:17:33 GMT
From: "[L] Vicious!" <baal@c2i.net>
Subject: Re: how to make sort() case insensitive?
Message-Id: <xeTy3.1619$I5.177628@juliett.dax.net>

Actually I agree, but the could you do me a favour. I run Win98, and when I
run 'perldoc -f sort' there is no way to actually read the stuff. |more
doesn't work either and I coulnd find any page switches, neither can I write
the results to a file using >sort.txt. Suggestions? Thnx for helping, by the
way!    (o:

Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.1234a1ed589ea144989ee3@nntp.hpl.hp.com...
> In article <37CAFAF6.46EFEFA4@cisco.com> on Mon, 30 Aug 1999 14:43:18 -
> 0700, Makarand Kulkarni <makkulka@cisco.com> says...
> > [ "[L] Vicious!" wrote:
> >
> > > Hi, simple question, the sort() function sorts the contents of an
array in
> > > this order a-z then A-Z (and then 0-9 I think, but thats not too
important).
> >
> > This is the default behaviour. You can change it.
>
> No, it's not.  Yes, you can.
>
> > > Is there a way to make the function case insensitive (a=A - z=Z)?
> >
> > Yes
> > @sorted_list  = sort {uc($a) cmp uc($b)}  @unsorted ;
>
> Which proves that *you* know how to find things in the Perl
> documentation.  `perldoc -f sort`:
>
>     # now case-insensitively
>     @articles = sort {uc($a) cmp uc($b)} @files;
>
> However,  many of us believe that it is better to give away fishing rods
> than to give away fish.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com




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

Date: Tue, 31 Aug 1999 10:56:49 -0600
From: "Cory W. Aitchison" <caitchison@novell.com>
Subject: Java parser in perl
Message-Id: <37cc0952.0@news.provo.novell.com>

Does anyone know if there is a java parser written in perl somewhere?  I
could write one myself but would rather not.

Cory




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

Date: Wed, 1 Sep 1999 01:55:54 +0900
From: "W cube Desichnology" <wcube@thrunet.com>
Subject: Mail including HTML tag...
Message-Id: <bOrgSH98#GA.213@news.thrunet.com>

I want your help...
I wanna know how to mail with sendmail including HTML tag in perl.
May I need some special module?
Or, May I need header setting?

Please....Let me know about this...
Thank you!






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

Date: Tue, 31 Aug 1999 11:57:57 -0400
From: Robert Mangold <r.mangol@radium.ncsc.mil>
Subject: Re: newbie needs help
Message-Id: <37CBFB85.204D2D46@radium.ncsc.mil>

Try inserting this line after the line "$inputline2 = <STDIN>;" line:

chomp($inputline2);

This removes trailing CR-LF (carriage return/line feed) from the variable.  My
guess is you are comparing "quit" ?= "quit\n".

That's not your main problem, however.  You use "==" to compare numbers and "eq"
to compare strings.

Hope that helps

Wyzelli wrote:

> The DeLongs <tsaaedel@bright.net> wrote in message
> news:qNEx3.158$q_6.4055@cletus.bright.net...
> > Attention all knowledgeable Perl people sirs,
> >
> >     I am in need of assistance. I'm running Perl in Win32, specifically
> > Win98 (yeah, I actually got it to work). Problem is, whenever I run a Perl
> > program, the program closes before I can ever see the output. So, I
> decided
> > to make a little bit of code that would make the user type 'quit' before
> the
> > program exits. Here's the code:
> >
> > $inputline = <STDIN>;
> > print( $inputline );
> > print( "\n \n" );
> > print ( "Type quit to exit.\n" );
> > $inputline2 = <STDIN>;
> > $quitline = "quit";
> > until ( $inputline2 == $quitline) {
> > print ( "Please type quit to exit. \n" );
> > $inputline2 = <STDIN>;
> > }
> >
> >
> > Problem is, if the user types anything at the prompt, the program exits.
> > Please correct my foolish errors.
> >
> > Adel
>
> Try running from the command prompt with perl scriptname.pl
>
> What is happening is what is supposed to happen... the program runs and then
> closes.
>
> It is also possible to turn off the 'close on exit' property from the icon
> which runs the script if desired.
>
> Wyzelli





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

Date: 31 Aug 1999 13:09:23 -0400
From: plussier@baynetworks.com (Paul L. Lussier)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <h67k8qbnags.fsf@baynetworks.com>

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

> In article <h67ogfo29ty.fsf@baynetworks.com>,
> 	plussier@baynetworks.com (Paul L. Lussier) writes:
> > 
> > Hi all,
> > 
> > I'm trying sort a lists of ip addresses in a script
> 
> This happens to work, for various modes of 'work', useability is left
> to the reader.
> 
> use Socket;
> my @sorted_ips = sort { inet_aton($a) cmp inet_aton($b) } @ips;

Could you explain *why* this works?  I don't quite understand what 'use Socket'
does that would help with sorting?

Thanks,

-- 
Seeya,
Paul


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

Date: Tue, 31 Aug 1999 10:29:59 -0700
From: "Bill Tucker" <billtucker@lucent.com>
Subject: Perl On NT
Message-Id: <7qh38u$elo$1@news.eng.octel.com>

Question, does anyone know what needs to be done to have perl execute on a
NT 4.0 system running Netscape Enterprise 3.5? I have perl in the path but
obviously you can't use the same HTML syntax as you do within Unix (<form
method="post" action="/cgi-bin/send_wba.pl">) to have pl file execute.

All help would be appreciated.




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

Date: Tue, 31 Aug 1999 10:26:38 -0600
From: Paul Hill <phill@myriad.com>
Subject: Re: Perl Y2K Bugs on the Internet
Message-Id: <37CC023E.EF305F48@myriad.com>



The Glauber wrote:
> Quick and unimportant point: tm_year is the "year - 1900". As such, it
> has no Y2K issues: the year 2000 will show up as the number 100. In
> other words, you don't concatenate it with "19" to get the year, you
> take it as a number and add 1900.

The library call doesn't have Y2K issue, just any calling code that
uses the value in the incorrect way has the problem.

As the examples on the pages linked from the original post where
showing it is the _use_ that contains the y2K bug.  It doesn't matter 
if you or I are the next Albert Einstien or the document tells you
not to do it wrong thus I wouldn't do it either, there are plenty of
perl scripts and other programs that contain just such y2k problems.

As Lee Fesperman stated
>It is conducive to errors. *All* programmers make errors.

-Paul


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

Date: Tue, 31 Aug 1999 10:42:01 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Posting forms with Perl
Message-Id: <37CC13E9.17720836@cisco.com>

[ Joel Kimble wrote:

> powerful but I was wondering how I could submit a form to a web page.

You submit forms to server side scripts.

> The only thing I really need help with is how to submit a form on a web
> page.  I want to
> be able to automate the filling out of the "Username" and "Password"
> fields and the pressing of the submit button.

You will need to read the perldocs for LWP::Simple and LWP::UserAgent and
you
will be equipped to do this. There are some good examples in the 'Perl
CookBook'.

You will have to experiment if a similar approach to automation would work
for other submissions as some server side scripts tend to be smart enough
to
recognize non-browser originating form submissions and then return nothing
and
do nothing.  A couple of weeks ago there was an interesting posting in this

newsgroup which said that his submissions using LWP::**  to the amazon.com
site's book
search ( by ISBN ) form stopped working.
--



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

Date: Tue, 31 Aug 1999 13:27:59 -0400
From: "Ethan H. Poole" <ehpoole@ingress.com>
Subject: Re: Problem with <!--#exec cgi=/scripts/script.pl%22--> in IIS4
Message-Id: <37CC109F.D6301292@ingress.com>

McNally, Lisa wrote:
> 
> I am having a problem calling my perl script from an HTML document using the
> %22exec cgi%22 statement.  If I call the script directly by using
> http://server/scripts/script.pl? it works fine (the  counter increments and
> the digits are displayed).  However if I use the <!--exec
> cgi=%22/scripts/script.pl%22--> from within a HTML document nothing happens.
> I am running IIS 4 on an NT 4.0 SP 5 server.  The script ran fine before we
> upgraded the server from IIS 3.  Any ideas??  This one really has me
> baffled.

Why are you using %22? There should be normal quotes around
"/scripts/script.pl", using %22 is likely causing the quotes to be passed
as part of the URL.  If you are trying to use it as a hack for a directory
or filename with a space in it, change the directory or filename because
you are thoroughly asking for trouble.  You will also want to check to
make sure the mapping for .pl is for: .pl -> c:\perl5\bin\perl.exe "%s"
"%s" if there is even a slight chance that a filename with a space might
ever get passed to perl.  But placing quotes in the SSI line as %22
probably causes them to be passed to the application as quotes, not
interpreted locally.

It should look like:

 <!--#exec cgi="/scripts/scripts.pl"-->

If the other version worked in earlier versions, you just got lucky that
it handled errors differently.  Anytime you depend on an error handler to
correct your mistake, results are bound to vary from server to server,
release to release.

-- 
Ethan H. Poole           ****   BUSINESS   ****
ehpoole@ingress.com      ==Interact2Day, Inc.==
(personal)               http://www.interact2day.com/


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

Date: Tue, 31 Aug 1999 13:14:16 -0400
From: "Lisa McNally" <lisa_mcnally@mail.crc.com>
Subject: Re: Problem with <!--exec cgi="/scripts/script.pl"--> in IIS4
Message-Id: <7qh2he$r4g@hobbes.crc.com>

Actually, I had already verifyed that Server Side Includes were enabled in
my IIS configuration.  It turnes out that the problem was by default IIS
will only run SSI from .shtml, .shtm and .stm files.






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

Date: 31 Aug 1999 16:27:44 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: regex bug: (?:\d{3})+ loses count
Message-Id: <7qgvq0$3gu$1@pegasus.csx.cam.ac.uk>

Bart Lateur <bart.lateur@skynet.be> wrote:
>
>Apparently, my "latest" Perl versions are not so recent. I only upgraded
>a few months ago. Bloody upgraditis! 
>
>Both my DOS and Activestate perls are 5.00502. In the meantime, I've
>tried it on a few other systems as well, and the bug show up in 5.00502
>on Solaris as well.

perl5.005_02 was something of a special case.    perl5.005 was rushed
out so as to have new features available before The Perl Conference.
And so it had serious bugs, and remained a development release only.
And the same happened with 5.005_01.    5.005_02 was also buggy,
notably the RE bug you've found and various problems with the
optimisation of   foreach (1..1000000) {}.    But by a failure of
quality control, it escaped as a public release.    :-(

So you should think of 5.005_02 as a development release.   Anyone
running it should upgrade to 5.005_03 immediately.


Mike Guy


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

Date: Tue, 31 Aug 1999 16:50:57 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Request for Comments: www.perl.com
Message-Id: <pudge-3108991251000001@192.168.0.16>

In article <slrn7snoss.a54.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:

# Exactly how many servers are clients in such a company going to connect to?

Um, one?

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])


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

Date: Tue, 31 Aug 1999 12:24:06 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Sockets and Threads
Message-Id: <x3yaer7x6je.fsf@tigre.matrox.com>


"Alex R.M. Turner" <musicmaker@armt.yi.org> writes:

> Forking is all very well, but from what I've read, having each of the
> forked processes communicate with the parent, i.e. use the same variable
> set is a nightmare.  Is there an easy way to have child processes use
> variable sets from the parent?  If so, how does one do it.  Most of the

It depends. Do these variables change all the time or are they fixed?
Are children allowed to modify those variables?

If they are fixed, then just pass them once to each child when it is
created. If not, then a more complicated approach is needed.

One way would be to send the children the references to those
variables, and the children can look them up directly from memory. Of
course this has a potential concurrency problem where more than one
child (and possibly the parent) will attempt to read/write to the
variable. In that case you need to be using semaphores which slightly
complicates your design.

Or maybe each child would send a request to the parent, and then the
parent will handle those requests, giving each child its unique time
to access the variable. But this is essentially the same as using
semaphores.

No one said IPC was elegant :)

And, chapters 12 and 13 of the Panther might prove useful here.

> stuff I've seen looks pretty gruesome, and I would prefer something beta
> like threads with which I've worked in Java at least.

You can compile Perl to have thread support. It is still in beta
though, so beware.

> I also discovered the select() statement last night, which looks like it
> might help me build a sensible polling loop.

Sure thing. You can't do anything useful without select(). Let me
suggest that you look into using the IO::Select module (part of the
standard distribution). It's simply an OO interface to the select()
system call. This module made my life much easier several times. I
recommend using it.

HTH,
--Ala



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

Date: Tue, 31 Aug 1999 16:52:57 +0100
From: Y <yunus000@england.com>
Subject: Re: Using grep to match complete words
Message-Id: <37CBFA59.5180BCB5@england.com>

Larry James wrote:
> 
>      I have a grep script to check for the presents of a word in a list
> of words.  My problem is that if the current word is "hello" and the
> list has a word "hello2" because "hello2" has "hello" included, this
> will show up as found.
>      My script goes as:
> 
> ---------------
> for i in wordlist
> do
>     if [ ! "`grep $i uniquewords`" ]
>     then
>         echo adding $i...
>         echo $i >>uniquewords
>     fi
> done


Assuming that all words in file[uniquewords] are 
one per line with no spaces or tabs at the end of each
line ... you couldtry:

if [ ! `grep '^'$i'$' uniquewords` ]

There must be a simpler method though .....

Can anyone explain when you would use a double quote
and when a single one?

Thanks

-- 
-------------------------------------------------------------
"Don't be suckered in by the comments - debug only the code."
To reply by e-mail remove '000' from my address
-------------------------------------------------------------


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

Date: Tue, 31 Aug 1999 09:29:37 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Using grep to match complete words
Message-Id: <MPG.1235a2cc996d9979989eec@nntp.hpl.hp.com>

In article <7qgn0v$a15$1@hera.buffalointer.net> on 31 Aug 1999 13:57:51 
GMT, Larry James <ljames@apollo.apollo3.com> says...
>      I have a grep script to check for the presents of a word in a list
> of words.  My problem is that if the current word is "hello" and the
> list has a word "hello2" because "hello2" has "hello" included, this
> will show up as found.

Please drop comp.lang.perl.misc from the followups on this thread, which 
keeps proliferating.  Just because Perl has a built-in function called 
'grep' is no reason whatever to post in the Perl newsgroup.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 31 Aug 1999 12:36:21 -0400
From: Joe Kline <Joe.Kline@sdrc.com>
Subject: Re: Using grep to match complete words
Message-Id: <37CC0485.A72BF8E7@sdrc.com>

Larry James wrote:

>      I have a grep script to check for the presents of a word in a list
> of words.  My problem is that if the current word is "hello" and the
> list has a word "hello2" because "hello2" has "hello" included, this
> will show up as found.
>      My script goes as:
>
> ---------------
> for i in wordlist
> do
>     if [ ! "`grep $i uniquewords`" ]
>     then
>         echo adding $i...
>         echo $i >>uniquewords
>     fi
> done

Well, one way to do this in Perl...

my (@uniquewords) = grep(/\buniqewords\b/,@wordlist);

This will match "uniquewords" in @list, but being mindful of word
boundaries (that's what the \b's are doing. The other suggestions in this
thread could apply here as well.

To better under regular expressions in Perl look at:

perldoc perlre

joe

--



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

Date: Tue, 31 Aug 1999 16:51:26 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: using the exec command.
Message-Id: <iKTy3.8772$914.599904@typ11.nn.bcandid.com>

In article <37CBFC5D.67F9B4AE@nacs.net>, kenn  <kenn@nacs.net> wrote:
>exec 'echo "unsubscribe nacs-announce" | /usr/lib/sendmail -f
>  $user\@nacs.net majrdomo\@nacs.net\n';

>sh: @nacs.net: command not found

Shell commands cannot span multiple lines unless there is something at the
end of the first line to tell the shell that the command isn't done yet. The
shell is treating your two lines as two separate commands.

And if $user is a variable in your perl script, you will want to use ""
instead of '' to get it interpolated. Try it like this:

exec "echo unsubscribe nacs-announce | /usr/lib/sendmail -f"
    ." $user\@nacs.net majrdomo\@nacs.net";

I have there two strings, neither one of them containing a newline (a newline
on the end of the whole thing wouldn't hurt, but it's not needed), and the .
operator makes them into one string for exec to pass to the shell.
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


------------------------------
End of Perl-Users Digest V9 Issue 688
*************************************


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