[7514] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1140 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 18:08:04 1997

Date: Tue, 7 Oct 97 15:00:23 -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           Tue, 7 Oct 1997     Volume: 8 Number: 1140

Today's topics:
     Re: $x = $y || $z - dangerous assumption? (Damian Conway)
     Re: [Q - newbie] Sockets and bi-directional communicati <greg_wright@cmsinc.com>
     Re: ActiveState/Activeware Site <afrenchs@epix.net>
     Adding key/vals to a hash? jflorent@forest.drew.edu
     Re: Adding key/vals to a hash? (brian d foy)
     Re: Adding key/vals to a hash? (Abigail)
     Re: Adding key/vals to a hash? (Greg Bacon)
     Can anyone help with a Bad free() error, please.... <ptomsic@pop.pitt.edu>
     Re: child labour <usenet-tag@qz.little-neck.ny.us>
     Compiling Perl4.004_01 on SunOS4.1.4 (Paul L. Lussier)
     Re: Die and the Web (John D Groenveld)
     Re: Help: Regular Expression Substitution <usenet-tag@qz.little-neck.ny.us>
     Re: How to check a URL adress in Perl ? (Abigail)
     Re: Killing a script after 'n' minutes <gabor@vinyl.quickweb.com>
     Re: looking for charity - telnet to port 25 <jay@rgrs.com>
     Re: oraperl (John D Groenveld)
     Re: perl and oracle (John D Groenveld)
     Perl and Sockets <froboz@cif.rochester.edu>
     Re: Perl eq to C struct <seay@absyss.fr>
     perl Q using -w and filehandlers sartang@pcocd2.intel.com
     perl script won't run correctly inside emacs <kin@isi.com>
     Re: perl script won't run correctly inside emacs <jay@rgrs.com>
     Re: Problems with 'new' (Greg Bacon)
     Re: Problems with 'new' <jhg@austx.tandem.com>
     Q:perl beautifier? <secdevc2@nortel.ca>
     Re: Sending files with sendmail <usenet-tag@qz.little-neck.ny.us>
     Simple Problem (ISTD/TD)
     Re: Strange string catenation quirk (Greg Bacon)
     Re: Where can I find LWP 5.02 or later? (Greg Bacon)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 7 Oct 1997 20:16:49 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: $x = $y || $z - dangerous assumption?
Message-Id: <61e5bh$a82$1@towncrier.cc.monash.edu.au>

Randal Schwartz <merlyn@stonehenge.com> writes:

>Damian> 	sub first_defined { map { return $_ if defined $_ } @_ }
>
>Ewwwww.  My eyes hurt.  map/grep in a void context is Bad Form,

Looks like you can take the programmer out of the functional paradigm,
but you can't take the functional paradigm out of the programmer :-)

For future reference, could you expand a little on _why_ that
particular solution is inappropriate?

>especially when this one could have been done by foreach so much easier:
>
>	sub first_defined { for (@_) { return $_ if defined $_; } }

Well, no argument that this is more straight-forward from an imperative 
view-point. I'm guessing that it's probably slightly more efficient too?

damian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  who: Damian Conway                 email: damian@cs.monash.edu.au
where: Computer Science Dept.          web: http://www.cs.monash.edu.au/~damian
       Monash University             quote: "The best form of self-defence is
       Clayton 3168, Australia               not being there in the first place"


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

Date: 7 Oct 1997 20:09:37 GMT
From: "J. Gregory Wright" <greg_wright@cmsinc.com>
Subject: Re: [Q - newbie] Sockets and bi-directional communication
Message-Id: <01bcd35d$74ac4f00$990d10ac@gregw-pc.cmsinc.com>

