[21754] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3958 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 12 03:05:39 2002

Date: Sat, 12 Oct 2002 00: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           Sat, 12 Oct 2002     Volume: 10 Number: 3958

Today's topics:
        chat2.pl error. <keesboss@chello.nl>
    Re: chat2.pl error. <goldbb2@earthlink.net>
    Re: effect of "use <version>" on forward-compatibility? <gorilla@elaine.furryape.com>
        Is there a way (AGoodGuyGoneBad)
    Re: ithreads, perl 5.8 and shared objects <goldbb2@earthlink.net>
    Re: ithreads, perl 5.8 and shared objects <troc@netrus.net>
    Re: Multiple Pings/Second <goldbb2@earthlink.net>
        Perl Book for sale <pic16@hotmail.com>
    Re: Problems with MSIE in combination with MAC not show <pkent77tea@yahoo.com.tea>
        question from beginner >_< (kit)
    Re: Regular Expressions Problem <goldbb2@earthlink.net>
        translate c++ to perl (kit)
    Re: Unrecognized character \x14 at line1 <bongie@gmx.net>
    Re: Unrecognized character \x14 at line1 <goldbb2@earthlink.net>
    Re: Web Design Resources & Tools...  all on one page! <uri@stemsystems.com>
    Re: Why is 'defined @x' deprecated? <heather710101@yahoo.com>
    Re: Why is 'defined @x' deprecated? <uri@stemsystems.com>
    Re: Why is 'defined @x' deprecated? <uri@stemsystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 12 Oct 2002 00:59:55 GMT
From: kees boss <keesboss@chello.nl>
Subject: chat2.pl error.
Message-Id: <fuKp9.3660$I8.114537@nlnews00.chello.com>

when I use "require chat2.pl" in my program's I get the error:

String found where operator expected at (eval 316) line 1, near "&__const 
'struct sockaddr'"
        (Missing operator before  'struct sockaddr'?)

I'm using preinstalled perl on SuSe linux 7.3 box.

Anybody know what is wrong with this perl-installation???

Thanks, Kees Boss


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

Date: Sat, 12 Oct 2002 00:58:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: chat2.pl error.
Message-Id: <3DA7ABE4.FBF03FF9@earthlink.net>

kees boss wrote:
> 
> when I use "require chat2.pl" in my program's I get the error:
> 
> String found where operator expected at (eval 316) line 1, near
> "&__const 'struct sockaddr'"
>         (Missing operator before  'struct sockaddr'?)
> 
> I'm using preinstalled perl on SuSe linux 7.3 box.
> 
> Anybody know what is wrong with this perl-installation???

You shouldn't be using chat2.pl -- it was written for perl4, and never
really got finished.  Instead, use the Expect module from CPAN.

Or, if all you need is to start a program with a terminal hooked to it's
std{in,out,err}, use IO::Pty (also from CPAN).

Or, if you're merely trying to multiplex many streams, learn about using
IO::Select (which comes with Perl) and sysread (a builtin function).

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Sat, 12 Oct 2002 01:28:35 -0400
From: Alan Barclay <gorilla@elaine.furryape.com>
Subject: Re: effect of "use <version>" on forward-compatibility?
Message-Id: <3DA7B303.7030200@elaine.furryape.com>

Vaughn Gardner wrote:
>> On Tue, 8 Oct 2002 17:56:43 -0500,
>>     Tad McClellan <tadmc@augustmail.com> wrote:
>>
>>> Vaughn Gardner <vhg@byu.edu> wrote:
>>>
>>>> (we have versions as old as 4.0.1.8 with code running against them).
>>>
>>>
>>>
>>> That is not a Perl version number. I think you mean v4.036.
>>
> 
> Here's what it said about itself:
> 
> $ /usr/contrib/bin/perl -v
> 
> This is perl, version 4.0
> 
> $RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
> Patch level: 36
> If this isn't a valid build ID, maybe I have bigger problems than I 
> thought :)

It's 4.036. 4.0 from the version number, plus 36 for the patch.





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

Date: 12 Oct 2002 06:32:13 GMT
From: agoodguygonebad@aol.com (AGoodGuyGoneBad)
Subject: Is there a way
Message-Id: <20021012023213.10798.00000847@mb-fv.aol.com>

