[11842] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5442 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 21 16:07:29 1999

Date: Wed, 21 Apr 99 13:00:20 -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           Wed, 21 Apr 1999     Volume: 8 Number: 5442

Today's topics:
        "unterminated character constant"? (Neil Cherry)
    Re: Another bug in Perl? (Larry Rosler)
        combining multiple grep statements into one... (Jim Matzdorff)
        DB2 SDK required to use DBD::DB2? (C superior?) tzadikv@my-dejanews.com
    Re: elegant way of assembling array of arrays? (Andrew Johnson)
        Evaluating User Input (Chunsheng Ban)
    Re: Evaluating User Input <tripix@tdi-net.freeserve.co.uk>
    Re: for (my $i;;) doesn't work like I think it should raylutz@adaptra.com
    Re: for (my $i;;) doesn't work like I think it should raylutz@adaptra.com
    Re: for (my $i;;) doesn't work like I think it should raylutz@adaptra.com
    Re: for (my $i;;) doesn't work like I think it should (Bart Lateur)
    Re: Help! CGI::Cookie script works fine, but problem wh <cassell@mail.cor.epa.gov>
    Re: Help!! (Matthew Bafford)
        How to get rid of the tailing spaces? du_bing@my-dejanews.com
    Re: How to get rid of the tailing spaces? (Randal L. Schwartz)
    Re: How to get rid of the tailing spaces? <jtjuslin@wannabe.mit.edu>
    Re: How to get rid of the tailing spaces? (Larry Rosler)
        how to merge? bing-du@tamu.edu
    Re: Is it REALLY impossible to install Perl on Windoze? (Wayne Venables)
        NET::SMTP question. Rather urgent.!! kroner1645@my-dejanews.com
    Re: NET::SMTP question. Rather urgent.!! (yong huang)
        Personal Web Server and Perl <pumpkin@nowhere.com>
    Re: Please Help !!!!! <aqumsieh@matrox.com>
        SOCKET PROBLEM <jsinglet@jaguar.ir.miami.edu>
    Re: Sorting Hashes of Arrays.... (Larry Rosler)
    Re: This installation make me nut, please help! <jhi@alpha.hut.fi>
        Verifying text in a string jharmor@my-dejanews.com
    Re: Verifying text in a string <jtjuslin@cc.hut.fi>
    Re: Verifying text in a string (Larry Rosler)
    Re: Verifying text in a string (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 21 Apr 1999 19:35:38 GMT
From: njc@dmc.uucp (Neil Cherry)
Subject: "unterminated character constant"?
Message-Id: <slrn7hsa9l.s1k.njc@dmc.uucp>

I'm getting the following:

:13: unterminated character constant

I have only one 13 in an array reference (that doesn't make sense) and
I have no ^M's (unix). So what is this and how can I find this.

-- 
Linux Home Automation           Neil Cherry             ncherry@home.net
http://members.home.net/ncherry                         (Text only)
http://meltingpot.fortunecity.com/lightsey/52           (Graphics GB)
http://www2.cybercities.com/~linuxha/			( DOWN )


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

Date: Wed, 21 Apr 1999 11:42:41 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Another bug in Perl?
Message-Id: <MPG.1187bbf788f963f89898f9@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371d9ffd.16457397@news.iol.it> on Wed, 21 Apr 1999 13:30:18 
GMT, Andrea LN Spinelli <aspinelli@ismes.it> says...
 ...
> I experimented a little with Benchmark, (precious thing to know!)
> and the results are quite interesting...
 ... 
> split_global_table: 49 wallclock secs (48.88 usr +  0.00 sys = 48.88
> CPU)
 ...

Uri Guttman mentioned 'pack' a couple of days ago, but I think you 
didn't notice.  Add this to your test cases:

	'unpack' => sub { my $b = $a;
		my $c = uc unpack 'H*', $b;
	},

Here are my results:

Benchmark: timing 1024 iterations of split_global_table, unpack...
split_global_table: 56 wallclock secs (54.86 usr +  0.84 sys = 55.70 
CPU)
    unpack:  1 wallclock secs ( 0.84 usr +  0.00 sys =  0.84 CPU)

So all your fiddling with Perl code doesn't mean much compared to using 
a C-implemented Perl function to do the job.

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


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

Date: 21 Apr 1999 12:35:19 -0700
From: syran@best.com (Jim Matzdorff)
Subject: combining multiple grep statements into one...
Message-Id: <7fl99n$8u7$1@shell18.ba.best.com>

I am wondering if there's a neat perl trick to combine multiple perl
grep statements into one.  For instance, currently I have the following
lines:

my ($search) = qq /'1.$count'/;
my (@ret_lines) = grep /$search/, @lines;  
@ret_lines = grep /Search_Param/, @ret_lines;
if (@ret_lines && (my ($found) = grep /OK/, @ret_lines))
{
	print "Line is $found\n";
}

is there some way I can just do a:

if (my ($found) == grep /<$search,Search_Param,OK>/, @lines)
{
	print "Line is $found\n";
}

???  The strings I am searching on can be in any order in the strings.

Thnx,
--jim
-- 
--
One tequila, two tequila, three tequila, floor.


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

Date: Wed, 21 Apr 1999 18:51:56 GMT
From: tzadikv@my-dejanews.com
Subject: DB2 SDK required to use DBD::DB2? (C superior?)
Message-Id: <7fl6o2$j98$1@nnrp1.dejanews.com>

Is there any way I can distribute my Perl script that uses DBD::DB2 to
machines that do not have the DB2 SDK installed?

I know that the DB2 SDK is necessary to *build* DBD::DB2 but question why it
should be necessary for simply *running* a script that *uses* DBD::DB2.

One irritating aspect of this problem is that apparently a C program that
uses DB2 does not suffer from this problem.  You just "bind" the C program
with the DB2 database (on a machine that has the DB2 SDK) and then you can
distribute the compiled and "bound" C program to a machine that does *not*
have the SDK. Thus if this is true, programming DB2 apps in C has a distinct
advantage over programming them in Perl, which rubs me the wrong way.

One problem with this issue is how to copy a DBD::DB2 module from one machine
to the other (without building it on the second machine).  I tried doing such
a copy recently by simply using "tar" to package up the relavant directorys
in /usr/local/lib/perl5, but I could not run my script on the second machine.
 I would get:

Can't load '/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2.so' for
mo dule DBD::DB2: dlopen:
/usr/local/lib/perl5/site_perl/5.005/aix/auto/DBD/DB2/DB2 .so: A file or
directory in the path name does not exist. at /usr/local/lib/perl
5/5.00502/aix/DynaLoader.pm line 168.

(I posted about this problem at the time but got no response.  The "DB2.so"
file it claims does not exist actually does exist...the problem seems to be
something that is called from "DB2.so".  The only way I could come up with to
solve this problem was to install the DB2 SDK on the second machine and
rebuild DBD::DB2 there.)



--
Thanks,

Tzadik

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 18:00:56 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: elegant way of assembling array of arrays?
Message-Id: <snoT2.1336$Vp.36973@news1.rdc1.on.wave.home.com>

In article <371E0A8D.4127D82D@lucent.com>,
 Burton Kent <burton.not.spam@lucent.com> wrote:
! I have a list of strings, such as:
!   @stringlist = [ "one two three", "eleven twelve thirteen", "twentyone"];
! which I would like to convert to a list of lists such as:
!   @stringlistlist [ ["one", "two", "three"], ["eleven", "twelve", "thirteen"],
! ["twentyone"] ];
! 
! (Note that the use of numbers is arbitrary, has nothing 
! to do with the actual problem)
! 
! What's a good way to do this?  I'm trying to create something
! like the Schwartzian transform.

my @stringlist = ( "one two three", "eleven twelve thirteen", "twentyone");
my @stringLOL = map{[split]} @stringlist;
print $stringLOL[1][2];

regards
andrew


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

Date: Wed, 21 Apr 1999 15:28:34 -0400
From: ban.1@osu.edu (Chunsheng Ban)
Subject: Evaluating User Input
Message-Id: <ban.1-2104991528340001@mansb195.mansfield.ohio-state.edu>

I would like to write a program to accept user input that is
an arithmetic expression and the program evaluate it and print
out the result. Here is an example what I want though it does
not work.

------------- Example -------------

#!/usr/bin/perl

print "Enter an expression to evaluate: ";
my $userinput;
chop($userinput = <STDIN>);
print "The result is ",$userinput,".\n";

------------ End -----------------

If a user enters 2+3, I want the program to output 5 instead of
2+3.

I am new to programming. I would appreciate any help. Please send
reply to cban@math.ohio-state.edu.

Thanks.


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

Date: Wed, 21 Apr 1999 20:36:06 +0100
From: "Wayne Keenan" <tripix@tdi-net.freeserve.co.uk>
Subject: Re: Evaluating User Input
Message-Id: <7fl9pc$1vq$1@news8.svr.pol.co.uk>

Chunsheng Ban wrote in message ...
>I would like to write a program to accept user input that is
>an arithmetic expression and the program evaluate it and print
>out the result. Here is an example what I want though it does
>not work.
>
>------------- Example -------------
>
>#!/usr/bin/perl
>
>print "Enter an expression to evaluate: ";
>my $userinput;
>chop($userinput = <STDIN>);
>print "The result is ",$userinput,".\n";
>
>------------ End -----------------
>
>If a user enters 2+3, I want the program to output 5 instead of
>2+3.
>
>I am new to programming. I would appreciate any help. Please send
>reply to cban@math.ohio-state.edu.
>
>Thanks.

change  the last line to:
print "The result is ", eval $userinput ,".\n";







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

Date: Wed, 21 Apr 1999 18:34:04 GMT
From: raylutz@adaptra.com
Subject: Re: for (my $i;;) doesn't work like I think it should
Message-Id: <7fl5ml$i4k$1@nnrp1.dejanews.com>

In article <7fi2qd$6aa$1@pegasus.csx.cam.ac.uk>,
  mjtg@cus.cam.ac.uk (M.J.T. Guy) wrote:
> >The only difference between pass one and two is the 'my' in the for().
> >According to the perl docs I've read, these SHOULD do the same thing.
>
> Only in versions 5.004 and later of Perl.
>
> And I also note you aren't using -w  -  that code gives a warning
> (which in the example is harmless).

I always use -w, and my interpreter doesn't produce any warnings...
Otherwise, I wouldn't have spent so much time finding this silly bug.
-Raymond Lutz

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 18:31:07 GMT
From: raylutz@adaptra.com
Subject: Re: for (my $i;;) doesn't work like I think it should
Message-Id: <7fl5h4$i2b$1@nnrp1.dejanews.com>

I checked the version.. it is 5.001. I'm using a port of perl to DOS so I can
code on a laptop that I have, typically shrinking the turn-around time. It
could be that the port is not perfect in this regard. Oh well, I don't mind
putting the 'my' on the outside of the loop, but it loses some of it's
conciseness. Thanks for your help. -Raymond

In article <1dqjbf5.14rhts96le1juN@[207.60.170.94]>,
  rjk@linguist.dartmouth.edu (Ronald J Kimball) wrote:
> <raylutz@adaptra.com> wrote:
>
> > The only difference between pass one and two is the 'my' in the for().
> > According to the perl docs I've read, these SHOULD do the same thing.
>
> Works for me with perl5.004_04.  What version of perl are you using?
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 18:37:12 GMT
From: raylutz@adaptra.com
Subject: Re: for (my $i;;) doesn't work like I think it should
Message-Id: <7fl5sg$i92$1@nnrp1.dejanews.com>

In article <371deab3.1054120@news.skynet.be>,  bart.lateur@skynet.be (Bart
Lateur) wrote: PERFECT! Just what I needed to see... Plus I now know where to
look for similar issues... Again, the version is 5.001 that I have as a port
on my PC laptop. Is it prudent to avoid using my in control structures for
this reason ( to avoid incompatibilities) if the code is to be used in many
situations?? -RCL

> The syntax
>
> 	for(my $i; ...; ...) {  .... }
>
> did NOT come with the first version of Perl 5. I'm not sure exactly when
> it was introduced, but my guess it must have been around 5.004.
>
> NAME
>     perldelta - what's new for perl5.004
>
>     my() in Control Structures
>         You can now use my() (with or without the parentheses) in
>         the control expressions of control structures such as:
>
>             while (defined(my $line = <>)) {
>                 $line = lc $line;
>             } continue {
>                 print $line;
>             }
>
>         Also, you can declare a foreach loop control variable as
>         lexical by preceding it with the word "my". For example, in:
>
>             foreach my $i (1, 2, 3) {
>                 some_function();
>             }
>
> 	Bart.
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 19:10:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: for (my $i;;) doesn't work like I think it should
Message-Id: <372121c8.1260968@news.skynet.be>

raylutz@adaptra.com wrote:

>I checked the version.. it is 5.001. I'm using a port of perl to DOS so I can
>code on a laptop that I have, typically shrinking the turn-around time. It
>could be that the port is not perfect in this regard. Oh well, I don't mind
>putting the 'my' on the outside of the loop, but it loses some of it's
>conciseness.

Time to upgrade. The DJGPP DOS port is at least at level 5.004. 5.005 is
in the making, if it's not available yet. (BTW is 5.005 Ready For The
World (TM) yet?)

For all I've heard, 5.001 must be about the worst Perl 5 implementation
you can possibly have.

	Bart.


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

Date: Wed, 21 Apr 1999 11:17:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help! CGI::Cookie script works fine, but problem when using SSI's
Message-Id: <371E1646.17A34275@mail.cor.epa.gov>

Jack Schlotthauer wrote:
> 
> Why not <!--#exec cgi="/cgi-bin/test.cgi" -->
> 
> [major snip]

Could work.  But I was taking issue with the poster's arbitrary
decision that *Perl* was to blame, rather than all the other
components of his system.. like his server installation, or 
[possibly, in this case] his own CGI code.

Glad that at least one of us was paying attention,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Wed, 21 Apr 1999 18:06:28 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Help!!
Message-Id: <slrn7hs18e.rv.dragons@dragons.duesouth.net>

On Wed, 21 Apr 1999 10:40:08 -0500, Do, Bruce (EXCHANGE:RICH4:T221) <brucedo@americasm01.nt.com>
lucked upon a computer, and thus typed in the following:
: I am generating data files with 4 million entries but i want to write
: out to a file at intervals of 20000. Right now the script will generate
: one file with 4 million entries. Try reading a file of that size. Not
: pleasant. So i want to generate 200 files with 20,000 entries. Any
: suggestions greatly appreciated.

I'm afraid you're not to clear on what your problem is.

Why not just:

0) set file number to 0