J. Gregory Wright <greg_wright@smsinc.com> wrote in article
<01bcd27a$d1ac3be0$990d10ac@gregw-pc.cmsinc.com>...
> J. Gregory Wright <greg_wright@smsinc.com> wrote in article
> <01bcd272$7d3596e0$990d10ac@gregw-pc.cmsinc.com>...
> 
> [ snip ]
> 
> > My experience with socket programs in 'C' indicates that this should
> > work, but both the client and the server hang (and I never see the
output
> > from the 'logmsg "Received..." line in the server).
> 
> Also, a telnet to the server process "works".  Meaning, if I telnet to
the
> server's port, and type in a string, then the server prints out the
string
> and sends back the canned "..the time is..." message and closes the
> connection.  So I am assuming the problem is with the client?

First of all, my apologies to anyone who responded to my post via E-mail -
typos in newsreader profiles can cause problems with reply-to-addresses.
The sole exception to this apology is Graham Barr <gbarr@ti.com>,
whose response was forwarded to me by the folks at "smsinc.com":

>Surly your experience with C code should tell you that using
>stdio and sockets do not mix. You shold be calling sysread,
>syswrite and using select to determine if there is any data
>on the socket.

[flame on]
This is the kind of snotty help that gets folks on these newsgroups
labelled as "jerks", "creeps" and "dweebs".  I attempted to follow
general rules of ettiquette by supplying as much information as
possible, and pointed out that I was taking my examples from 
Wall's book, which *does* show using 'print SOCK' and '$var = <SOCK>'
for I/O.  A simple "The examples in the book are only good for
connect-read data-disconnect" and "The standard way to do this
is to use sysread / syswrite..." would have sufficed.  Did you see
"newbie" in the header?  I did not claim to be an expert in Perl -
I was taking an example in a well-respected book, and modify it
to do something a little different.  My posting to the newsgroup 
after sifting through web sites, FAQs and the books was an attempt
to get an intelligent answer to my dilema, not a invitation for you
to pump your flagging ego.  Jerk.
[flame off]

At any rate, you *can* use 'print' and '<SOCK>' to do bi-directional
I/O over a single socket connection, if you use the following code:

  my $oldfh = select(SOCK);
  $| = 1;
  select($oldfh);

which turns on auto-flush for output operations on the pipe.  It makes
data available to the other side as soon as the output record separator
character is encountered in the output stream.  This was derived from
the responses to the article titled "fflush".

Is this the most optimal way to go about doing this?  Probably not...
but I would need some input on the second part of my question, which
had to do with the use of the IO::Socket library:

>Now one thing I have noticed from digging around in the newsgroup is
>that most folks seem to be using the IO::Socket library, instead of the
>"use Sockets".  Did I miss something?

Is this a better way to do things?  And when did it show up (as in, which
version of Perl).

Thank you in advance (and my apologies to those who were not the target
of the "flame" segment of the message for the outburst).

-- 
Gregory Wright
Credit Management Solutions, Inc.
greg_wright@cmsinc.com



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

Date: 7 Oct 1997 19:08:04 GMT
From: "Ann" <afrenchs@epix.net>
Subject: Re: ActiveState/Activeware Site
Message-Id: <01bcd34b$e5f3cf60$3dcaeecd@afrenchs>

Jeremy D. Zawodny wrote
"Ann" wrote:
: 
: >Anyone else having a problem accessing this site?  Also, the listserv
lists
: >I was subscribed to stopped; don't get reply to list majordomo requests.

: >Hope it's just that "Learning Perl on Win32 Systems" was more successful
: >than anticipated and it's a temporary thing.
: 
: There have been DNS problems which make getting to the site (and
: getting mail to the site) difficult.
: 
: FYI, they don't use Majordomo.

Thank you.  My ISP has been having some DNS problems so I wasn't as
concerned about not being able to resolve the site sometimes as with (1)
not being able to connect to the server and (2) that the 3 lists I'd
subscribed stopped.

Understood about 'majordomo'; I was using term in the generic sense.  When
trying to contact them I did use the address/format specified in their
subscription confirmations.

Ann



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

Date: 7 Oct 97 00:58:01 EST
From: jflorent@forest.drew.edu
Subject: Adding key/vals to a hash?
Message-Id: <e966Vj9TA0AD@forest>

Is it possible to add an element to a hash?  I'm thinking it's not, but if 
it is or anyone knows any feasible workarounds I'd really appreceiate it.  

-Justin Florentine


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

Date: Tue, 07 Oct 1997 15:31:15 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Adding key/vals to a hash?
Message-Id: <comdog-ya02408000R0710971531150001@news.panix.com>

In article <e966Vj9TA0AD@forest>, jflorent@forest.drew.edu wrote:

>Is it possible to add an element to a hash?  I'm thinking it's not, but if 
>it is or anyone knows any feasible workarounds I'd really appreceiate it.  

by "element" do you mean "key-value pair" as your subject line
implies?  if so, you simply use a new key and give it a value:

   $hash{$new_key} = $new_value;

were you thinking about something else?

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 7 Oct 1997 19:28:53 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Adding key/vals to a hash?
Message-Id: <slrn63l3fp.de.abigail@betelgeuse.rel.fnx.com>

jflorent@forest.drew.edu (jflorent@forest.drew.edu) wrote on 1498
September 1993 in <URL: news:e966Vj9TA0AD@forest>:
++ Is it possible to add an element to a hash?  I'm thinking it's not, but if 
++ it is or anyone knows any feasible workarounds I'd really appreceiate it.  

If not, hashes would be pretty useless.

One way of doing it is:

           $hash {$key} = $element;



Abigail


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

Date: 7 Oct 1997 21:36:15 GMT
From: gbacon@adtran.com (Greg Bacon)
Subject: Re: Adding key/vals to a hash?
Message-Id: <61ea0f$4qm$4@info.uah.edu>

In article <e966Vj9TA0AD@forest>,
	jflorent@forest.drew.edu writes:
: Is it possible to add an element to a hash?  I'm thinking it's not, but if 
: it is or anyone knows any feasible workarounds I'd really appreceiate it.  

    @flat_hash = %hash;
    push @flat_hash, ($key, $value);
    %hash = @flat_hash;

:-),
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 07 Oct 1997 15:33:09 -0400
From: Paul Tomsic <ptomsic@pop.pitt.edu>
Subject: Can anyone help with a Bad free() error, please....
Message-Id: <343A8E74.E4BCE530@pop.pitt.edu>