I'm trying to send the contents of an object, then return new data to the
object.
I can copy the contents to a hidden field, since I'm not sure how to read in
the value of an object.

On a different page, I have called a script with a link(without changing the
current page), and then the script opened a popup.

A HREF="PopUp.cgi?somedata,291,185,etc" target=_blank>
It's just used to show the results of a querry to a user.

I can refresh the page if I have to. I'd rather do that than use frames, but
was hoping something like this might work

<script language=javascript>
function saveobj(){
var
chio=showModalDialog("SavRet.cgi","","dialogWidth=380px;dialogHeight=200px");
if (chio != null) {
document.objform.data.value=chio;
}
</script>

SaveRet.cgi
#parse data
#remove newlines, tabs, etc
#open file, save data, get next section of data, close file
#print popup screen header
#print javascript to return next section to parent
#print message data has been saved.
#print form, data, ok(submit) button.
#print footer

Thanks again, and pardon the JS
Steve


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

Date: Sat, 12 Oct 2002 00:51:13 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3DA7AA41.B1CA3169@earthlink.net>

Ilya Zakharevich wrote:
> Benjamin Goldberg wrote:
[snip]
> > > I read it as "POE can use an externally supplied event loop".  
> > > Right?
> >
> > Yes, if those externally supplied event loops will indicate
> > readability and writability on filehandles.
> 
> I'm confused.  *What* filehandle?  Is POE assuming that *every* event
> is associated to a filehandle?

No -- it means that the only kinds of events that POE *cares about* are
ones associated with filehandles.

> > Considering more real-worldish situations, let's consider the
> > following event types:
> >    F: filehandle ready for reading/writing (select)
> >    P: process has die (wait)
> >    L: locking events (flock)
> >    S: signals
> >    R: RPC (using semaphores and shared memory)
> > [wouldn't it be nice if we had an event system which handled *all*
> > of these? I may as well wish for the moon, considering how likely
> > that is.]
> 
> I do not know what is L;

Perl's flock builtin.  This may be implemented with one of the C flock,
lockf, or fcntl functions.

> is there a manpage available on Solaris?

If there isn't one for flock, perhaps there is one for lockf.  And
there's *certainly* a man page for fcntl, though whether or not solaris
fcntl supports F_GETLK, F_SETLK, F_SETLKW, I don't know.

> I also have no idea what is a "shared memory" event.

When performing rpc with shared memory, you use shared memory segments
to send data to/recieve data from the program you're doing RPC with, and
semaphores to tell the other program when it's safe to read from/write
to those shared memory segments.  You wouldn't have a "shared memory"
event, but you might have a semaphore event.

> On OS/2 I know how to handle F, P, S and R (but *very* ugly).  On
> Unix?  It is easy to handle F and S (thus P)...  [But only for S which
> do not require ACKing.  The latter may be also doable, but need
> further thinking.]

On unix, I would use a lightweight thread for handling each type of
event, and each of those threads would communicate the results to the
main thread using one single mechanism (probably a mutex lock, some
global memory (shared across all threads), and a condition variable).

The main thread could then read events from one place, using one
mechanism, and not have to worry about anything else, due to data
encapsulation.

> > POE handles events of type F.
> >
> > BourneShell handles events of type P.
> >
> > POE can only use BourneShell as a backend, with a bridge, if it *at
> > least* handles events of type F.  If BS handled both F and P, then
> > it would be doable, otherwise no.
> 
> You mean BS needs to handle events of type F, *even* if the
> application would not need them?

Yes, if you're going to use BS as a backend for POE.

> > Now, SMTT need events of some other type F, and lets you replace
> > it's event loop with any other event loop which supports type F ...
> > since POE always supports events of type F, you can use POE as a
> > backend.
> >
> > If you want to use another module's event loop as a backend, using a
> > POE bridge class, that backend *must* support events of type F (it
> > may do other things as well, such as P, but F is a minimum).
> 
> I still suspect that you try to convey is related to *one* module
> replacing (subclassing) the event loop...
> 
> > > BS handles wait() events only.
> >
> > Then you can't use BS as POE's backend.
> 
> OK: BS handles requests for F events by die()ing.  Is it good enough?
> ;-)
> 
> > > It does not know that somebody may need to examine the GUI event
> > > queue of Win32.
> 
> > How are Win32 GUI events done?  Type R, maybe?
> 
> I doubt it.  On OS/2 it is a special kind of Queue' ("prime" because
> it has a separate API, comparing to core-Queue).