1) open the file "file_$filenum"

2) write until 20k records have been written

3) close the file

4) increment file number

5) go back to step 1

: thanks in advance,

HTH,

: Bruce.

--Matthew


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

Date: Wed, 21 Apr 1999 18:44:48 GMT
From: du_bing@my-dejanews.com
Subject: How to get rid of the tailing spaces?
Message-Id: <7fl6ao$io1$1@nnrp1.dejanews.com>

Hello there,

$test="hello    ";

What's the best way to get rid of those extra spaces in the string $test to
make it like "hello".

Thanks in advance for any idea and suggestion,

Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Apr 1999 12:17:20 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: How to get rid of the tailing spaces?
Message-Id: <m17lr5dbr3.fsf@halfdome.holdit.com>

>>>>> "du" == du bing <du_bing@my-dejanews.com> writes:

du> Hello there,
du> $test="hello    ";

du> What's the best way to get rid of those extra spaces in the string $test to
du> make it like "hello".

<text mode=Abigail>
Just do this:

    $test = "hello";

</text>

:)

The real answer is *read the FAQ*.

perldoc -q space =>

    =head1 Found in /usr/lib/perl5/5.00502/pod/perlfaq4.pod

    =head2 How do I strip blank space from the beginning/end of a string?

    [snipped]

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Wed, 21 Apr 1999 22:20:22 +0300
From: Jukka Juslin <jtjuslin@wannabe.mit.edu>
Subject: Re: How to get rid of the tailing spaces?
Message-Id: <371E24F6.8BB33441@wannabe.mit.edu>