I'm getting this error on every program that I run, and it wasn't until
I installed
Perl 5.004 that this error started showing up...

Bad free() ignored at
/usr/local/lib/perl5/i386-bsdos/5.00401/DynaLoader.pm line155.

Now, I've taken to put a line in the code that looks like the following
to make perl
ignore it, but it's not a solution (IMO)

$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /^Bad free/ };

The line in the DynaLoader.pm that the error is coming from looks like
the following.....

    my $libref = dl_load_file($file, $module->dl_load_flags) or
        Carp::croak("Can't load '$file' for module $module:
".dl_error()."\n");


Again, I'm running the following.....

BSD/OS 2.1 and Perl  5.004_01



Thanks for any help.....


--Paul




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

Date: 7 Oct 1997 19:26:14 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: child labour
Message-Id: <eli$9710071519@qz.little-neck.ny.us>

karin  <nuekar@edith.antenna.nl> wrote:
> First of all we would like to thank you for taking the time to read our
> news.

s/news/post/;

> Statement 1.
> Child labour is a good thing. It makes the children tough and they
> wouldn't be a great burden to their parents. If children don't work,
> they come out of school and the only thing they do is bother their
> parents in stead of doing something usefull. 

system("kill -9 $$"); # patricide

> Statement 2.
> There are a lot of countries in this world who have an economical
> interest in countries where child labour is accepted. Countries where
> child labour is accepted should be shot out of the world economie.
> Not only economical area's but shot out completely until they change.

$f=fork;
unless defined($f) die "Can't get us a child!\n" ;

Elijah
------
was hoping this would be a perl question


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

Date: 7 Oct 1997 20:44:38 GMT
From: plussier@wellfleet.com (Paul L. Lussier)
Subject: Compiling Perl4.004_01 on SunOS4.1.4
Message-Id: <61e6vm$rdr@paperboy.corpeast.baynetworks.com>

Hi all,

I've been struggling with compiling and installing perl5.004_01 today and can't
figure out what the problem is.  I've never had a problem compiling perl before
but this time I'm stumped.  I'm on a SunOS 4.1.4 system, using gcc-2.7.2.3 and
gnu make 3.76.1, both also compiled and installed today, and neither of
which gave me any problem.

This is exactly what I'm typing:

sh Configure -Dcc=/usr/local/gnu/bin/gcc -Dprefix=/usr/local/langs/perl5 -des

This completes with out any errors or warnings, and tells me to run a make,
which I do (using gmake) and this dies with:

$ gmake
`sh  cflags libperl.a miniperlmain.o`  miniperlmain.c
       CCCMD =  /usr/local/gnu/bin/gcc -DPERL_CORE -c -I/usr/local/include -O   
In file included from perl.h:1010,
                 from miniperlmain.c:10:
scope.h:91: parse error before `jmp_buf'
scope.h:91: warning: no semicolon at end of struct or union
scope.h:94: parse error before `}'
gmake: *** [miniperlmain.o] Error 1