Because you can only talk through an API, there's no way to know how
it's done internally.

> > > Likewise SMTT does not know that somebody may want to
> > > wait()...
> >
> > Fortunatly, SMTT does not need to know about someone wanting to
> > wait() if it's using POE for it's backend, since POE provides a kind
> > of contract, in that it will make callbacks for whatever F type
> > events you tell it to watch for.
> 
> Still do not understand what this has to do with SMTT and BS trying to
> cooperate on event dispatch (using POE as an arbitrator).

If SMTT only cares about only F events, then it can use POE as a
backend, regardless of what POE, in turn, uses as a backend.

If BS could handle both F and W events, then it could act as a backend
for POE, if you write an appropriate bridge class.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Sat, 12 Oct 2002 05:21:02 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <slrnaqfc9r.8ma.troc@eyrie.homenet>

On Fri, 11 Oct 2002 23:25:13 +0000 (UTC), Ilya Zakharevich wrote:
> You are still missing the point.  Of course *I* (given enough time and
> resources) *can* make them cooperate.  But the real question is: how
> to design an event looper which is *scalable*; I repeat that
> scalability in this context is an API which allows third-parties to
> extend the capabilities of the loop with the following properties:
>
>      the parties should not know about each other, only about the
>      extension API;
>
>      The parties may be extending the loop in the same direction, or
>      in independent directions.

The POE::Bridge subclasses are used below POE's public APIs.  They are
private interfaces to operating systems, graphical toolkits, or events
libraries.  My last message was all about making two or more of them
work together despite the silliness and difficulty of doing so.

POE::Kernel represents kernel services (provided by a POE::Bridge)
through a public set of medium-level APIs.  This seems to be the
"extension API" you seek.

As I mentioned in my last message, POE::Bridge subclasses may extend
POE::Kernel in two directions.  They may extend POE::Kernel downward
by hooking it to new kernel services.  They may extend it upward by
inserting new public APIs into POE::Kernel.

POE::Component modules have not been mentioned yet.  They are
extensions built atop POE::Kernel's public APIs.  They use POE's
common event loop and its common multitasking metaphor.  These seem
like your "parties".

Your other concerns were already covered in my last message.

-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net


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

Date: Sat, 12 Oct 2002 00:29:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multiple Pings/Second
Message-Id: <3DA7A518.547D2F8B@earthlink.net>

Kevin Vaughn wrote:
> 
> Somehow I have a feeling like this code would greatly help me out...
> if I understood it.  I guess I'll have to break out the Perl book and
> start learning =)

None of the individual parts are horribly complex -- it's just one
simple thing and another simple thing and another simple thing, which
put together look like one complicated thing.

> Thank all of you for your responses.  I wasn't expecting much, and I
> got a lot.  Maybe I can get better at this stuff and repay you one of
> these days.
> 
> -Kevin
> 
> >
> > Ok, revised code:

And now, with comments:

> >    my $socket = ...;

This should be an icmp socket, probably created with:
   my $socket = IO::Socket::INET->new(Proto => 'icmp');

> >    my @hosts = ...; # 4 byte ip addresses.

You'll probably create the elements of this list by doing inet_aton on
strings "1.2.3.4", or gethostbyname on strings like "foo.bar.com".