du_bing@my-dejanews.com wrote:
> 
> Hello there,
> 
> $test="hello    ";
> 
> What's the best way to get rid of those extra spaces in the string $test to
> make it like "hello".

Probably like this:

#!/usr/bin/perl

$name = "jukka    ";
$name =~ s/\s.*//;
print ($name); 
 
> Thanks in advance for any idea and suggestion,

Again - if you cannot figure this out by yourself you maybe shouldn't do
programming at all.

++Jukka Juslin


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

Date: Wed, 21 Apr 1999 12:50:59 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to get rid of the tailing spaces?
Message-Id: <MPG.1187cbfc281036319898fc@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371E24F6.8BB33441@wannabe.mit.edu> on Wed, 21 Apr 1999 
22:20:22 +0300, Jukka Juslin <jtjuslin@wannabe.mit.edu> says...
> du_bing@my-dejanews.com wrote:
> > $test="hello    ";
> > 
> > What's the best way to get rid of those extra spaces in the string $test to
> > make it like "hello".
> 
> Probably like this:

Probably not.

> #!/usr/bin/perl
> 
> $name = "jukka    ";
> $name =~ s/\s.*//;
> print ($name); 

That converts 'jukka juslin   ' to 'jukka'.  Hardly what was requested.
 
> > Thanks in advance for any idea and suggestion,
> 
> Again - if you cannot figure this out by yourself you maybe shouldn't do
> programming at all.

