[9147] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2765 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 29 23:07:48 1998

Date: Fri, 29 May 98 20:00:25 -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           Fri, 29 May 1998     Volume: 8 Number: 2765

Today's topics:
    Re: Apache 90 second time out <rootbeer@teleport.com>
    Re: Apache 90 second time out (Mike Stok)
    Re: Control characters (Shaun Sides)
        DB_File database load corrupting records---help? (Sam Nelson)
    Re: Deleting Variables (Shaun Sides)
    Re: Don't Know how to decrypt using PERL (Ken Fox)
    Re: Don't Know how to decrypt using PERL <jgoldberg@dial-but-dont-spam.pipex.com>
    Re: Don't Know how to decrypt using PERL (Kevin Reid)
        expanding a perl variable back to the shell (Fraserwag)
    Re: expanding a perl variable back to the shell (Fraserwag)
    Re: expanding a perl variable back to the shell <ljz@asfast.com>
    Re: HELP!!!!!! seeker79@yahoo.com
    Re: net::ftp->ls() sloooowwwww <rootbeer@teleport.com>
    Re: PC Screen Image File info@insyte.com
    Re: please help <rootbeer@teleport.com>
    Re: Rand on NT perl (Mike Stok)
    Re: Rand on NT perl <rootbeer@teleport.com>
    Re: Reading whole file into a scalar (Shaun Sides)
    Re: RegEx for breaking up HTML <rootbeer@teleport.com>
    Re: Returning from a signal handler? <rootbeer@teleport.com>
    Re: seek advice on simple first program (Kevin Reid)
    Re: seek advice on simple first program (Mike Stok)
    Re: Tom Christiansen attacks the free software communit <kermit@ticnet.com>
    Re: xsub question: XS_pack_$ntype (Ken Fox)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 30 May 1998 02:46:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Apache 90 second time out
Message-Id: <Pine.GSO.3.96.980529194237.6742N-100000@user2.teleport.com>

On Fri, 29 May 1998, Agent Information Inquiry wrote:

> How can I have the script make some insignificant request to the server

Perhaps the docs, FAQs, and newsgroups about servers will be able to help
you, since the request should be the same no matter what language you
program it in. If you find out how to make the request and don't know how
to implement it in Perl, though, please ask again. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 30 May 1998 03:56:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Apache 90 second time out
Message-Id: <6ko00v$47j@news-central.tiac.net>

Randal Schwartz has written a bunch of uselful columns for Web Techniques,
Column 20 might be interesting to you, even if it doesn't directly solve
your problem... 

Go and browse http://www.stonehenge.com/merlyn/WebTechniques/

Hope this helps,

Mike

In article <356F35EB.7987@eg-web.com>,
Agent Information Inquiry  <agent@eg-web.com> wrote:
>Please help.  I have written a script that does some fairly heavy
>database  processing.  To complete the processing (due to the size of
>the task) will require over 3 minutes by the script.  But there is one
>problem which is summed up by the following note from my tech support:
>
>"This script will not be able to run through a web browser because
>Apache itself will time out if a request is not made within 90 seconds.
>Apache's perl interpreter is designed to handle simple requests and
>processes, and your script is actually doing a fairly complex
>maintenance routine."
>
>How can I have the script make some insignificant request to the server
>every minute so that I can trick the server into letting the script
>finish its processing?
>
>Help is appreciated, and thank you in advance.
>
>Ed
>-- 
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>E & G Web Designer Directory - - - - - - A Designer For Every Need
>http://eg-web.com                        *******  *******  *******
>WDD Global Hosting Service - - - - - - - The Web Home Specialists 
>http://eg-web.com/wddglobal/global.html  *******  *******  *******
>WDD Banner Exchange  - - - - - - - - - - One to One Display Ratio
>http://eg-web.com/wddglobal/global.html  *******  *******  *******
>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 30 May 1998 01:05:43 GMT
From: arch@abts.net (Shaun Sides)
Subject: Re: Control characters
Message-Id: <slrn6mu4fg.2vd.arch@abts.net>