This 4 byte strings are packed in_addr structs.  (Or you could consider
them to be packed in_addr_t numbers, but that's silly).

> >    my %hosts = map {; pack_sockaddr_in(0, $_) => $_ } @hosts;

This creates a hash, with keys as sockaddr_in structs, and values as
in_addr structs.

> >    my @checksums;

For each sequence number, we compute one message and checksum.  Since we
reuse these, it makes sense to cache them.

> >    vec( my $svec = "", fileno($socket), 1 ) = 1;

Create a variable $svec, set it to "", then use vec() to set a bit
corresponding to the fileno of the socket... see perldoc -f select to
understand it's use.

> >    my $expire = 30 + time;

This is a 30 second timeout.

> >    my ($lastsent, $sentinel, $wvec) = scalar(each %hosts);

Create three variables, and assign to $lastsent the first key in the
%hosts hash.

> >    while( (my $seq = $expire - time) >= 0 ) {

Calculate the sequence number based on the time, and also check that we
haven't timed out.


> >       my ($msg) = @{$checksums[$seq] ||= do {

Each element of $checksums[...] is an arrayref, containing a pair of the
form: [message, checksum].  We're essentially doing here:
   my ($msg) = @{ that pair };
which assigns the message part of the pair to the variable $msg, and
ignores the checksum part.

The ||= means, if there *isn't* an element in $checksums[$seq] yet (and
there might not be, since @checksums is initally an empty array),
evaluate the expression on the right, assign it to the part on the left,
and use that as the result.

The "do {" means, we have stuff that's not a simple expression, but a
block, but we want to use that block as if it were a simple expression.

So the last element of the following block is used as the [message,
checksum] pair to store in $checksums[$seq], and to get the message to
put into $msg.

> >          $sentinel = $lastsent;

This is a bit hard to understand.  Further on, we repeatedly loop
through the %hosts hash.  But I don't want to always start in the
beginning, each time we get a new sequence number -- I want to start
just after the last item that was sent.  That means that for each new
sequence number, we need to *stop* when we've sent the last one that was
sent on the prior sequence number.

> >          $wvec = $svec;

For each sequence number, we only loop through the hosts once -- to mark
that we've already looped through the list once, we later assign "" to
$wvec.  This sets it back to the socket bitvector whenever we get a new
sequence number, indicating to begin/continue looping through hosts.

> >          # code, subcode, checksum, pid, seq, [data ommited]
> >          my $msg = pack("C2S3", 8, 0, 0, $$ & 0xFFFF, $seq);

Create a ping message.

> >          my $chk = unpack("%32S*", $msg);
> >          # $chk += ord(substr( $msg, -1 )) if length($msg) % 2;
> >          $chk = ($chk & 0xFFFF) + ($chk >> 16) for 1..2;
> >          $chk = 0xFFFF & ~$chk;

Calculate the checksum.

> >          $msg = pack("C2S3", 8, 0, $chk, $$ & 0xFFFF, $seq);

Remake the ping message, but with the checksum.  I suppose I could have
done:
             substr( $msg, 2, 2 ) = pack("S", $chk);
But since Net::Ping remakes the message, so do I.

> >          [ $msg, $chk ];

This is the last expression of the do block, and hence it is the value
of the do block.  It becomes the right side value of the "||=" up above.

> >       }};

One of these is to match the "do {", the other is to match "@{".

> >
> >       my $rvec = $svec;

We *always* try to read the socket (even if we're not trying to write to
the socket.

> >       (my ($n), $t) = select($rvec, $wvec, '', 0.5);
> >       die "select failed: $!" if !defined($n) or $n < 0;
> >       next if $n == 0; # timeout.

This tests if the socket is ready for reading or writing.

> >       if( $wvec =~ tr/^\0// ) {

If we haven't looped all the way through the %hosts hash for this
sequence number, then we need to send another ping packet.

> >          my $ip; $ip ||= each %hosts for 1..2;

This gets the next sockaddr_in struct from %hosts, repeating from the
beginning if we've gone off the end.

> >          send( $s, $msg, 0, $lastsent = $ip ) or die;

Send the packet.

> >          $wvec = "" if $ip eq $sentinel;

If we've reached our starting point, don't send any more packets during
this sequence number.

> >       }
> >
> >       $rvec =~ tr/^\0// or next;

If the socket is readable, continue.  If not, then repeat the loop.

> >       my $responder = recv( $s, my ($resp), 8, 0 )
> >          or die "Error in recv: $!"; # shouldn't happen.

Get an icmp packet.

> >       my ($port, $ip) = unpack_sockaddr_in($responder);

Split the originating host into it's address and port number.

> >       die "Expected port to be zero" if $port;

This really ought to be "next if $port != 0;", since it probably is
possible to send icmp packets from ports other than 0.  I think.

> >       my ($rtype, undef, $rchk, $rpid, $rseq) =
> >          unpack("C2S3", $resp);

Unpack the parts of the icmp packet (ignoring the subtype field).

> >       # make sure this is a valid packet:
> >       $rtype == 0 and $rpid == ($$ & 0xFFFF)
> >          and defined $checksums[$rseq]
> >          and $rchk == $checksums[$rseq][1] or next;

Check that the same data is coming back that we sent out.

> >       # remove this host from the %hosts hash, and
> >       # if wasn't previously there, ignore the packet.
> >       delete $hosts{$responder} or next;

When you delete a thing from a hash, it returns the old value of what
had been there.  If you try to delete a thing that wasn't there to begin
with, it returns undef.  So this will do a 'next' if the host that sent
us the packet isn't in %hosts (either because it's from a machine we
didn't ping, or because we've already recieved a ping response from
them).

I've just realized that there's a bit of a logic bug in my program
here... if the element we've just deleted was $sentinel, the loop-
through-%hosts-stopping-code will be confused, and, umm, not stop... So
I need to set $sentinel to something else, if that's the case; the next
element after where $sentinal was would be ideal, but I don't know how
to efficiently find that out, especially not after we've just deleted
it.  So instead, set it to $lastsent:

   $sentinel = $lastsent if $sentinel eq $responder;

Hmm, but even that might not work, if this response is *from* the last
item we sent, or if we've previously recieved a response to the one
which we last sent... so:

   if( $sentinel eq $responder ) {
      $sentinel = $hosts{$lastsent} ?
         $lastsent :
         (each %hosts or each %hosts);
   }

(The 'each %hosts or each %hosts' means that if we've gone past the last
element of %hosts, use the first element.)

Furthermore, way up above, the first item in the "do {" block, this same
mistake needs to be fixed... where it says:

>          $sentinel = $lastsent;

It needs to be:

           $sentinel = $hosts{$lastsent} ?
              $lastsent :
              (each %hosts or each %hosts);

> >       # print out the fact that we've discovered
> >       # that the host is alive.
> >       print inet_ntoa($ip) . " is alive\n";

The ntoa function means, "network format to ascii format".  You could
probably use gethostbyaddr and print the host's real name, but that's
your decision (it'll probably slow things down a bit, and you want your
program to run as quickly as possible).

> >       last unless %hosts;

Exit the while loop if there are no more hosts to recieve pings from,
since we've gotten pings from everyone.

> >    } # end while(1)