This is the second of your posts (one from Finland and one from MIT???) 
involving the same regex error ('.*' instead of '*' or better '+').  A 
little more testing and a little more diffidence might be in order for a 
wannabe. 

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


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

Date: Wed, 21 Apr 1999 19:39:07 GMT
From: bing-du@tamu.edu
Subject: how to merge?
Message-Id: <7fl9gq$lt6$1@nnrp1.dejanews.com>

Hello,

I know how to use 'split' to cut a string.  How to merge all the elements (but
seperated by space) of a list?

Thanks,
Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 18:32:07 GMT
From: wvenable_net@iname.com (Wayne Venables)
Subject: Re: Is it REALLY impossible to install Perl on Windoze???
Message-Id: <371e1956.315097@news.sprint.ca>

On 20 Apr 1999 20:41:00 -0000, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

>> The ActiveState installation program freezes always
>> when "preparing HTML documentation", at 95%, leaving
>> the installation unfinished (I believe that 60 min
>> waiting for the program to continue - was enough...).
>> 
>
>I might be inclined to leave it for a while longer given the
>lesser of your platforms.  That stage took 20 minutes on my
>work machine - a 350Mhz PII with 64MB - it has a lot of work
>to do building several hundred HTML pages and hey this Windows
>not Linux (where I can build the whole damn thing in ten minutes
>from the source ).

  It took around a minute to build the HTML documentation on my K6 233