Original message by: Liz Castro <Liznet@cookwood.com>
Date: Fri, 29 May 1998 09:23:49 -0400
Subject: Control characters


> While deciphering someone else's code, I've come across the following:
> 
> $val2 =~ s/\cM\n/<BR>/g;
> 
> I found a quick reference to \c in the Camel book; it says to use if for
> control characters. 
> 
> So what does \cM mean?

\cM would be represented in DOS as ^M or CTRL-M.  It's a carriage
return, ascii 13, 0x0D, 015, 00001101, or however you want to represent
it.  In DOS/WIn, both that and a linefeed character are tacked onto the
end of every line in a normal file.

-- 
==============================================================================
	   Shaun L. Sides	    | Hey!  CyberGold |     arch@abts.net
Free Randal Schwartz and Ric Flair! | wastes yer time | arch@sara.mmlc.nwu.edu
==============================================================================
	   The time for desperation is upon us.  Let's play.
		  First Wizard Zeddicus Zu'l Zorander
==============================================================================	


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

Date: 28 May 1998 15:07:00 GMT
From: sam@cs.stir.ac.uk (Sam Nelson)
Subject: DB_File database load corrupting records---help?
Message-Id: <6kjuik$8jm@lorne.stir.ac.uk>

I'm working on rendering our local student records database accessible webwise
via CGI stuff written around DB_File databases.  One segment, the `academic
history' dataset, revolves around creating the DB_File form of a flat file
300000-odd lines deep of the form

    registration#<tab>course<tab>session-code<tab>semester<tab>grade

which I split into separate per-semester DB_Files, but combine on a per-student
basis, so that each of the per-semester files contains key-value pairs of the
form

    Key                     Value
    registration#           `course(grade) course(grade) course(grade) ...'

As I work my way down the flat file, I append the `course(grade)' entry to
the relevant value in the relevant array with something like

 $AcademicHistory{$RegistrationNumber}.=sprintf(" %s(%s)",$CourseCode,$Grade);

(having of course previously `tied' `%AcademicHistory' to the relevant file).
The problem is that in a small fraction of cases (about 1/10000) this `append'
is treated as `assign', with the result that previously-appended course/grade
pairs are lost.  As you can imagine, I don't need this...