Any idea what I'm doing wrong?  This is a very standard, basic SunOS 4.1.4
setup.  I've even tried rm'ing the build directory and starting over from 
scratch, but I get the exact same thing.  Is there a problem with the tar
file I pulled down?  I looked at scope.h, but didn't see any problems with it.

Thanks a lot for any help in advance,

--
Seeya,
Paul
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- Paul Lussier		=   It is a good day	=The next best thing to doing -
= Baynetworks DOCD	-    to put slinkies	-something smart is not doing =
- plussier@lancity.com	=     on escalators	=      something stupid.      -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
     =     Don't take life too seriously, you won't get out alive.     -
     -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: 7 Oct 1997 16:20:22 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Die and the Web
Message-Id: <61e5i6$6n9$1@tholian.cse.psu.edu>

In article <342faa8a.3392555@news.magna.com.au>,
Jon Hedley <jhedley@REMOVEmustangpcs.com> wrote:
>program. Is there a way that I can set die to output to STDOUT rather
>than the error log?

CGI::Carp, included with the CGI.pm distribution, allows you to redirect
error messages. Thanks Lincoln!
John
groenvel@cse.psu.edu


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

Date: 7 Oct 1997 19:00:20 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Help: Regular Expression Substitution
Message-Id: <eli$9710071421@qz.little-neck.ny.us>

Tad McClellan <tadmc@flash.net> wrote:
> kai@webexpert.net wrote:
> :  3) Anyone have any thoughts of how to parse out comments in PERL?!? :-P
> : Comments are started with #, unless if # are within quotes or regular
> : expression delimiters... unfortunately, those delimiters can be ANYTHING
> : as long as the regular expression starts with m, s, y, tr,... anything
> : ELSE?! This becomes especially strange if I can't say: $CurLine =~
> : /=~\s*[smy(tr)]?(.)/; $delimiter =$1; # or is it $2?!? but if beginning
>         ^^^^^^^^^
> Here you are doing it again (not understanding char classes).

{misunderstanding explained and marked bit changed to (?:[smy]|tr)}

> Note also that your approach above will not work on these statements:
> 
> m{foobar};  # matching against $_ does not require the binding operator (=~)
> 
> split /foobar/, $str;  # never has a binding operator to key on...
 ...
> This is not a simple problem you are tackling...
> 
> You need to really parse the perl grammar. Regexs alone are not
> sufficiently powerful to do this right.