with 32MB RAM.  I've even installed it twice so far, same results each
time.

Later,



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

Date: Wed, 21 Apr 1999 17:47:21 GMT
From: kroner1645@my-dejanews.com
Subject: NET::SMTP question. Rather urgent.!!
Message-Id: <7fl2v7$fb3$1@nnrp1.dejanews.com>

Hi anyone,

I need to get the NET::SMTP modules for installation on a WinNT machine. I am
familiar how sendmail works in UNIX but this is a new task for me. The
problem is - if I download the lib files from cpan, how are they to be
installed on the NT machine? i tried perl Makefile.PL and get errors(are they
different files for NT or is it platform independent?). I figured you could
simply place the smtp.PM and cmd.PM files, etc in the perl/lib/net directory,
but the script won't work. HELLLP. I have to send a simple email from a
script each time it is executed and I am no longer using an HP unix box.

thanks to all who are in the watchful helpful arena here...
Aaron

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 10:08:43 -0800
From: yong321@yahoo.com (yong huang)
Subject: Re: NET::SMTP question. Rather urgent.!!
Message-Id: <WxoT2.6934$_c.2464544@WReNphoon3>

This is FAQ but unfortunately Active State didn't do a good job explaining
this clearly or at all. I assume you use ActivePerl. At the command line,
simply type

ppm libnet install
or is it: ppm install libnet

I as well as others asked the same question a few weeks ago.

When you run this command, the perl package manager takes care of everything
including the location to put the module. Obviously you have to be connected
to the Internet before you issue the command.

Yong



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Wed, 21 Apr 1999 11:18:06 -0700
From: "Mr. Pumpkin" <pumpkin@nowhere.com>
Subject: Personal Web Server and Perl
Message-Id: <oJoT2.24412$134.264359@tor-nn1.netcom.ca>

I have installed MS PWS on my computer and Perl 5 as well.  The associations
for both .cgi and .pl work fine (start perl when I double click).  The web
server is working fine, but when it attempts to run the cgi through a
browser, it just say web contacted, waiting for for reply and hangs until it
eventually gives up.  Any ideas? better web server?

Thanks,
Forest




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

Date: Wed, 21 Apr 1999 14:18:15 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Please Help !!!!!
Message-Id: <x3yemldyh08.fsf@tigre.matrox.com>


Jasjit Singh <jasjit@teleport.com> writes:

> $email = "someone@somewhere.someplace";

Did you test this?



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

Date: Wed, 21 Apr 1999 13:45:14 -0400
From: John L Singleton <jsinglet@jaguar.ir.miami.edu>
Subject: SOCKET PROBLEM
Message-Id: <Pine.OSF.4.05.9904211341160.8379-100000@jaguar.ir.miami.edu>