There appears to be a workaround involving building the database entirely in
memory, then tying up a DB_File and spitting the whole lot out into that file
(because obviously that only uses `assign' on the DB_File array).

I _was_ using plain old DB-1.85 against 5.004_04 (on Solaris 2.5.1/2.6) and
against 5.002 on a couple of other platforms.  I've recently tried out
DB-2.4.10 (built in 1.85 compatibility mode) and it seems to work better on
S2.5.1, at least, but I can't seem to get it to go against 5.002 elsewhere at
all.  Since I loaded the academic-history database up with 5.004_04/2.4.10,
I've discovered another 22 records (another fraction of a percent) that were
missing completely from the older database files.  I'm now working on methods
to verify that what's in the database files is what was in the raw-data flat
files...

Is DB_File _meant_ to handle this sort of thing, or am I pushing it Just Too
Far?

Thanks for any hints,

-- 
SAm.                               (Insert bandwidth-wasting disclaimer here)
[Tune: `Nick-nack Paddywhack']
  I hate Po, Po hates me / Po tied Dipsy to a tree
  Tinky-Winky shot him in the head / Sorry Laa-Laa, Dipsy's dead


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

Date: 30 May 1998 02:18:31 GMT
From: arch@abts.net (Shaun Sides)
Subject: Re: Deleting Variables
Message-Id: <slrn6mu5f6.2vd.arch@abts.net>

Original message by: Keith <barberk3@pilot.msu.edu>
Date: Fri, 29 May 1998 02:20:54 GMT
Subject: Deleting Variables


> # If it is past a $cut_off date, I want to delete the variables, yet I
> # get the error msg "delete argument is not a HASH element..."
>                 if ($day < $cut_off){
>                         delete FILE $class;
>                         delete $line{"$class"};
>                         delete $line{"$name"};
> 
> 
> Anyone help a new guy out?

I think what you're wanting is undef.  Do

	undef $scalar;
	undef @array;
	undef %hash;
	undef $hash{"key"};
	undef &sub;

If you want to delete an element pair from a hash, use

	delete $hash{"key"};

or if you want to actually delete a file, use

	unlink "filename";
	unlink $varContainingFilename;

That's all the stuff I know of to do those things. ;-)  I'm sure you'll
get more complete answers, though.

-- 
==============================================================================
	   Shaun L. Sides	    | Hey!  CyberGold |     arch@abts.net
Free Randal Schwartz and Ric Flair! | wastes yer time | arch@sara.mmlc.nwu.edu
==============================================================================
	   The time for desperation is upon us.  Let's play.
		  First Wizard Zeddicus Zu'l Zorander
==============================================================================	


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

Date: 30 May 1998 01:24:22 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <6knn46$94t14@eccws1.dearborn.ford.com>

"Larry Rosler" <lr@hpl.hp.com> writes:
> Please, folks.  Get your heads out of the Unix sandbox.  Continued blind
> Unix-centrism will hinder Perl, not help it.

How is not copying the definition of crypt() out of the C documentation
being Unix-centric?  If your C library doesn't have crypt(), then neither
does your Perl.  If your C library has crypt(), then why isn't a pointer
from the Perl docs to the C docs enough?

The Perl docs don't define all the oddities of printf() either.  Anybody
going to complain about that too?

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: Sat, 30 May 1998 02:32:45 +0100
From: "Jeremy Goldberg" <jgoldberg@dial-but-dont-spam.pipex.com>
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <6knnlf$2m4$1@plug.news.pipex.net>

> THE ON-LINE DOCUMENTATION DOES NOT EXPLAIN THE PURPOSE OF THE SALT.


According to the UNIX man pages:

       "salt  is  a  two-character  string  chosen  from  the  set
       [a-zA-Z0-9./].   This  string is used to perturb the algo-
       rithm in one of 4096 different ways."

That's the theory, anyway - it sometimes seems to make no difference beyond
tacking the salt on the front of the crypted output (although at other times
it DOES change the output).




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

Date: Fri, 29 May 1998 22:32:47 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Don't Know how to decrypt using PERL
Message-Id: <1d9sv27.104jsyp95jlpmN@slip166-72-108-247.ny.us.ibm.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> It is reasonable to assume that the person who asked what the purpose of
> the 'salt' argument was had crypt available.

My question was not what the purpose of the salt was. I meant "how is it
used in the encryption?".

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 30 May 1998 01:32:31 GMT
From: fraserwag@aol.com (Fraserwag)
Subject: expanding a perl variable back to the shell
Message-Id: <1998053001323100.VAA01602@ladder01.news.aol.com>

Hi,

I'm new to perl.  I am using perl for win32 to write an NT software release
script for our manufacturing operation.  I'm creating paths and files names as
follows:

print "enter the name of the file";
$filename = <STDIN>;
print "enter the destination path";
$destpath = <STDIN>;

The problem occurs when I am ready in the script to copy my files.  I'm doing
this as follows:

system ("copy d:\temp\release\$filename $destpath\$filename");

Whenever I reach this point in the execution of the script, I'm getting an
error stating that the command syntax is incorrect.  Can someone point out what
I'm sure is a REALLY obvious problem?  My assumption is that once I return to
the shell, I lose the ability to expand the variables.  Any comments gratefully
received. Thanks.

Simon


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

Date: 30 May 1998 01:55:15 GMT
From: fraserwag@aol.com (Fraserwag)
Subject: Re: expanding a perl variable back to the shell
Message-Id: <1998053001551500.VAA00237@ladder03.news.aol.com>

Sorry, my code also has the chops, but I didn't include them in the original
post, as I did the codeing earlier at work.

print "enter the name of the file";
$filename = <STDIN>;
chop($filename);
print "enter the destination path";
$destpath = <STDIN>;
chop($destpath)

Again, any help appreciated.


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

Date: 29 May 1998 22:38:36 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: expanding a perl variable back to the shell
Message-Id: <lt4sy8mqj7.fsf@asfast.com>

fraserwag@aol.com (Fraserwag) writes:

> Hi,
> 
> [ ... ]
>
> The problem occurs when I am ready in the script to copy my files.  I'm doing
> this as follows:
> 
> system ("copy d:\temp\release\$filename $destpath\$filename");
> 
> Whenever I reach this point in the execution of the script, I'm getting an
> error stating that the command syntax is incorrect.  Can someone point out what
> I'm sure is a REALLY obvious problem?  My assumption is that once I return to
> the shell, I lose the ability to expand the variables.  Any comments gratefully
> received. Thanks.

The problem doesn't have to do with the shell.  It's the way you're
using backslashes.  Try this instead:

  system ("copy d:\\temp\\release\\$filename $destpath\\$filename");

Since backslash has a special meaning within double-quoted strings,
you have to escape each backslash with another backslash in this case.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: Sat, 30 May 1998 00:53:14 GMT
From: seeker79@yahoo.com
Subject: Re: HELP!!!!!!
Message-Id: <6knl9q$rtv$1@nnrp1.dejanews.com>

Hi,

> without a server, for the purpose of debugging.. if this is true, how would
> i pass the attributes to it to test it, and find out what's not working
> etc??
> i'm writting these scripts in notepad, with only a couple tutorials and
> faq's to help me with the basics.. I can then go download Perl? for win95?
>

Perl Builder is what you need. This will allow you to test and debug your
scripts locally without a server. You can download a copy from
http://www.solutionsoft.com/perl.htm.

Dave Seeker


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sat, 30 May 1998 01:26:40 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: net::ftp->ls() sloooowwwww
Message-Id: <Pine.GSO.3.96.980529182503.6742E-100000@user2.teleport.com>

On Fri, 29 May 1998, Jeremy L. Mordkoff wrote:

> ftp->ls() seems to take 25 seconds to retrieve 2 file names. Is there a
> better (faster) way? 

Maybe; maybe not. There are several possible bottlenecks in an FTP
transfer; maybe the server took 24 seconds to connect, for example. But
the Net::FTP module has a debugging mode - does that give you any helpful
information? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 30 May 1998 01:15:35 GMT
From: info@insyte.com
Subject: Re: PC Screen Image File
Message-Id: <6knmjn$u9v$1@nnrp1.dejanews.com>

Thanks. Your point about clever and elegant well taken. This is what I ended
up doing and it appears to work correctly. I do not know if it will work for
all POSSIBLE PC Screen Image files, but it works in the set we are faced
with.

     open (IN, "<$data_in");
     @array = (<IN>);
     foreach $line (@array)
	{
	$list = join ("",$list,$line);
	}
     $list = substr($list,$data_leadin);
     $list =~ s/\x00//g;
     $list =~ tr/a-zA-Z0-9':\x20/ /cd;

In this particular case, it got rid of all the character attribute bytes,
including the "null (x00)" ones for the "empty" spaces...Works ..

John


In article <6kkk26$t7v$1@blackice.winternet.com>,
  Dave Kenny <dk@parka.winternet.com> wrote:
>
> Just because perl supports clever and elegant techniques doesn't mean
> you have to (or should) be clever and elegant all the time.
>
> I would do something simplistic like:
>
> 	@goodPart = array of char/attributes from area of interest;
> 	@chars = ();
> 	$nBytes = 0 + @goodPart;
> 	for ($j = 0;   $j < $nBytes;   $j = 2) {
> 		push @chars, $goodPart[$j];
> 	}
>
> That is, extract the characters you want by brute force instead of trying
> to be clever.  (While the attribute bytes _might_ all be nonalphanumeric
> I would not rely on that!)
>
> I would probably use read() rather than <>, to avoid worries about \r,
> \n, binary vs text files etc.  Since you want a bunch of bytes instead
> of a bunch of lines, this seems more intuitive to me.
>
> After reading the file into a string, I'd use substr() to extract the
> part(s) where your data is.  For each such chunk I'd say something like
>
> 	@goodPart = split //, $chunkOfFile;
> 	<the bruteforce loop to extract every other byte>
> 	print join("", @chars), "\n"
>
> (or \r\n if you are running under unix but producing a file for MsDos).
>
> My point is that lots of times I find it easier to use simple minded
> code, and run a test after each step toward the final program, so
> I can verify that my code is really doing what I think it should.
> I find this works much better for me than trying to be clever and
> ending up with a program that produces no output!  Those are hard
> to debug!
>
> So first I'd just write the code to extract the "lines" of interest
> and print them to STDOUT, piping my perl script into od -c or something
> where I can see the attribute bytes.
>
> Then I'd probably write a dummy routine to run the for loop on a
> string like "0123456789" to be sure I got the even numbers.  Finally
> I'd put the for loop inside the reading-the-data loop.
>
> I'll gladly swallow my pride if it gets me working code faster.
>
> info@insyte.com wrote:
> : I am attempting to process a file which is actually a PC screen image, i.e.
> : each display character is two bytes with the odd numbered byte being an
> : attribute. The raw data for the area of interest begins at byte 12 and each
> : "line" is 48 displayed charaters (96 data bytes) long. Because its going to a
> : fixed format PC display the source data does not contain NLs, the physical
> : display simply wraps every 48 characters. My objective is to end up with a
> : text file consisting of "lines" of 48 byte data elements.
>
> : The portion of the file that I want has alphamerics and some limited
> : punctuation so I have tried reading this file into an array and doing:
>
> :     @out_data = (<FILE>);
> :     $out_data =~ tr /a-zA-Z0-9':+/ /c;
>
> : This does get rid of the non-alphamerics (attributes) but leaves me with
> : spaces. If I do
>
> :     $out_data =~ tr /a-zA-Z0-9'://c;
>
> : the output ends up with a "ODOA" (new line) after EVERY data character.
>
> : I've tried treating it both as a array and as a scalar with varying results,
> : but all negative. Some of the attribute data in the source is things like
> : "OA" "OB" OD, etc. Some of the things I've tried have resulted in these
> : attributes being treated as if they were NL's etc!
>
> : Any suggestions on how I can process this down to plain ASCII text
>
> : -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> : http://www.dejanews.com/   Now offering spam-free web-based newsreading
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sat, 30 May 1998 01:48:06 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: please help
Message-Id: <Pine.GSO.3.96.980529183216.6742F-100000@user2.teleport.com>

On Thu, 28 May 1998, Ilya A Shlyakhter wrote:

> Subject: please help

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I need to convert C code fragments of the form
>   (SomeType *) IritMalloc(a*b*...*c*sizeof(SomeType)*d*...*e*f)
> into
>   IMALLOC(SomeType, a*b*...*c*d*...*e*f)
> 
> while leaving untouched cases where the amount of memory being
> allocated is not a simple multiple of sizeof(SomeType), e.g.
> (SomeType *) IritMalloc(sizeof(SomeType) + 10)
> 
> How can I do this in PERL?  

Maybe I'm misunderstanding the problem, but it sounds as if you need to
write a C parser which will see what's going on and re-write it if
necessary. 

Although you could write Perl code to parse C, it seems easier to start
with some existing C-parsing code written in C. That is, I'm not aware of
any Perl code which parses C, but I'm sure you can find C code which does
so. Of course, if you could find C-parsing code written in Visual Basic,
that would be a good start. :-) 

On the other hand, maybe your C code is so regular that you could identify
lines like those by matching with a simple regular expression. In that
case, this could be done with an appropriate substitution s/// in a few
lines of Perl code. But if (for example) there are comments interspersed
within the code you wish substituted, the problem of matching becomes
_much_ more complex. And even worse, where do you put the comments in the
new code?  :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 30 May 1998 03:45:10 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Rand on NT perl
Message-Id: <6knvc6$47j@news-central.tiac.net>

It's OK, if you deliberately seed the generator with a known value then
you enter the sequence at a predictable point (OK, the examples on linux,
but...)

[mike@stok mike]$ perl -e 'srand 10; for (1 .. 5) { print rand (10), "\n" }'
5.65810732077807
6.10929917544127
5.05768078379333
1.79646874312311
8.16686273552477
[mike@stok mike]$ perl -e 'srand 10; for (1 .. 5) { print rand (10), "\n" }'
5.65810732077807
6.10929917544127
5.05768078379333
1.79646874312311
8.16686273552477

So, you don't lose the capability and people who forget srand get less
predictable sequences...

Hope this helps,

Mike

In article <356feb4e.9878070@149.174.211.108>,
Ron Heiby <heiby_u@falkor.chi.il.us> wrote:
>Ala Qumsieh <aqumsieh@matrox.com> wrote:
>>I also heard, from reliable sources, that with the
>>upcoming new version of perl, an srand is not needed anymore
>
>This concerns me. Sometimes, it is useful to be able to have a repeatable
>series of "random" numbers. I hope that such capability would be maintained.
>
>-- 
>Ron.


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Sat, 30 May 1998 02:57:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Rand on NT perl
Message-Id: <Pine.GSO.3.96.980529194830.6742P-100000@user2.teleport.com>

On Fri, 29 May 1998, Ron Heiby wrote:

> Ala Qumsieh <aqumsieh@matrox.com> wrote:
> >I also heard, from reliable sources, that with the
> >upcoming new version of perl, an srand is not needed anymore
> 
> This concerns me. Sometimes, it is useful to be able to have a
> repeatable series of "random" numbers. I hope that such capability would
> be maintained. 

Your fears are groundless. Although calling srand is no longer required in
order to initialize the random seed, there is no plan to disallow it. See
the perlfunc and perldelta manpages for Perl 5.004 for some details. Hope
this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 30 May 1998 02:05:58 GMT
From: arch@abts.net (Shaun Sides)
Subject: Re: Reading whole file into a scalar
Message-Id: <slrn6mu7t1.2vd.arch@abts.net>

Original message by: Mike Dolan <mdolan@best.com>
Date: Thu, 28 May 1998 12:21:26 -0400
Subject: Reading whole file into a scalar


> I want to read the entire contents of a text file into a single scalar so
> that I can apply regular expressions to that scalar.  Do you know how to do
> this?

I don't think you can read a file into a scalar.  There's a variable $\
which contains the record separator.  The default value for this is \n,
and changing that value isn't recommended.  But you can do something
like:

	foreach $file (@ARGV) {
	    open FILE, $file || die "Ooops $!";
	    while (<FILE>) {
	        # do stuff to $_
		push @file, $_;
	    }
	    close FILE || die "Ooops, again $!";
	    undef @file;
	}

This is what I use when I want to keep the files in @ARGV separate from
each other.  You can just go:

	while (<>) {
	    # do stuff to $_
	    push @lines, $_;   # or however you'll keep it.
	}

As you've probably heard by now, TMTOWTDI.  And mine's not particularly
likely to be the best way, but I'm learning. ;-)

-- 
==============================================================================
	   Shaun L. Sides	    | Hey!  CyberGold |     arch@abts.net
Free Randal Schwartz and Ric Flair! | wastes yer time | arch@sara.mmlc.nwu.edu
==============================================================================
	   The time for desperation is upon us.  Let's play.
		  First Wizard Zeddicus Zu'l Zorander
==============================================================================	


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

Date: Sat, 30 May 1998 02:09:45 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: RegEx for breaking up HTML
Message-Id: <Pine.GSO.3.96.980529190640.6742I-100000@user2.teleport.com>

On Fri, 29 May 1998, Shawn Porter wrote:

> Doran L. Barton wrote:
> > I need a RegEx that will return a list of HTML elements and non-HTML
> > elements in a stream. 

> I couldn't figure out a regex to do it, but this does the trick. 

> 	if($document =~ s/^<(.*?)>//)
> 	{
> 		push(@elements, "<$1>");
> 	}

Perhaps you didn't realize that angle brackets may appear within valid
HTML tags. 

    <img src="rt-arrow.gif" alt="-->" >

This is why modules like HTML::Parser were developed. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 30 May 1998 02:15:15 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Returning from a signal handler?
Message-Id: <Pine.GSO.3.96.980529191031.6742J-100000@user2.teleport.com>

On Fri, 29 May 1998, Brian J. Sayatovic wrote:

>     I'm writing a perl script which runs a batch of programs one at a
> time.  If one particular one fails, say, due to a segv, I want it to be
> handled by perl so I can log it, and continue with the next program.  I
> have my signal handling set up sort of like this pseudo-code: 

Now, you know that a segfault doesn't make a signal which perl can catch,
right? That is, as I understand it, when a segfault happens, the perl
binary is unable to run further Perl code. 

On the other hand, when the magical $? variable is set to a child
process's exit status, you can easily tell which signal (if any) caused
the exit. Maybe that's what you need? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 29 May 1998 22:06:50 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: seek advice on simple first program
Message-Id: <1d9t7h7.1epuii51cq91cN@slip166-72-108-247.ny.us.ibm.net>

Shaun Sides <arch@abts.net> wrote:

> Yay.  I've managed to actually write a useful little program in Perl.
> ;-)  All it does is doublespace a file.  I have a couple of ideas for
> some other simple things I can try my hand at, too.  So, what I'd like
> to know is just how inefficient my algorithm is, brief advice on same,
> and that sort of thing.  Hell, if someone wants to show me a totally
> obfuscated version of it, go ahead! ;-)  I'm sure I'd learn something
> from it.
> 
> #!/usr/bin/perl -w
> # ds.pl --> Double-space
> # Program to take single spaced text files and add an
> # extra \n to the end of each line.
> # usage: ds <filename1> <filename1> <...> <filenamen>
> 
> foreach $file (@ARGV) {
>       open FILE, $file || die "Can't open $file $!";

The precedence of || is higher than open, therefore this will never
report an error because $file will (usually) be true.

Do this instead:

        open FILE, $file or die "Can't open $file $!";

(You also need to change "||" to "or" in the rest of your program.)

Or, if you like obfuscation:

 foreach $FILE (@ARGV) {
        open FILE or die "Can't open $file $!";

>       while (<FILE>) {
>               s/(.\n)$/$1\n/;
>               s/^\n$/\n\n/;
>               push @file, $_;

How about this instead of those 3 lines:

                push @file, "$_\n";

>       }
>       close FILE || die "Can't close $file $!";
>       open FILE, ">$file" || die "Can't open $file for write $!";
>       print FILE @file;
>       undef @file;
> }
> # EOF ds.pl
> 
> I see that loading the whole file into an array could cause some barfing
> if the size were significant.  I thought about trying to use $^I, but
> figured that I can modify it that way later on.  Or even come up with a
> better way.
> 
> --

The "--" needs a space after it ("-- ") in order to function as a
signature delimiter.

> ==============================================================================
>          Shaun L. Sides           | Hey!  CyberGold |     arch@abts.net
> Free Randal Schwartz and Ric Flair! | wastes yer time | arch@sara.mmlc.nwu.edu
> ==============================================================================
>          The time for desperation is upon us.  Let's play.
>                 First Wizard Zeddicus Zu'l Zorander
> ==============================================================================



-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 30 May 1998 03:30:18 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: seek advice on simple first program
Message-Id: <6knuga$47j@news-central.tiac.net>

In article <slrn6mu2la.2vd.arch@abts.net>, Shaun Sides <arch@abts.net> wrote:
>Yay.  I've managed to actually write a useful little program in Perl.
>;-)  All it does is doublespace a file.  I have a couple of ideas for
>some other simple things I can try my hand at, too.  So, what I'd like
>to know is just how inefficient my algorithm is, brief advice on same,
>and that sort of thing.  Hell, if someone wants to show me a totally
>obfuscated version of it, go ahead! ;-)  I'm sure I'd learn something
>from it.

  perl -ni.bak -e 'print $_, "\n"' file ...