And perl grammar is not an easy thing to parse, particularly regexps. 
Some fun ones to think about, all legal (in 5.00401 at least). How many
can you understand without reading the docs or trying them out?

	s# foo	\# bar
	 # qux   #x;

	s# wee  [\#] fun
	 # neat  #x;

	s[ fee(.*fie.*)foe ][
			($a=$1,               # $1 can't be modified
			 $a =~ s# \s #"."#xge # tr might be faster
			 && $a  # replace with null if s/// failed
			    ]xe;

	$a=~s=j.k.l=wingo=s&&s&#(?#foo)&s;&;

Elijah
------ 
#!/usr/bin/perl -- -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P&,\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;


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

Date: 7 Oct 1997 19:34:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How to check a URL adress in Perl ?
Message-Id: <slrn63l3q7.de.abigail@betelgeuse.rel.fnx.com>

Greg Bacon (gbacon@adtran.com) wrote on 1498 September 1993 in
<URL: news:61dppf$q0v$2@info.uah.edu>:
++ [Posted and mailed]
++ 
++ In article <876235866.29562@dejanews.com>,
++ 	dbagot@gl16.fr.lucent.com writes:
++ : I am learning perl and my current task is to check a URL adress.
++ : I mean : how to know if a given URL adress is valid ?
++ : 
++ : Do a "URL" class exist ?
++ 
++ Use LWP; LWP rocks your Perl world!
++ 
++     % perl -MLWP::Simple -e 'getprint shift' http://www.foo.com/dir/
++ 
++ to put it simply.  If you want to be more thorough, take a look at
++ Randal's fourteenth Web Techniques column at
++ 
++     http://www.stonehenge.com/merlyn/WebTechniques/col14.html
++ 
++ for an example of using LWP for URL verification.
++ 
++ Since I mentioned Randal, another way of quickly checking a URL from
++ the command line is
++ 
++     % echo URL >/tmp/url.$$; cat /tmp/url.$$ | perl -MLWP::Simple \
++       -e 'chomp($url = <>); getprint $url'


Yeah, accept that it only checks for 3 out of the 10 possible URL schemes.



Abigail


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

Date: 7 Oct 1997 21:09:48 GMT
From: Gabor Egressy <gabor@vinyl.quickweb.com>
Subject: Re: Killing a script after 'n' minutes
Message-Id: <61e8es$j8s$1@flint.sentex.net>

Luis Torres <ltorres@campus.ruv.itesm.mx> wrote:
: Hi, anyone know of a way to kill a perl script after, say 60 minutes or
: so?

: Thanks in advance

alarm 3600;

gabor.
--
    It won't be covered in the book.  The source code has to be useful for
    something, after all...  :-)
        -- Larry Wall in <10160@jpl-devvax.JPL.NASA.GOV>


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

Date: 07 Oct 1997 15:00:40 -0400
From: Jay Rogers <jay@rgrs.com>
To: "Rama Polefka" <rama@mae.engr.ucdavis.edu>
Subject: Re: looking for charity - telnet to port 25
Message-Id: <82vhz9flev.fsf@shell2.shore.net>

"Rama Polefka" <rama@mae.engr.ucdavis.edu> writes:
> i am trying to automate a mail flush from a smtp server.  in order to do
> this, i need to telnet to port 25 and issue a command to start the flush. 
> thats it.
> 
> i am using the activestate version for win32 and have cut and pasted the
> following script:

Here's an implementation that works with Net::Telnet.  Net::Telnet
doesn't require any modules that don't already come with a perl
distribution.  You can find it on CPAN.

This connects to the SMTP server, issues the command, and checks for
success.

    ## Connect to smtp port.
    use Net::Telnet ();
    $esmtp = new Net::Telnet (-host => $hostname,
                              -port => 25,
                              -timeout => 30);
    
    ## Read server greeting.
    $esmtp->getline;
    
    ## Start queue processing.
    $esmtp->print("etrn#mydomain.com");
    ($prematch, $match) = $esmtp->waitfor('/^\d\d\d .+\n/');
    
    die "problem starting queue: $match"
        unless $match =~ /^\d\d\d OK/;
    
    $esmtp->print("quit");
    $esmtp->close;

--
Jay Rogers
jay@rgrs.com


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

Date: 7 Oct 1997 16:13:49 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: oraperl
Message-Id: <61e55t$6lj$1@tholian.cse.psu.edu>

In article <343320D6.2172@Sun.COM>,
MARI J MORTELL  <mari.mortell@Sun.COM> wrote:
>Hi,
>I am interested in oraperl.
>Can anyone point me to information on oraperl?
Many answers to life's questions are archived at Dejanews -
http://www.dejanews.com/ among other places.
John
groenvel@cse.psu.edu


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

Date: 7 Oct 1997 16:16:53 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: perl and oracle
Message-Id: <61e5bl$6ma$1@tholian.cse.psu.edu>

In article <34336DBE.9C0295DD@prestel.net>,
webadmin  <webadmin@prestel.net> wrote:
>How can I get perl to query an orcale dtabase, and is there a idiots
>guide out there somewhere. I can get it to query mSQL but I need to
>upgrade to Oracle.

