[15655] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3068 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 16 18:21:00 2000

Date: Tue, 16 May 2000 15:20:30 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958515630-v9-i3068@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 16 May 2000     Volume: 9 Number: 3068

Today's topics:
        Servers and sockets and strings, oh my hawaii_jen@my-deja.com
    Re: Servers and sockets and strings, oh my <jhelman@wsb.com>
    Re: Servers and sockets and strings, oh my <aqumsieh@hyperchip.com>
    Re: sorry repost i need help despertly can someone just <thepoet1@arcormail.de>
        time spent to run a perl script <jmourneyNOjmSPAM@hotmail.com.invalid>
    Re: time spent to run a perl script (Randal L. Schwartz)
        tracking the memory <sumengen@hotelspectra.com>
        Using Getopt::Std 0 == 1?? gregsptl1962@my-deja.com
    Re: Using Getopt::Std 0 == 1?? (brian d foy)
        Using OCX object <dduchinNOddSPAM@connect.net.invalid>
        Using user-variables in external commands? II <nobody@noisebox.dhs.org>
        Variables in Pattern sarbx@my-deja.com
    Re: Variables in Pattern (Neil Kandalgaonkar)
    Re: xs: getting a char* into my Perl script (Ilya Zakharevich)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 16 May 2000 21:25:29 GMT
From: hawaii_jen@my-deja.com
Subject: Servers and sockets and strings, oh my
Message-Id: <8fsebm$41b$1@nnrp1.deja.com>

I've been slamming my head against the same brick wall all afternoon,
so I thought I'd ask for help.

I am attempting to write a TCP server in Perl.  This server will listen
on a port and accept incoming communications.  The first line of the
incoming request is read, some decisions are made, and then the rest of
the request is read in.  I need to get the entire rest of the request
into one scalar character string, so I was doing this:

$clientRequest = "";

while (<CLIENT>) {

   $clientRequest .= $_;

}

Obviously there is also an ending condition (it checks $_ against a
preset "end of file" value).

This, when run, produced some extremely mangled strings.  When I tried
to print out $clientRequest doing something like this:

print "clientRequest is $clientRequest\n";

I would end up with something like
clientTextest is lastlinesentbyclient

What am I missing?  Please tell me it's something obvious and make me
feel stupid - at this point, that's the best thing I could hope for.

Thanks,
Jen


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 16 May 2000 21:49:41 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Servers and sockets and strings, oh my
Message-Id: <3921C294.A409FDB6@wsb.com>

It would help to see all of the code in the while block.  It looks as if
something in there is overwriting your return value.  Please post the
whole block.

JH
----------------------------------------------------------------
Jeff Helman                 Product Manager -- Internet Services
jhelman@wsb.com                    CCH Washington Service Bureau
----------------------------------------------------------------

hawaii_jen@my-deja.com wrote:
> 
> I've been slamming my head against the same brick wall all afternoon,
> so I thought I'd ask for help.
> 
> I am attempting to write a TCP server in Perl.  This server will listen
> on a port and accept incoming communications.  The first line of the
> incoming request is read, some decisions are made, and then the rest of
> the request is read in.  I need to get the entire rest of the request
> into one scalar character string, so I was doing this:
> 
> $clientRequest = "";
> 
> while (<CLIENT>) {
> 
>    $clientRequest .= $_;
> 
> }
> 
> Obviously there is also an ending condition (it checks $_ against a
> preset "end of file" value).
> 
> This, when run, produced some extremely mangled strings.  When I tried
> to print out $clientRequest doing something like this:
> 
> print "clientRequest is $clientRequest\n";
> 
> I would end up with something like
> clientTextest is lastlinesentbyclient
> 
> What am I missing?  Please tell me it's something obvious and make me
> feel stupid - at this point, that's the best thing I could hope for.
> 
> Thanks,
> Jen
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


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

Date: Tue, 16 May 2000 22:04:36 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Servers and sockets and strings, oh my
Message-Id: <7a4s7yduew.fsf@Merlin.i-did-not-set--mail-host-address--so-shoot-me>


hawaii_jen@my-deja.com writes:

> I am attempting to write a TCP server in Perl.  This server will listen
> on a port and accept incoming communications.  The first line of the
> incoming request is read, some decisions are made, and then the rest of
> the request is read in.  I need to get the entire rest of the request
> into one scalar character string, so I was doing this:
> 
> $clientRequest = "";
> 
> while (<CLIENT>) {
> 
>    $clientRequest .= $_;
> 
> }
> 
> Obviously there is also an ending condition (it checks $_ against a
> preset "end of file" value).
> 
> This, when run, produced some extremely mangled strings.  When I tried
> to print out $clientRequest doing something like this:
> 
> print "clientRequest is $clientRequest\n";
> 
> I would end up with something like
> clientTextest is lastlinesentbyclient
> 
> What am I missing?  Please tell me it's something obvious and make me
> feel stupid - at this point, that's the best thing I could hope for.

I can't say for sure, but I think that you're having \r's appended at
the end of your input lines. Try this:

	while (<CLIENT>) {
		tr/\r//d;
		$clientRequest .= $_;
	}

Let us know whether this solves it for you or not.

--Ala


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

Date: Tue, 16 May 2000 21:02:10 +0200
From: Christian Winter <thepoet1@arcormail.de>
Subject: Re: sorry repost i need help despertly can someone just look what is wrong
Message-Id: <iv5sf8.df3.ln@usenet-autoren.de>

Tad McClellan <tadmc@metronet.com> schrob:
>    $from   = '"vinny"<vinny@perlguru.com>';
                     ^^^
There should be a space (even if it works):
$from = '"vinny" <vinny@perlguru.com>';

if I got rfc822 right.

Regards
Christian


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

Date: Tue, 16 May 2000 12:06:32 -0700
From: Perl Discussion <jmourneyNOjmSPAM@hotmail.com.invalid>
Subject: time spent to run a perl script
Message-Id: <009e8de0.2d638022@usw-ex0102-084.remarq.com>

i'm trying to find out how much time is needed for my perl script
to finish running.

is there a way to do this? the machine i work on do not
provide syscall.ph; so i can't do as the docs says.
i tried localtime() (subtract with new time value, etc),
but i'm having problem with it, too.

any help would be appreciated.

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: 16 May 2000 14:00:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: time spent to run a perl script
Message-Id: <m1hfbyi52e.fsf@halfdome.holdit.com>

>>>>> "Perl" == Perl Discussion <jmourneyNOjmSPAM@hotmail.com.invalid> writes:

Perl> i'm trying to find out how much time is needed for my perl script
Perl> to finish running.

Hmm, that seems to be equivalent to the "halting problem", which I
believe has been proven to be impossible to solve.

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 16 May 2000 13:45:19 -0700
From: "Baris" <sumengen@hotelspectra.com>
Subject: tracking the memory
Message-Id: <3921b2b4$1_1@goliath2.newsfeeds.com>

Hello,
I am having memory leaks in my program. It is basically a while loop, which
processes all the elements in a database one by one.
I am initialize all arrays and hashes in the beginning of the while loop,
and I am undefining all of them at the end of the loop. (I am using strict
pragma too.)

I want to use a tool which can tell me which data structure is using how
much memory. I need to be ablle to track this while running the program.

I am also suspicious about the modules i am using and wondering if they have
any memory leaks or not. i am using: DBI, DBD::mysql, LWP::Simple,
LWP::UserAgent, Image::Size, HTML::Parser.
(I wonder if there are problems of perl clearing the memory right away???).
I am defining module variables using my inside the while loop. I assume at
each loop the old module variables are cleared and new one is created..
Thanks,
Baris.




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Tue, 16 May 2000 19:05:46 GMT
From: gregsptl1962@my-deja.com
Subject: Using Getopt::Std 0 == 1??
Message-Id: <8fs65t$qab$1@nnrp1.deja.com>

Using the following code snippet and running as ./xx.pl -c 0
the output equals 1
The same if ./xx.pl -c 1
the output equals 1 All other numbers/letters are OK except 0
#!/usr/bin/perl
#!/usr/bin/perl -dw

use Getopt::Std;
getopts ('c:');  # set -c to the skip count

$Getopt::Std::opt_c = '1' unless $Getopt::Std::opt_c;
         # Set count by default to 1

print "$Getopt::Std::opt_c\n"; # Debug Why's -c 0 == 1???


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 16 May 2000 15:38:47 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Using Getopt::Std 0 == 1??
Message-Id: <brian-1605001538470001@rtp-cr45-dhcp-100.cisco.com>

In article <8fs65t$qab$1@nnrp1.deja.com>, gregsptl1962@my-deja.com wrote:

>the output equals 1 All other numbers/letters are OK except 0
>#!/usr/bin/perl