Err, this comment is wrong.  The condition of the while loop actually is
for whether we've timed out or not.

> >    print inet_ntoa($_)." is down\n" for values %hosts;

Any element still in the %hosts hash after the while loop exits is one
which we haven't gotten a response for.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Sat, 12 Oct 2002 02:46:13 GMT
From: "Jacob" <pic16@hotmail.com>
Subject: Perl Book for sale
Message-Id: <V1Mp9.4264$Sk6.465398@news1.telusplanet.net>

FS: Perl Developer's Dictionary by Clinton Pierce - $20
email me to pic16[Remove]@hotmail.com




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

Date: Sat, 12 Oct 2002 01:29:28 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Problems with MSIE in combination with MAC not showing Perl generated HTML
Message-Id: <pkent77tea-DDFC45.02292712102002@news-text.blueyonder.co.uk>

In article <3da72578$0$11215$1b62eedf@news.euronet.nl>,
 "Jan" <jan@nospam.harf.nl> wrote:

> print "Content-type text/html\nPragma: no-cache\n\n";
 ...

> http://80.60.28.57/top1000/secure/cgi-bin/formtest.pl to see that it
> normally should work.

It should not work. Your headers are not within the HTTP specification. 
The output of your script is bad and no browser is bound to render it. 
IE 5.1 on MacOS does the right thing and fails to show anything.

This is why so many people round here say:

   *** use CGI; ***

You made a mistake that you wouldn't have made if you'd used CGI.pm. 
Think of the time you'd have saved not having to debug this problem. 
Asnwer at the bottom of the message.

> We are totally in the dark why it doesn't show any output on the MAC. After

It's usually written Mac though, if you mean an Apple Macintosh PC.

P


__STUFF__
dev/area/tmp/perl-5.8.0 > HEAD 
http://80.60.28.57/top1000/secure/cgi-bin/formtest.pl