Once you download the DBD::Oracle module, perldoc Oraperl and
perldoc DBD::Oracle will show you the light. You'll need to download
DBI, if you are using some other method to access mSQL.
John
groenvel@cse.psu.edu


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

Date: Tue, 7 Oct 97 21:10:26 GMT
From: Joshua Pincus <froboz@cif.rochester.edu>
Subject: Perl and Sockets
Message-Id: <1997Oct7.211026.5727@galileo.cc.rochester.edu>

I am writing a Perl-based Proxy server.  I have come up against a bunch 
of bizarre problems.  Whenever I try to read from a socket using 
sysread(), the system call hangs.  For instance, if I create the socket 
and then connect to the server with Netscape or Lynx, the while loop that 
reads in the Netscape header hangs after the header has been read in.  It 
blocks waiting for more data from the filehandle.  How do I stop this?  I 
merely want the darn while loop to act like a read() in C.  I want to be 
able to read in the data and, when their is no more data, to have sysread() 
return 0.  

I have searched the Perl FAQ and man pages for answers to no avail.  Any 
help would be appreciated.

Josh Pincus


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

Date: Tue, 07 Oct 1997 14:59:36 +0200
From: Doug Seay <seay@absyss.fr>
To: Brian@Kreation.com
Subject: Re: Perl eq to C struct
Message-Id: <343A3237.E678C8C@absyss.fr>

[posted and mailed]

Brian J. wrote:
> 
> I was wondering if there is a way to create a structure, or in Pascal
> a record? I also need an array of them.
> Something like:
> 
> struct PCB ( $ioburst = 0, $cpuburst = 0, $jobnum = 0);
> 
> @PCBs (1..100] of PCB
> 
> so accessing them would look something like this:
> 
> $PCBs[2].$ioburst = 23;
> 
> I know its a mess, but you get the idea.

You seem to be thinking Pascal or perhaps C.  Don't fight Perl.  Perl
doesn't do all this heavy pre-definition of data.  Relax and thing
"dynamic".

I do strucutres as hash tables, so I can do stuff like

	# creation and initialization
	my %structure = (
		field1	=> value1,
		field2	=> value2
		);

	# utilization
	$structure{field1} = $new_value;

If you want to limit your "structure" to only three fields, make a class
out of it and only define those three fields as methods.  If your OO
experience is limited, don't be frightened.  It ain't complicated.  Post
again if you try this and you are lost.

As for the list bit, put your constructor call in a loop and iterate 100
times.  Think dynamic.  Don't think pre-defined limitations.  I'm not
saying that one is better than the other, just that one way of thinking
is more natural to Perl.

Quoting FAQ4 (perldoc perlfaq4)

       How can I make the Perl equivalent of a C structure/C++
       class/hash or array of hashes or arrays?

       Use references (documented in the perlref manpage).
       Examples of complex data structures are given in the
       perldsc manpage and the perllol manpage.  Examples of
       structures and object-oriented classes are in the perltoot
       manpage.

You need to RTFM to get a few ideas.

- doug


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

Date: Tue, 07 Oct 1997 15:22:07 -0600
From: sartang@pcocd2.intel.com
Subject: perl Q using -w and filehandlers
Message-Id: <876250045.13827@dejanews.com>

hi, I have the following code

open ( FILE , "filename") || die "died\n";

&parseFile( FILE ) ;

If I use -w it warns that  FILE  is not being used.

I tried using :
use vars qw( FILE );
and it did not like this at all so I always get this
warning whenever I run.  What can I do ?


thanks

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Tue, 7 Oct 1997 15:03:26 -0400
From: Kin Cho <kin@isi.com>
Subject: perl script won't run correctly inside emacs
Message-Id: <343A87C8.A8BC0372@isi.com>

I wanted to execute a system command with a perl script in emacs.
So I put this perl statement:

system("xterm -e rlogin foo");

in foo.pl.  Then I invoke the compile command in the buffer foo.pl in
emacs,
which I defined to invoke perl followed by the filename of the buffer.
The xterm pops up for a split second, then goes away.

If I run perl foo.pl from inside a emacs shell buffer, the xterm stays
up correctly.