i have written a progeram that fingers a user. the only problem is that i
cannot make the program do this on a NON remote level- if i try to change
the server.. it still does a local finger...
can you take a look at the code and prehaps give me a hand??

thankyou.

use Socket;
use strict;


my($mailServer) = 'mail.server.com'; #for the example


my($proto)      = getprotobyname("tcp")        || 6;
my($port)       = 79;
my($serverAdd) = (gethostbyname($mailServer));



socket(FINGER, AF_INET(), SOCK_STREAM(), $proto)
    or die("socket: $!");

#$packFormat = 'S n a4 x8';   # Windows 95, SunOs 4.1+
my($packFormat)= 'S n c4 x8';   # SunOs 5.4+ (Solaris 2)


printf("I am COnnecting john\n\n\n");
connect(FINGER, pack($packFormat,AF_INET(), $port, $serverAdd ))
    or die("connect: $!");
printf("connected\n\n\n");



my($inpBuf) = '';



send(FINGER,  "-i ",0);
send(FINGER,  "jsinglet\r\n'",0 );
recv(FINGER, $inpBuf, 200, 0);
close(FINGER);
printf("closed socket!\n\n");
print("$inpBuf\n\n");



*-------------------------*--------------------------------------------*
* John Lawrence Singleton *                singleto@ocala.cs.miami.edu *
*  Computer Engineering   *               jsinglet@coeds.eng.miami.edu *
*   University of Miami   *               jsinglet@jaguar.ir.miami.edu *
*    (305)-689-9850       *                      johnsingleton@usa.net *
*-------------------------*--------------------------------------------*





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

Date: Wed, 21 Apr 1999 11:10:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting Hashes of Arrays....
Message-Id: <MPG.1187b45e892a03019898f8@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371D8C0A.E4011339@Baratta.com> on Wed, 21 Apr 1999 01:27:54 
-0700, Anthony Baratta <Anthony@Baratta.com> says...
 ...
+ The examples are basically what's in the Camel Book...Chapter 4. e.g.
+ 
+ 	# print the whole thing sorted by number of members and name
+ 1	foreach $family ( sort { @{$HoL{$b}} <=> @{$HoL{$a}} } keys %HoL ) 
{
+ 2		print "$family: ", join(",", sort @{ $HoL{$family} }), "\n";
+ 3	}
+ 
+ I understand how line 2 works. Sorting the 'list' contained withing
+ $HoL{$family} 'horizontally' just before print out. But I don't
+ understand Line 1 - What compare is this doing here... @{$HoL{$b}} <=>
+ @{$HoL{$a}} ??

The comment tells you.  The value of an array in scalar context is the 
number of elements in the array.  So this sorts the arrays according to 
the number of elements in each, most to least.

 ...
+ And what if I had a Hash of Array like this.....
+ 
+ %HoL = (
+ StoreID1 => [ "A Store Name", "A Street Address", "A City", "A State",
+ "A Zip" ],
+ StoreID2 => [ "C Store Name", "C Street Address", "C City", "C State",
+ "C Zip" ],
+ StoreID3 => [ "B Store Name", "B Street Address", "B City", "B State",
+ "B Zip" ],
+ StoreID4 => [ "D Store Name", "D Street Address", "A City", "A State",
+ "A Zip" ],
+ 	);
+ 
+ How would I sort on City then Store Name between StoreIDs (vertically)
+ and print out the info that order? So my print out looks like this....
+ 
+ 	"A Store Name", "A Street Address", "A City", "A State", "A Zip"
+ 	"D Store Name", "D Street Address", "A City", "A State", "A Zip"
+ 	"B Store Name", "B Street Address", "B City", "B State", "B Zip"
+ 	"C Store Name", "C Street Address", "C City", "C State", "C Zip"

perlfaq4:  "How do I sort an array by (anything)?"

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


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

Date: 21 Apr 1999 21:08:42 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: This installation make me nut, please help!
Message-Id: <oeepv4xdexh.fsf@alpha.hut.fi>


kamez@my-dejanews.com writes:

> I'm experiencing the same problem , trying to install PERL5 on BSDI 3.1 ,
> and i can't even get a "make" , cause i get the following error :
> ------------------------------------------------------------------
> `sh  cflags libperl.a doio.o`  doio.c
>           CCCMD =  cc -DPERL_CORE -c -fpcc-struct-return -O
> doio.c: In function Perl_do_ipcctl:
> doio.c:1381: argument #4: incompatible types in argument passing
> doio.c:1432: argument #4: incompatible types in argument passing
> *** Error code 1
> 
> Stop.
> -----------------------------------------------------------------
> If you have any clue, i'll appreciate it,
> Thanks a lot for your help.
> Khalid.