200 OK
Date: Sat, 12 Oct 2002 01:22:32 GMT
Pragma: no-cache
Via: 1.1 cache-har (NetCache NetApp/5.1R2D14)
Server: Microsoft-IIS/4.0
Client-Bad-Header-Line: Content-type text/html
Client-Date: Sat, 12 Oct 2002 01:23:15 GMT
Client-Peer: 80.60.28.57:80

See it now? If you don't then...

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 11 Oct 2002 22:48:55 -0700
From: manutd_kit@yahoo.com (kit)
Subject: question from beginner >_<
Message-Id: <1751b2b5.0210112148.27350cc@posting.google.com>

Would you answer the following questions for me ??

1) where I can download the online perl books?

2) how should I do for the c++ class structure in perl?

3) I am trying to make a game for my class, hmm ........ if I want to
make it works online, like playing in 2 different computers, what
should I do?

Thanks very much!


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

Date: Sat, 12 Oct 2002 01:15:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regular Expressions Problem
Message-Id: <3DA7AFE0.5FB43465@earthlink.net>

DMB wrote:
> 
> I'm just learning perl and I have a problem. I want to write a regular
> expression that insists that the number of left brackets in the
> pattern matches exactly the number of right brackets. So (he(llo
> wo)rld) would match but (he(llo wo)rld wouldn't. This sounds pretty
> simple but from whats in the book I was reading I can't think how to
> do it which is why I've been trying for the last half an hour or so.
> How can it be done? Thanks.

See perldoc perlre, where it describes the (??{ code }) construct.

I wouldn't use that code verbatim, but instead would do:

my $parens; $parens = qr/
   \(
   (?>(?:
      [^()]+
   |
      (?=\()
      (??{ $parens })
   )*)
   \)
/x;

Placing the (?>) in a different place, and adding the (?=\() *should*
improve the efficiency of the regex.

To be certain that "(he(llo wo)rld" won't match, use it as:
   if( "(he(llo wo)rld" =~ /^$regex\z/ ) {
      print "Matched!  Oops.\n";
   } else {
      print "Didn't match! Good.\n";
   }

Or perhaps:
   if( "(he(llo wo)rld" =~ /^(?>[^()]*(?:$regex[^()]*)*)\z/ ) {

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 11 Oct 2002 23:11:31 -0700
From: manutd_kit@yahoo.com (kit)
Subject: translate c++ to perl
Message-Id: <1751b2b5.0210112211.7316268f@posting.google.com>

is there any way that I can translate my c++ code to perl??

it sounds stupid, but I dun really know how to use perl.....


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

Date: Sat, 12 Oct 2002 06:57:26 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Unrecognized character \x14 at line1
Message-Id: <1735141.FypsAffmmF@nyoga.dubu.de>

Nishi Bhonsle wrote:
> I am executing the a perl script from the comand line on a unix box
> that calls internally some other perl script
> perl /home /home/nb/test.pl /home/nb /home/nb
  ^^^^^^^^^^
That's your command line?  So you're calling perl on a directory, not a 
Perl script?  That cannot work.

> and i am getting an error like Unrecognized character \x14 at line1

I suppose that perl tries to parse the directory.

> What does this error mean?

It means that perl found a character in the (supposed) Perl script that 
is part of the code but not valid.

> Used perl -d test.pl , but it was going into the perl script
> correctly.

That is a correct call, even without the '-d'.

> $map_file1="$clearcaseDrive_latestConfigSpec\/a.map";

You don't have to escape slashes.

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Experience is that marvelous thing that enables you to recognize a
mistake when you make it again.         -- F. P. Jones



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

Date: Sat, 12 Oct 2002 01:19:07 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Unrecognized character \x14 at line1
Message-Id: <3DA7B0CB.9675B7DA@earthlink.net>

Nishi Bhonsle wrote:
> 
> 
> Gurus:
> I am executing the a perl script from the comand line on a unix box
> that calls internally some other perl script
> perl /home /home/nb/test.pl /home/nb /home/nb
> 
> and i am getting an error like Unrecognized character \x14 at line1
> 
> What does this error mean?

It means that you have a "¶" character on line 1.

> Used perl -d test.pl , but it was going into the perl script
> correctly.

I doubt that -- or else it was a different character that perl was
complaining about.

Show us the real error message [using cut and paste] and perhaps we can
help you.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Sat, 12 Oct 2002 03:11:45 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Web Design Resources & Tools...  all on one page!
Message-Id: <x7wuooic5q.fsf@mail.sysarch.com>

>>>>> "g" == gbd  <asg779e@earthlink.net> writes:

  g> All comments are welcome.

stop spamming this group. no one cares about your stupid page.

uri

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


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

Date: Sat, 12 Oct 2002 02:17:45 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Re: Why is 'defined @x' deprecated?
Message-Id: <ao80o9$obl$1@reader1.panix.com>

In <x7bs60k23y.fsf@mail.sysarch.com> Uri Guttman <uri@stemsystems.com> writes:

>>>>>> "DW" == Da Witch <heather710101@yahoo.com> writes:

>  DW> I have a method that needs to compute the values in an array
>  DW> exactly once.  So I wrote something like:

>  DW>   { my @array; sub foo { unless(defined @array) { # carryout
>  DW> lengthy computation of @array
>  DW>       }
>  DW>       @array
>  DW>     }
>  DW>   }

>i know that is dummy code but where do you keep that array for real?

These array variables (there are several in the actual code) are meant
to be analogous to static variables in C: they "belong" to functions,
but retain their values after these functions return.  The reason I
have methods return the arrays, instead of simply setting the values
of the arrays once and for all, and simply use the array variables
directly, is that I want to make the data in these arrays inheritable.
So the methods are basically "get"-type accessors.  But some of these
methods, as it turns out, are called a lot, so I want to optimize them
by eliminating the redundant computations.

>  DW> But this seems to me exceedingly inelegant, especially since, in
>  DW> fact, I have several arrays that need to be computed only once.
>  DW> I'd have to have a "first_time_flag" for each: ugly.

>then use a hash of arrays. you can test for no array having been
>computed easily with exists.

>or for single arrays, use a scalar variable and stuff an array ref into
>it. then you can test the scalar with any boolean op to see if you have
>an array.

>see, i said there are simple and better ways to do this.

Yes.  But I guess the simplest still is "no warnings 'deprecated'" :-)

h


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

Date: Sat, 12 Oct 2002 03:09:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why is 'defined @x' deprecated?
Message-Id: <x765w8jqu1.fsf@mail.sysarch.com>

>>>>> "DW" == Da Witch <heather710101@yahoo.com> writes:

  DW> These array variables (there are several in the actual code) are
  DW> meant to be analogous to static variables in C: they "belong" to
  DW> functions, but retain their values after these functions return.
  DW> The reason I have methods return the arrays, instead of simply
  DW> setting the values of the arrays once and for all, and simply use
  DW> the array variables directly, is that I want to make the data in
  DW> these arrays inheritable.  So the methods are basically "get"-type
  DW> accessors.  But some of these methods, as it turns out, are called
  DW> a lot, so I want to optimize them by eliminating the redundant
  DW> computations.

so that doesn't stop you from using the ideas i said. and you then need
some way to access those arrays and also tell if they were assigned or
not. using the array ref itself for that is simple:

{ 
my $foo_ref ;

sub make_foo {

	$foo_ref = [ blah ] if $baz ;
}

sub get_foo {
	return $foo_ref ;
}
}

  >> see, i said there are simple and better ways to do this.

  DW> Yes.  But I guess the simplest still is "no warnings 'deprecated'"
  DW> :-)

i disagree. defined on aggregates is wrong and i am glad it is now
deprecated. either use my suggestions or some other method. in the
future defined on aggregates may even become a syntax error. it is not
meaningful in any way, shape or form. even those who care about storage
can always use the ref to the aggregate technique and undef the scalar
holding the ref.

uri

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


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

Date: Sat, 12 Oct 2002 03:10:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why is 'defined @x' deprecated?
Message-Id: <x71y6wjqri.fsf@mail.sysarch.com>

>>>>> "JT" == Jay Tilton <tiltonj@erols.com> writes:

  JT> The concept you've almost found in that idea is called memoization.

and there is a memoize module that does it for you.

uri

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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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


------------------------------
End of Perl-Users Digest V10 Issue 3958
***************************************


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