>$Getopt::Std::opt_c = '1' unless $Getopt::Std::opt_c;
>         # Set count by default to 1

if $Getopt::Std::opt_c holds the value 0, then what does this
one line do?  what is it supposed to do if $Getopt::Std::opt_c
is 0?

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Tue, 16 May 2000 14:06:43 -0700
From: MagicDRD <dduchinNOddSPAM@connect.net.invalid>
Subject: Using OCX object
Message-Id: <1c31d620.54d82292@usw-ex0109-070.remarq.com>

I am trying to write a Perl script that will use
functions/methods in an existing OCX object.

Is there a special module to use that will allow me to use
the OCX object or is there some method for creating my
own .pm file that references the OCX???

Thanks for your posts.
David


* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is Beautiful


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

Date: Tue, 16 May 2000 14:38:13 -0600
From: Anonymous <nobody@noisebox.dhs.org>
Subject: Using user-variables in external commands? II
Message-Id: <af04dba299384001bf265dbafbcea30c@noisebox.dhs.org>

Thank you for your answers!

The question is not if $recipient and
$body can contain any character in:

 ...
To: $recipient
  
$body
end
 ...

The question is can contain $body any
character?
Im already checking $recipient for
 .+@.+..+ and before parsing out everything
except w,d . - and @.
For example if you send an empty line
containing only a dot sendmail quits and
maybe there ore some other similar things.

So is it safe to allow any character in
$body and only check $recipient?

Thank you, Mike!


 .


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

Date: Tue, 16 May 2000 21:36:26 GMT
From: sarbx@my-deja.com
Subject: Variables in Pattern
Message-Id: <8fsf0o$4mk$1@nnrp1.deja.com>

Can a variable be used in a pattern like,

$pattern  = "pattern"
$str = "The whole string containing pattern"

if ( $str =~ /$pattern/) {
}

I know it doesnt work directly like this. How would you do something
like this.

Thanks,
-Sarva


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 May 2000 21:58:19 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: Variables in Pattern
Message-Id: <8fsg9r$9ll$1@newsflash.concordia.ca>

In article <8fsf0o$4mk$1@nnrp1.deja.com>,  <sarbx@my-deja.com> wrote:
>Can a variable be used in a pattern like,
>
>$pattern  = "pattern"
>$str = "The whole string containing pattern"
>
>if ( $str =~ /$pattern/) {
>}
>
>I know it doesnt work directly like this. 

It does.

>How would you do something
>like this.

Like you did it.

If $pattern might contain regex metacharacters, like ".", and you
don't actually want metacharacter behaviour, use \Q:

$pattern = "The horror... the horror...";

if ($dialogue =~ /\Q$pattern/) {
   print "Apocalypse Now\n";
}

-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: 16 May 2000 19:08:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: xs: getting a char* into my Perl script
Message-Id: <8fs6c3$4bl$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Ulrich Ackermann 
<uackermann@orga.com>],
who wrote in article <39211B3B.FC316D7B@orga.com>:
> Hi;
> I am trying get a string out of an C-function (e.g. get_name) which is
> defined in a C library. The C-function returns an char*. 
> After reading the perlxstut example 4 and the code of a friend, who did
> nearly the same thing carefully I am still getting rubbisch into my
> script.
> The important part of my .xs-file looks like this:
> 
>      40 char *
>      41 get_name()
>      42 PPCODE:
>      43     int len;
>      44     char *name;
>      45     name=(char*)malloc(sizeof(char[30]));
>      46     name=  get_name();
>      47     len = strlen(name); 
>      48     printf ("xs: %s: %d \n", name,len);
>      49     EXTEND(sp,2);
>      50     PUSHs(sv_2mortal(newSViv(1)));
>      51     PUSHs(sv_2mortal(newSVpv(name, len)));

Just use

  char *
  get_name()

That's all.  If you actually need to put 1 in front, make a Perl wrapper.

But here are several points:

  sizeof(char[30])  //  Just do not do this
  name = malloc(???) immediately followed by name = ???  // Likewise

I do not think you want to program XS with so much knowledge of C.
But anyway, here is the thing I would try:

  SV *
  get_name()
    PPCODE:
      char *name = get_name();
      EXTEND(sp,2);
      PUSHs(&Perl_sv_yes);
      PUSHs(sv_2mortal(newSVpv(name, 0)));

(with an optimization to push 1).

Hope this helps,
Ilya


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3068
**************************************


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