Which of the several dozen releases that could be called 'PERL5'
are you running?  Please always report the exact release.
In general, when hitting a problem while building Perl please
study INSTALL carefully.

For your particular problem I can, however, guess that using
a more modern 'perl 5' would help.  In general, using the latest
maintenance release helps.

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


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

Date: Wed, 21 Apr 1999 17:45:49 GMT
From: jharmor@my-dejanews.com
Subject: Verifying text in a string
Message-Id: <7fl2sc$f9u$1@nnrp1.dejanews.com>

I am looking for an easy way to verify that the chars, in a three char string
are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
(@.*&).
The string was created by user input and I am trying to strip out non text
chars.

Thanks
Jay

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 21 Apr 1999 21:58:59 +0300
From: Jukka Juslin <jtjuslin@cc.hut.fi>
Subject: Re: Verifying text in a string
Message-Id: <371E1FF3.7D2A13D0@wannabe.mit.edu>

jharmor@my-dejanews.com wrote:
> 
> I am looking for an easy way to verify that the chars, in a three char string
> are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
> (@.*&).
> The string was created by user input and I am trying to strip out non text
> chars.

The answer is quite obviously \W switch, for example:
$name =~ s/\W.*//;

The \W searches for nonword characters, actually. You have to strip off
_ after that because it matches that also.

Anyway you should work harder by yourself - do not ask things like this
in news. You wont get nothing usefull done if you can't read the man
pages.

++Jukka Juslin


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

Date: Wed, 21 Apr 1999 12:11:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Verifying text in a string
Message-Id: <MPG.1187c2bb9ea3049a9898fa@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7fl2sc$f9u$1@nnrp1.dejanews.com> on Wed, 21 Apr 1999 
17:45:49 GMT, jharmor@my-dejanews.com <jharmor@my-dejanews.com> says...
> I am looking for an easy way to verify that the chars, in a three char string
> are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
> (@.*&).
> The string was created by user input and I am trying to strip out non text
> chars.

  $string =~ tr/A-Za-z0-9//c;

tells you how many characters are not in the specified ranges.  Add a 
'd' suffix to delete them.

Look for the 'tr' (translate) operator in perlop.

Ignore anyone who shows a regex solution (though I doubt they'll dare to 
now :-).  It will be an order of magnitude slower.

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


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

Date: Wed, 21 Apr 1999 12:43:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Verifying text in a string
Message-Id: <MPG.1187ca3e97eecfc39898fb@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371E1FF3.7D2A13D0@wannabe.mit.edu> on Wed, 21 Apr 1999 
21:58:59 +0300, Jukka Juslin <jtjuslin@cc.hut.fi> says...
> jharmor@my-dejanews.com wrote:
> > I am looking for an easy way to verify that the chars, in a three char string
> > are only in the sets [A-Z] or [a-z] or [0-9] and contain no other chars i.e.
> > (@.*&).
> > The string was created by user input and I am trying to strip out non text
> > chars.
> 
> The answer is quite obviously \W switch, for example:
> $name =~ s/\W.*//;

\W is a subpattern that matches a single character.  I don't know what 
you mean by '\W switch'.

Your regex strips out the matching character *and all subsequent 
characters* (except newline stops it).  That is not what was requested.

> The \W searches for nonword characters, actually. You have to strip off
> _ after that because it matches that also.

Then why not refer to the 'nonword character' as [^\w_]?

So we have

  $name =~ s/[^\w_]//g;

And this is not what was requested anyhow, because the user specified 
the 52 ASCII letters, but perlre says this:  "If use locale is in 
effect, the list of alphabetic characters generated by \w is taken from 
the current locale. See perllocale."

So we end up with

  $name =~ s/[^A-Za-z0-9]//g;

And we should forget all about it now, and use 'tr' instead.  (But your 
post was recorded here 13 minutes ahead of mine that said this.  :-)
 
> Anyway you should work harder by yourself - do not ask things like this
> in news. You wont get nothing usefull done if you can't read the man
> pages.

Well, yes.  But which man pages?  In this case, perlre loses out to 
perlop. 

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


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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