Anyone knows how tty, stty, etc... works please help!

Thanks.

-kin




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

Date: 07 Oct 1997 17:06:28 -0400
From: Jay Rogers <jay@rgrs.com>
To: Kin Cho <kin@isi.com>
Subject: Re: perl script won't run correctly inside emacs
Message-Id: <82ra9xffl7.fsf@shell2.shore.net>

Kin Cho <kin@isi.com> writes:
> I wanted to execute a system command with a perl script in emacs.
> So I put this perl statement:
> 
> system("xterm -e rlogin foo");
> 
> in foo.pl.  Then I invoke the compile command in the buffer foo.pl in
> emacs,
> which I defined to invoke perl followed by the filename of the buffer.
> The xterm pops up for a split second, then goes away.
> 
> If I run perl foo.pl from inside a emacs shell buffer, the xterm stays
> up correctly.

Hey, it works for me.  :-)

If you know you have permission to rsh to the remote host, try
flipping the xterm and rlogin around:

    $remote = "foo";
    $display = "bar:0";
    system "rsh $remote -n 'exec xterm -display $display'";

This way your input takes a more direct route to xterm.  Also your
DISPLAY is correctly set.

I can't imagine why you'd want to invoke a perl program via M-x
compile.  Use M-x perldb to debug perl programs.

If you're looking for a way to position to compilation errors within
the perl source, like M-x compile, then grab my improved version of
perldb.

  ftp://ftp.cis.ufl.edu/pub/perl/CPAN/authors/id/JROGERS/perldb+.el.1.02.gz

--
Jay Rogers
jay@rgrs.com


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

Date: 7 Oct 1997 21:24:47 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Jim Garrison <jhg@austx.tandem.com>
Subject: Re: Problems with 'new'
Message-Id: <61e9av$4qm$2@info.uah.edu>

[Posted and mailed]

In article <343A8416.167E@austx.tandem.com>,
	Jim Garrison <jhg@austx.tandem.com> writes:
: I can get it to work by using 'eval', as in
: 
: 	$ctl = eval "new $ctype(\$a,\$ct)";
: 
: but this still doesn't answer the question of why
: the simple case compiles but the more complex
: case doesn't.  Besides, I'm not sure that eval
: should be required here....

No eval (especially the evil eval EXPR variant) necessary:

    $ctl = $ctype->new( \($a, $ct) );

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Tue, 07 Oct 1997 16:37:33 -0500
From: Jim Garrison <jhg@austx.tandem.com>
To: Greg Bacon <gbacon@adtran.com>
Subject: Re: Problems with 'new'
Message-Id: <343AAB9D.78C3@austx.tandem.com>

Greg Bacon wrote:
> 
> [Posted and mailed]
> 
> 
> No eval (especially the evil eval EXPR variant) necessary:
> 
>     $ctl = $ctype->new( \($a, $ct) );
> 
> Hope this helps,
> Greg

Why does the indirect object form compile in some
cases but not others?  Should I submit a perlbug?

-- 
James Garrison			mailto:jhg@austx.tandem.com
Tandem Computers, Inc
14231 Tandem Blvd, Rm 1038	Phone: (512) 432-8455
Austin, TX 78728-6699		Fax:   (512) 432-8247


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

Date: Tue, 07 Oct 1997 15:46:02 -0400
From: Anton Fernando <secdevc2@nortel.ca>
Subject: Q:perl beautifier?
Message-Id: <343A917A.3DE0@nortel.ca>

hi folks,
	Like cb (C beautifier), is there one for Perl5.* ?

Thankx in Adv
anton fernando
secdevc2@nortel.ca


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

Date: 7 Oct 1997 19:15:58 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Sending files with sendmail
Message-Id: <eli$9710071500@qz.little-neck.ny.us>

Jan Krynicky  <Jan.Krynicky@st.mff.cuni.cz> wrote:
> ECSSPEAR@livjm.ac.uk wrote:
> > Is it possible to have the files e-mailed as attachments
> > just as they would if they were sent with any modern e-mail
> > program (as opposed to sending them uuencoded in the mail message)?
> It depends on the sendmail program you use.

