[16919] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4331 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 15 06:10:58 2000

Date: Fri, 15 Sep 2000 03:10:13 -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: <969012613-v9-i4331@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Sep 2000     Volume: 9 Number: 4331

Today's topics:
        Text manipulation: translating several token at once <tm@kernelconsult.com>
        Text manipulation: translating several token at once <tm@kernelconsult.com>
    Re: Text manipulation: translating several token at onc <philipg@atl.mediaone.net>
    Re: Text manipulation: translating several token at onc <lr@hpl.hp.com>
        Timeout while socket opened (Park, Jong-Pork\)" <okletsgo@NOSPAM.hitel.net (remove NOSPAM.)
    Re: timeout <psbrady@my-deja.com>
        unwanted @ <rs016182@pro.via-rs.com.br>
        Web Client multipart-data POST <billhess2000@home.com>
    Re: Were to get a sendmail for a Win98 SE ? (Philip 'Yes, that's my address' Newton)
        RE: Were to get a sendmail for a Win98 SE ? <hopes@ole.com>
        WIN32::OLE and parameter call by reference problem (Bård J Grønbech)
    Re: Working with IP addresses the_crowbar@my-deja.com
    Re: XS and C structures question <sm_jamiesonNOsmSPAM@hotmail.com.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Sep 2000 06:33:38 +0200
From: TM <tm@kernelconsult.com>
Subject: Text manipulation: translating several token at once
Message-Id: <39C1A6A2.863E4040@kernelconsult.com>

   Hello,

here's the question let's take  a text or even   a line of text. with
let's say many atoms symbols from the periodic chart of elements. And
now we whant to translate each of them into their full name.
The brutal way would be to make a loop over the line and trying all  of
the symbol one at a time:

But I guess there must be a more elegant trick.

TM



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

Date: Fri, 15 Sep 2000 06:34:30 +0200
From: TM <tm@kernelconsult.com>
Subject: Text manipulation: translating several token at once
Message-Id: <39C1A6D6.2313A865@kernelconsult.com>

   Hello,

here's the question let's take  a text or even   a line of text. with
let's say many atoms symbols from the periodic chart of elements. And
now we whant to translate each of them into their full name.
The brutal way would be to make a loop over the line and trying all  of
the symbol one at a time:

But I guess there must be a more elegant trick.

TM



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

Date: Fri, 15 Sep 2000 04:47:37 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Text manipulation: translating several token at once
Message-Id: <JRhw5.1682$jC4.274850@typhoon.southeast.rr.com>

TM <tm@kernelconsult.com> wrote in message
news:39C1A6A2.863E4040@kernelconsult.com...
>    Hello,
>
> here's the question let's take  a text or even   a line of text. with
> let's say many atoms symbols from the periodic chart of elements. And
> now we whant to translate each of them into their full name.
> The brutal way would be to make a loop over the line and trying all  of
> the symbol one at a time:
>
> But I guess there must be a more elegant trick.
>
> TM

my %elements = ( H => 'Hydrogen', O => 'Oxygen', N => 'Nitrogen' );
my $text = 'H O N';

$text =~ s/(\w)/$elements{$1}/g;
print "$text\n";

hth,
Philip




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

Date: Thu, 14 Sep 2000 22:33:12 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Text manipulation: translating several token at once
Message-Id: <MPG.142b54664e549bde98ad6e@nntp.hpl.hp.com>

In article <JRhw5.1682$jC4.274850@typhoon.southeast.rr.com>, 
philipg@atl.mediaone.net says...
> TM <tm@kernelconsult.com> wrote in message
> news:39C1A6A2.863E4040@kernelconsult.com...

 ...

> > here's the question let's take  a text or even   a line of text. with
> > let's say many atoms symbols from the periodic chart of elements. And
> > now we whant to translate each of them into their full name.
> > The brutal way would be to make a loop over the line and trying all  of
> > the symbol one at a time:
> >
> > But I guess there must be a more elegant trick.

 ...

> my %elements = ( H => 'Hydrogen', O => 'Oxygen', N => 'Nitrogen' );
> my $text = 'H O N';
> 
> $text =~ s/(\w)/$elements{$1}/g;
> print "$text\n";

  my %elements =
    ( H => 'Hydrogen', O => 'Oxygen', N => 'Nitrogen', Ne => 'Neon', );
  my $text = 'H2O N Ne Foo';

  $text =~ s/([A-Za-z]+)/$elements{$1} || $1/eg;
  print "$text\n";

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


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

Date: Fri, 15 Sep 2000 13:12:00 +0900
From: "¹ÚÁ¾º¹ \(Park, Jong-Pork\)" <okletsgo@NOSPAM.hitel.net (remove NOSPAM.)>
Subject: Timeout while socket opened
Message-Id: <8ps6m0$gj3$1@news1.kornet.net>

I tried to get a html file from other site. And I wanna make more powerful web Robot.

But I can't control timeout while buffering data from the site.
Here is LWP example. LWP::UserAgent can define timeout before connect to the site.

But, Unhappiness, I can't define timeout while connected and getting data from the site.
If object site have lowest bandwidth and have a large file(but small than buffer),
my robot wait for a long time.

Here is LWP example and my wroted source. Help me....

------

$ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->max_size(10000);

$request = HTTP::Request->new('GET', 'http://slnms.snu.ac.kr');
$response = $ua->request($request);

print $response->content;


-------


   my $sock = IO::Socket::INET->new(PeerAddr => $host,
                                    PeerPort => $port,
                                    Proto    => 'tcp',
                                    Timeout  => 10) || return;
   $sock->autoflush;
   print $sock join("\015\012" =>
                    "GET $path HTTP/1.0",
                    "", "");

   my $buf = "";
   my $n;
   1 while $n = sysread($sock, $buf, 8*1024, length($buf));
   return undef unless defined($n);

    print $buf;









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

Date: Fri, 15 Sep 2000 08:54:16 GMT
From: Paul Brady <psbrady@my-deja.com>
Subject: Re: timeout
Message-Id: <8pso3m$66e$1@nnrp1.deja.com>

In article <cRVu5.55497$d9.388311@typhoon.kc.rr.com>,
  "Ryan McKillen" <ryruns@aol.com> wrote:
> I am working on a perl script right now and wondered if I could get
some
> help.  The script is attached.  This script uses LWP::Simple to check
links
> and make sure they work.  I would like for it to timeout and consider
a link
> not working if it can't be validated in 20 seconds or less.  Does
anyone
> know how to use perl's alarm() function to make this happen?
>

Couldn't read your script, but something like this should work :

    # simple script snippet to make socket connection and timeout
    # if response not received within $timeout seconds

    $timeout = 20;		# could be any no of seconds

    eval {
        local $SIG{ALRM} = sub { die "alarm\n" };    # NB \n required

	alarm $timeout;			# set alarm

	$sock = new IO::Socket::INET (PeerAddr  => $remote_server,
				      PeerPort  => $remote_port,
				      Proto	=> $proto,
				      Reuse     => 1);

	if ($sock){
	    $remote_server_ok = 1;      # connected OK
	} else {
	    $remote_server_ok = 0;      # nae luck !
	}

    };
    alarm 0;			        # switch off alarm

    if ($@ eq "alarm\n") {	        # $@ contains return from eval
	# timed out
	$remote_server_ok = 0;          # nae luck !
    }
    elsif ($@) {
	# eval died with other error
	$remote_server_ok = 0;          # nae luck !
    }


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


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

Date: Fri, 15 Sep 2000 04:20:35 -0300
From: "Fernando" <rs016182@pro.via-rs.com.br>
Subject: unwanted @
Message-Id: <8psiqc$106e$1@phi.procergs.com.br>

I'm using a format to store a string like this:

@*
$string

Well, the problem is that I'm getting an "@" at the end of string, so if
$string="bla", the string returned from the format is bla@. If I use @<<<...
its ok, but I want @* because I need to store multiline strings.




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

Date: Fri, 15 Sep 2000 04:20:21 GMT
From: "Bill Hess" <billhess2000@home.com>
Subject: Web Client multipart-data POST
Message-Id: <9shw5.47046$QW4.546759@news1.rdc1.mi.home.com>

I am trying to write a web client to upload files to a web server (in Perl)-
I know the CGI side on the server works, because I can upload successfully
using a web browser.  But I cannot seem to get the headers correct.  Here is
what I think the headers should look like - Am I missing something???  I am
trying to reverse engineer what IE is doing...


POST /cgi-bin/upload.pl HTTP/1.1
Accept: application/vnd.ms-excel, application/msword,
application/vnd.ms-powerpoint, image/gif, image/x-xbitmap, image/jpeg,
image/pjpeg, application/pdf, */*
Accept-Encoding: gzip, deflate
Accept-Language: en-us
Connection: Keep-Alive
Content-Length: 319
Content-Type: multipart/form-data;
boundary=---------------------------7d031f9410338
Host: deville
Referer: http://deville/cgi-bin/upload.pl
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)

---------------------------7d031f9410338
Content-Disposition: form-data; name="file";
filename="D:\hess\dev\www\notes\hello.txt"
Content-Length: 13
Content-Type: text/plain

Hello there

---------------------------7d031f9410338--


--

Bill Hess






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

Date: Fri, 15 Sep 2000 05:04:01 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: Were to get a sendmail for a Win98 SE ?
Message-Id: <39c1a830.566457912@news.tiscalinet.de>

On Thu, 14 Sep 2000 23:37:16 -0300, "Agustin Chernitsky"
<agustinchernitsky@altavista.com> wrote:

>     I'am running a server on my Win98SE for development. I need a sendmail
> program since my Internet Server uses sendmail to send it's mail. Can
> someone tell me were to get a sendmail for Win32?

http://www.sendmail.com/

Sendmail, Inc., sells sendmail for Win32 AFAIK.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.


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

Date: Fri, 15 Sep 2000 09:25:38 +0200
From: "Hopes" <hopes@ole.com>
Subject: RE: Were to get a sendmail for a Win98 SE ?
Message-Id: <8psip8$ljb$1@diana.bcn.ttd.net>

I use blat.exe for sending mail with windows.
Its very simple.
You can download the official latest version in
http://www.interlog.com/~tcharron/blat.html

Agustin Chernitsky <agustinchernitsky@altavista.com> escribió en el mensaje
de noticias 8ps20v$di7sa$1@ID-48235.news.cis.dfn.de...
> Hi!
>
>     I'am running a server on my Win98SE for development. I need a sendmail
> program since my Internet Server uses sendmail to send it's mail. Can
> someone tell me were to get a sendmail for Win32?
>
> Thanks!
>
>
> --
> Agustín Chernitsky
> InterEmpresa
>
> E-mail:       agustinchernitsky@altavista.com
> ICQ:          20020826
>
>




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

Date: 15 Sep 2000 07:40:04 GMT
From: bjg@kikut.asp.infostream.no (Bård J Grønbech)
Subject: WIN32::OLE and parameter call by reference problem
Message-Id: <8psjok$7it$1@news1.sol.no>

This method is part of an ocx, which I try to call from perl:

void ConvertCoord(single* ScreenX, 
                  single* ScreenY, 
                  double* MapX, 
                  double* MapY, 
                  short Direction);


 ------------------------------
use Win32::OLE;
my $obj = Win32::OLE->new("MapX.Map.3");

[ code deleted ]

my ($sx, $sy) = (23, 300);
my ($x, $y) = (0, 0);
my $vsx = Variant(VT_UI1|VT_BYREF, $sx);
my $vsy = Variant(VT_UI1|VT_BYREF, $sy);
my $vx = Variant(VT_R8|VT_BYREF, $x);
my $vy = Variant(VT_R8|VT_BYREF, $y);


$obj->ConvertCoord($vsx, $vsy, $vx, $vy, 1);
 ------------------------------

Running this with Activestate perl 5.6.0 gives me:

Win32::OLE(0.14) error 0x8002005: "Type mismatch"
    in METHOD/PROPERTYGET "ConvertCoord" argument 1 at t.pl line 29


What am I doing wrong?

-- 

-Bård

Bård Grønbech, InfoStream ASP ASA


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

Date: Fri, 15 Sep 2000 07:30:54 GMT
From: the_crowbar@my-deja.com
Subject: Re: Working with IP addresses
Message-Id: <8psj7e$1n6$1@nnrp1.deja.com>

Thanks!! With the code snipets posted I was able to get things working.
Thanks again.

James

In article <MPG.142ac752f777174b98ad66@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8pqrgf$qn0$1@news.smart.net> on 14 Sep 2000 15:39:59 GMT,
> hymie! <hymie@lactose.smart.net> says...
>
> ...
>
> > Convert the two IP addresses from base-256 numbers into base-10
numbers.
> > Then, as you iterate between your starting and ending point, convert
> > the base-10 numbers back to base-256 IP addresses.
> >
> > $base10=unpack("L",join '',map chr,reverse split(/\./,$ip));
> >
> > $ip = join '.',unpack("C*",reverse pack ("L",$base10));
>
> You are seriously deluded to think that those are 'base-10' numbers.
> That is only how they appear if you print them (that is, the default
> conversion of an integer to a string uses base-10 notation).  They are
> simply integers using Perl's internal representation, which is binary-
> based.
>
> > (Now ... I'm very proud of this little snippet, because I'm Just
Another
> > Perl Hacker Wannabe.  So I'm not sure if I should invite you to
admire
> > it, or pick it apart and teach me.  :)
>
> It is pretty good, though you missed the pack() in the first
conversion.
> But it is seriously flawed by the use of the endian-dependent 'L'
> conversion, instead of always big-endian 'Network' order.
>
>   $number=unpack'N',pack'C4',split/\./,$ip;
>
>   $ip=join'.',unpack'C4',pack'N',$number;
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>


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


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

Date: Fri, 15 Sep 2000 02:09:08 -0700
From: SimonJ <sm_jamiesonNOsmSPAM@hotmail.com.invalid>
Subject: Re: XS and C structures question
Message-Id: <04daa4e8.4a18e87d@usw-ex0106-048.remarq.com>

You can't directly access the C structure elements. There are 2 options
- the missing methods it complained about - write them ! A seperate
subroutine with the element's name that simply returns the element
value ! The only hassle is you need a method for each element.
The best option I came up with was to use a tied hash, so that I can do
things like $structptr->{element1} and also assign to it. The tied
methods reference the elements via a subroutine that simply returns all
the elements in a fixed order, or sets passed elements in the real
structure.
I also blessed the tied hash reference so that I can call up methods
and the C structure using the same object pointer. Quite neat.
Cheers,
Simon.


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



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

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


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