might be one way of doing something close to what you want, and it may be
good enough for you too...

Hope this helps,

Mike
 
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Fri, 29 May 1998 21:14:41 -0500
From: "Kermit Tensmeyer" <kermit@ticnet.com>
Subject: Re: Tom Christiansen attacks the free software community (was: Re: GNU attacks on the open software community)
Message-Id: <6knq3i$65e@enews2.newsguy.com>




Kees Hendrikse wrote in message ...
>In <6k4735$8nc$1@justus.ecc.lu> Stefaan A Eeckels writes:
>
>> In article <EtD3MG.J8v@echelon.nl>,
>> kees@echelon.nl (Kees Hendrikse) writes:
>> > In <6k3k7m$76l$1@justus.ecc.lu> Stefaan A Eeckels writes:
>> >
>> >> In Dutch, some 'bleeding' of the meaning is present, however -
>> >> to indicate that something doesn't accrue taxes, one would say
>> >> 'belastingvrij' (litteraly 'tax free'), whereas the French would
>> >> say 'hors taxe' (litteraly 'without taxes').
>> >>
>> >> It's safe to say that in Dutch the word 'vrij' (which descends
>> >> from the same roots as 'free') has stayed closer to the original
>> >> meaning (which isn't 'gratis') than in English.
>> >
>> > I'm not so sure about that. Take for example the dutch 'vrij parkeren'
(free
>> > parking) which does mean: no charge for parking. I think in all western
>> > languages the notion of free is dangerously close to 'gratis'.


Vrij Parkeren  has a set of meanings that are understood from the
culture, that *does* have an impact in this discussion.

 Simply because a  spot is considered 'Vrij' parking, does not imply that
anything can be done with that spot.  Simply because one occupies the
spot does not mean that one can open up a Van to use as a portable
store (as in market day) without paying the city taxes for vendors.

 It does not require that all things that might be sold, be sold at cost or
that any tools that are dispense by use of sales in a 'Vrij Parkeren' does
not require that all products of the tools be given away with the same
requirments.
   Now imagine, that someone builds a product with gnu software, can you
imagine the problems sell the products for big money?

  Gnu software is not free because it limits what can be done with the
software
to specfic criteria and uses. It can't be used to make a big profit.


--
Kermit Tensmeyer      kermit@ticnet.com
   Dallas, TX         Life is too short to worry much...




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

Date: 30 May 1998 01:12:04 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: xsub question: XS_pack_$ntype
Message-Id: <6knmd4$94t13@eccws1.dearborn.ford.com>

nobody@nowhere.org writes:
> /usr/bin/perl: can't resolve symbol 'XS_pack_charPtrPtr'
> ...
> 
> A grep through /usr/lib/perl5 yields no subroutine with the name
> XS_pack_charPtrPtr (except ExtUtils/typemap).

That's probably how it's getting into your code then.  When building
the XS wrappers, xsubpp uses the typemap (and any custom typemaps that
provide) to generate code for argument conversion.

> sse is my own work with routines which returns char ** (is it possible
> to create xsubs which returns more refined structures?)

Have you defined your own "char **" typemap conversion?  If you don't,
xsubpp will take the ExtUtils definition.  Some of the standard
conversions are broken.  I've been meaning to submit a fix for them,
but haven't had time yet. :(

If you define your own "char **" conversion the problem should go away.

> is it possible to create xsubs which returns more refined structures?

That's a funny question.  Refined?  As in "char ** is below my station,
I deserve more refined structures?"  If you mean structs, then, yes,
your XS stubs can return pointers to structs.  In fact, treating pointers
to structs as blessed scalar refs is very easy.

> why does "perl Makefile.PL" complain:
> | Warning: the following files are missing in your kit:
> |       lib
> | Please inform the author.

You deleted "lib" from your source directory but you haven't
taken it out of MANIFEST?  If "lib" is a directory it shouldn't
go into MANIFEST.

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

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

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