Huh? sendmail is oblivious to these things. If you have a base64
encoded file in $File (see the MIME::Base64 module) then something
like this will send it:

open(MAIL,"|sendmail -t") || die "Nobody shot me. -- Frank Gusenburg\n";

print MAIL <<EndOfMail
To: $useraddress
Subject: your file sir/ma'am
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="my-unique-string"

This is a MIME multipart message. MIME aware tools will hide this
text from you normally.

--my-unique-string
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Dear Sir or Ma'am:
Here's your file.
Enjoy.

--my-unique-string
Content-Type: application/unknown
Content-Transfer-Encoding: base64

$File

--my-unique-string--
EndOfMail

	&& close MAIL;

See RFC 1431 for more about MIME formatting. It is really quite
simple.

Elijah
------
the Gusenburg quote is not important here


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

Date: Tue, 7 Oct 1997 18:57:31 GMT
From: "Howell Caton (ISTD/TD) <caton>" <caton@arl.mil>
Subject: Simple Problem
Message-Id: <343A861B.204C@arl.mil>

This is a multi-part message in MIME format.

--------------7D9963784AFE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Here's something really simple that won't work.  Can anyone tell
me why.  Thanks!



-- 


Howell Caton
Army Research Lab.
ATTN:  AMSRL-IS-TP
Aberdeen Proving Ground, MD 21005
phone 410-278-8942
FAX 410-278-9223
caton@arl.mil

--------------7D9963784AFE
Content-Type: text/plain; charset=us-ascii; name="ng_msg"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="ng_msg"


    cat <fn> |delay_echo |rt_echo 

where delay_echo is as follows:

#!/usr/local/gnu/bin/perl

while (<STDIN>)
{
    print;
    sleep(2);
}


and rt_echo is as follows:

#!/usr/local/gnu/bin/perl
while (<STDIN>)
{
    print;
}

--------------7D9963784AFE--



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

Date: 7 Oct 1997 21:33:53 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Tom Bortels <bortels@pacificnet.net>
Subject: Re: Strange string catenation quirk
Message-Id: <61e9s1$4qm$3@info.uah.edu>

[Posted and mailed]

In article <343A834E.40D4@pacificnet.net>,
	Tom Bortels <bortels@pacificnet.net> writes:
: Weird. Try the following:
: 
: #!/usr/local/bin/perl

No -w?

: $hello = "hello"; $goodbye = "goodbye";
: $r1 = "$hello:$goodbye:::::\n";
: $r2 = "$hello:$goodbye" . ":::::\n";
: print $r1;
: print $r2;
: 
: (I was using similar code to munge thru a shadow password file)
: 
: Here's the output I get:
: 
: hello::
: hello:goodbye:::::

My guess is the parser's seeing the double colons and thinking goodbye
is a package name because

    $r1 = "${hello}:${goodbye}:::::\n";

yields the expected output.  Had you run your script under -w, perl
would have complained about use of an uninitialized value.  Always run
under -w when you get unexpected results; it can be enlightening.

I would say this is a bug (the behavior is the same under 5.004_03),
but I'd be delighted to hear why it isn't.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: 7 Oct 1997 21:16:34 GMT
From: gbacon@adtran.com (Greg Bacon)
To: Ryan Ilea <rilea@NospaMsprint.ca>
Subject: Re: Where can I find LWP 5.02 or later?
Message-Id: <61e8ri$4qm$1@info.uah.edu>

[Posted and mailed]

In article <343A7C59.81@nospamsprint.ca>,
	Ryan Ilea <rilea@NospaMsprint.ca> writes:
: I'm trying to compile a perl program that I have and first I had to
: upgrade perl from 5.001 to 5.003 and now it says that it requires LWP
: 5.02 or later.  If anyone knows where I can get LWP for Linux I would
: really appreciate if they would let me know.  Thanks in advance.

Get thee to the CPAN!

    http://www.perl.com/CPAN/

Look for the latest LWP distribution in

    http://www.perl.com/CPAN/modules/by-module/LWP/

: PS If replying by email remove 'NospaM' from address.

To receive replies by email, put a replyable email address in your
From: header or your Reply-To: header, perhaps both.

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". 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 1140
**************************************

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