[6445] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 70 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 7 12:16:00 1997

Date: Fri, 7 Mar 97 09:00:25 -0800
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, 7 Mar 1997     Volume: 8 Number: 70

Today's topics:
     "indent" for perl (Claude Frantz)
     Re: /.*/ works, /[.]*/ doesn't, why!?!!?!! <rfi@uebemc.siemens.de>
     Re: Basic $ENV questions (Eddie Babin)
     Binary Upload to web.. <areeves@goodnet.com>
     Re: BUG? Please explain this behavior <roderick@argon.org>
     Re: BUG? Please explain this behavior <jhg@austx.tandem.com>
     Re: Chopping lines? (Jeffrey)
     Re: Chopping lines? <joemoore@att.com>
     Re: Comm.pl vers 1.6 (Clay Irving)
     Generate Makefile and execute it from PERL <jyves@nortel.ca>
     Re: HELP!?! - Perl from UNIX shell??? (Brian Wheeler)
     help: add a package to perl jim_shi@franklin.com
     How can I find cause of bloated memory consumption in l <tim.wilson@cambridge.simoco.com>
     Re: Interactive drawing alternatives in perl? (Clay Irving)
     Re: keys() on a map() fails. Why? (Dave Thomas)
     Re: Multiline Strings into a List/Array (Nathan V. Patwardhan)
     Re: need some help here (M.J.T. Guy)
     Opening files in subdirectories <q0c73@unb.ca>
     Re: Perl Basic ( DOS/Win) (Nathan V. Patwardhan)
     Re: Perl/Win32 seems to choke on high bits (Gerben Vos)
     Re: Possible bug in regular expression form /\d{x,x}/ <syer@mpa-garching.mpg.de>
     Re: Possible bug in regular expression form /\d{x,x}/ <tchrist@mox.perl.com>
     Re: Reading from a file in an array arbitrary ???? <seay@absyss.fr>
     Re: Regexp: Search outside of HTML tags (Tad McClellan)
     releasing socket connections <mstearns@darkwing.uoregon.edu>
     Re: Semantics of hashes and NIS+ combined... what to do <pfeifer@ls6.informatik.uni-dortmund.de>
     SIGPIPE in LWP::Socket::connect on Solaris 2.5.1 (Gerben Vos)
     Re: Simple tr/// (Eric Bohlman)
     Re: Socket/Spawn problems under Solaris - could someone <pfeifer@ls6.informatik.uni-dortmund.de>
     Re: SSI with PERL and win95/NT (Nathan V. Patwardhan)
     Trapping Segmentation Fault <joemoore@att.com>
     Web Hosting Solutions woutlet@worldnet.att.net
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Mar 1997 12:44:25 GMT
From: claude@netwoman.rz.unibw-muenchen.de (Claude Frantz)
Subject: "indent" for perl
Message-Id: <33200d66.27632303@news.unibw-muenchen.de>

Where can I find the "indent" equivalent program for perl 
source code ?

Thanks.
Claude


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

Date: 07 Mar 1997 11:48:07 +0100
From: Ronald Fischer <rfi@uebemc.siemens.de>
Subject: Re: /.*/ works, /[.]*/ doesn't, why!?!!?!!
Message-Id: <xz2k9nk9dw8.fsf@uebemc.siemens.de>

peterv@valkieser.nl (Peter de Vroomen) writes:

[This message posted AND mailed]

| If /a*/ and /[a]*/ do the same thing, then why not /.*/ and /[.]*/???

Because inside a character class regular expression (i.e. inside
square brackets), the special characters loose there special meaning
(except a caret on the very first position). Therefore, [.] denotes
the set of characters consisting of a dot and serves not as a wildcard
for an arbitrary character.

-- 
Ronald Otto Valentin Fischer
business:	ronald.fischer@uebemc.siemens.de
private:	ronald.fischer@acm.org
http://ourworld.compuserve.com/homepages/ronald_fischer


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

Date: 7 Mar 1997 16:26:52 GMT
From: ebabin@cyberenet.net (Eddie Babin)
Subject: Re: Basic $ENV questions
Message-Id: <5fpfkc$di9@news.cyberenet.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Eddie Babin (ebabin@cyberenet.net) wrote:
: 
: : Thanks for your help.  This gave some of the environment variables.
: : How can I access the rest?
: 
: That *was* all the environment variables.  Which others were you
: looking for?
: 
: --
: Nathan V. Patwardhan
: nvp@shore.net
: 

I guess I'm mistaken but I've seen references to the following which I
also thought were environment variables:

HTTP_PROXY_CONNECTION 
HTTP_REFERER 
HTTP_USER_AGENT 
HTTP_CACHE_CONTROL
HTTP_X_FORWARDED_FOR
HTTP_VIA
PATH 
QUERY_STRING
REMOTE_ADDR 
REMOTE_HOST 
REQUEST_METHOD 
SCRIPT_NAME 
SERVER_ADMIN 
SERVER_NAME 
SERVER_PORT 
SERVER_PROTOCOL


Is there anyway to retrieve these values?  Thanks again for your help.

ed

-- 


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

Date: 7 Mar 1997 16:35:38 GMT
From: "Tony Reeves" <areeves@goodnet.com>
Subject: Binary Upload to web..
Message-Id: <01bc2b15$98a52a80$37931193@treeves.es.hac.com>

Does anyone have code to do a file transfer from a users PC/Mac disk to a
web location? 

I need to have an script that will allow me to let a user enter a file
name, then trasnfer that file to a dir on my web server.. the file will be
binary..



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

Date: 6 Mar 1997 20:26:00 -0500
From: Roderick Schertler <roderick@argon.org>
To: jhg@mpd.tandem.com
Subject: Re: BUG? Please explain this behavior
Message-Id: <pz9140lcod.fsf@eeyore.ibcinc.com>

On Wed, 05 Mar 1997 21:22:25 -0500, Bill Cowan <billc@tibinc.com> said:
> Jim Garrison wrote:
>> 
>> DB<2> $href = {"key1" => "val1", "key2" => "val2"};
[...]
>> DB<8> p %$href
>> 268671480

Yes, looks like a bug to me.

> [works using Win32 5.001m, printing "key1val1key2val2"]

Ditto with 5.003_92.  I don't have any older versions around with which
to test.  Jim, could you try with 5.003_92?  If not how about posting
the output of `perl -V' so someone with a similar platform can
investigate?

-- 
Roderick Schertler
roderick@argon.org


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

Date: Fri, 07 Mar 1997 10:19:23 -0600
From: Jim Garrison <jhg@austx.tandem.com>
To: Roderick Schertler <roderick@argon.org>
Subject: Re: BUG? Please explain this behavior
Message-Id: <3320400B.167E@austx.tandem.com>

I have had a response from someone else reporting that
this behaves correctly in the 5.004 upcoming release.

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


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

Date: 07 Mar 1997 15:13:17 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: tedder@e-zone.e-z.net (Ted Timmons)
Subject: Re: Chopping lines?
Message-Id: <JFRIEDL.97Mar8001317@tubby.nff.ncl.omron.co.jp>


[mail and post]

Ted Timmons <tedder@e-zone.e-z.net> wrote:
|> I'd like to chop long lines so that they are around 70 characters. I
|> don't need to worry about long/short line pairs (from having, say,
|> 90-character lines) because of the application.
|> 
|> Right now, I'm using something like this:
|> 
|> $data equals some long string
|> $data1 = substr ($data,0,70);
|> $data = substr ($data, 70);
|> print out $data1, start over (more or less)
|> 
|> The problem is it doesn't chop on word breaks.

How about this:
	1) cut off the string to 1 over the maximum width you want.
	2) remove any trailing non-word (and any partial word as well).
	   Since what's left is 1 character more than you want, any ending
	   \w means that a 2nd-to-the-end \w is ``partial''.

I.e.:

    $width = 70;
    while (<>) {
	chomp;

	## deal with tab->spaces here if you want

	if (length > $width) {
	    substr($_, $width+1) = '';
	    s/\W+\w*$//;
	}
	print "$_\n";
    }

The regex is pretty inefficient. In fact, I'd bet that
	$_ = reverse $_;
	s/^\w*\W+//;
	$_ = reverse $_;
would be a fair bit faster
(along the lines of an Andrew Johnson post earlier in the week).

	Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@ora.com> Omron Corp, Nagaokakyo, Kyoto 617 Japan
O'Reilly & Associates' _Mastering Regular Expressions_
                                   http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: Fri, 07 Mar 1997 11:11:45 -0500
From: Joe Moore <joemoore@att.com>
To: Ted Timmons <tedder@e-zone.e-z.net>
Subject: Re: Chopping lines?
Message-Id: <33203E41.4378@att.com>

Ted Timmons wrote:
> 
> I'd like to chop long lines so that they are around 70 characters. I
> don't need to worry about long/short line pairs (from having, say,
> 90-character lines) because of the application.
> 
> Right now, I'm using something like this:
> 
> $data equals some long string
> $data1 = substr ($data,0,70);
> $data = substr ($data, 70);
> print out $data1, start over (more or less)
> 
> The problem is it doesn't chop on word breaks. I've tried using a regexp
> with s/.*\W(\w+)/$1/; and several other combinations, but it doesn't
> like non-alphanumerics, like (, #, and more. Does anyone have any
> suggestions?

# $data = long string
while (length $data > 70) {
	if ($data =~ /^(.{1,70})\s/) {
		#matches first 1-70 chars followed by a space
		$data1 = $1; #match inside parens
		$data = $';  #everything after the match
	} else {
		#word bigger than 70
		print substr($data,0,70),"\n";
		$data = substr($data,70);
	}
	print "$data1\n";
}
print "$data\n";

-- 
Joe Moore
joemoore@att.com


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

Date: 7 Mar 1997 07:11:25 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Comm.pl vers 1.6
Message-Id: <5fp0ld$6cg@panix.com>

In <5fmdma$3k1@chemistry.ohio-state.edu> jnielsen@chemistry.mps.ohio-state.edu (John Nielsen) writes:

>I have been switching my tcl based expect code to perl using Comm.pl (I wish
>I would have known this existed earlier, perl is much nicer than tcl for
>my purposes). 

>Eric Arnold recently posted a Comm.pl example using version 1.6, but
>I can't find that version on CPAN anywhere. And the ftp site:
>ftp://ftp.sterling.com/programming/languages/perl/authors/Eric_Arnold
>refuses connection.

>Is there somewhere else I should be looking?

It looks like CPAN only has Comm.pl-1.3beta.tar.gz at:

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

and Comm.pl-1.5beta.tar.gz at:

    http://www.perl.com/CPAN/modules/by-module/Comm.pl/ERICA/
    http://www.perl.com/CPAN/authors/Eric_Arnold/

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: Fri, 07 Mar 1997 08:58:02 -0500
From: Jean-Yves Levesque <jyves@nortel.ca>
Subject: Generate Makefile and execute it from PERL
Message-Id: <33201EEA.7CE7@nortel.ca>

I am trying to generate a Makefile from PERL.
At the end of my perl script, I try to run make depend
as in the following:

	my $x=("gmake depend);

But it returns 'no such file or directory'. I close my
makefile before calling make depend. Is there something
I am missing or am I trying to do something that cannot 
be done?

Thanks,

Jean-Yves.

-- 
Jean-Yves Levesque (jyves@nortel.ca)	| Idea expressed belong to the
Nortel 					| owner and not to the company
P.O. Box 3511, Station C
Ottawa, Canada  K1Y 4H7


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

Date: 7 Mar 1997 13:24:48 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: HELP!?! - Perl from UNIX shell???
Message-Id: <5fp4v0$n3v@dismay.ucs.indiana.edu>

	Check your PATH.  "." may not be in there.  If its not, you can add
it, or run your script as "./menu.cgi"

Brian

In article <331fe632.3140332@news-the.forthnet.gr>,
	steve@alexandros.cperi.forth.gr (Steve) writes:
>A simple question I hope - but I can't even get a basic PERL script or
>CGI to run from any UNIX shell. If I type in for example menu.cgi or
>menu at the prompt it would return menu.cgi - Command not found.
>I know the program works because it runs ok from within webpages.
>Thanks in advance.
>Steve

-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: Fri, 7 Mar 1997 16:15:36 GMT
From: jim_shi@franklin.com
Subject: help: add a package to perl
Message-Id: <5fpgdm$rru@hideout.emanon.net>

Hi, I want add a package to perl.
the package is very simple:

package Frk;
 
require Exporter;
require DynaLoader;
 
@ISA = qw(Exporter DynaLoader);
 
@EXPORT = qw(gencmp);
 
bootstrap Frk;
 
 
1;



I add to ext directory. When I recompile the perl source code,
every thing is fine, excpet when linking, it says:

gcc-2.7.2.1    -o perl perlmain.o libperl.a lib/auto/DynaLoader/DynaLoader.a lib/auto/Frk/Frk.a `cat ext.libs` -lnsl -ldbm -ldl -lm -lc -lposix
collect2: ld returned 2 exit status
ld: Undefined symbol 
   _boot_Frk 
*** Error code 1
make: Fatal error: Command failed for target `perl'



what is "_boot_Frk" ? 

thanks.

jim_shi@franklin.com



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

Date: 07 Mar 1997 14:06:30 +0000
From: Tim Wilson 6093 <tim.wilson@cambridge.simoco.com>
Subject: How can I find cause of bloated memory consumption in large Perl program?
Message-Id: <pybu8vdcex.fsf@cambridge.simoco.com>

We have written a compiler[1] in O-O Perl 5; it contains about 20-30,000
executable lines in a few dozen packages.

On smaller inputs it is fine, but on larger source files it consumes
huge amounts of memory -- eg about 400MB to compile a 6000 line module.

 * How can I find out what is causing this bloated memory consumption?

 * Are there any Perl constructs that use surprisingly large amounts of
   memory, or that create garbage?

(According to my UNIVERSAL::DESTROY function, all my objects have been
deallocated before the global destuction phase of garbage collection,
so I infer I have not created any circular data structures.  (See p300
of the Perl5 book.))

Tim

[1] For the curious, it compiles Shlaer-Mellor Object-Oriented
Analysis and Kennedy Carter ASL (process language) into ANSI C.


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

Date: 7 Mar 1997 07:13:04 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Interactive drawing alternatives in perl?
Message-Id: <5fp0og$6gj@panix.com>

In <Pine.SOL.3.91.970306095845.25345A-100000@Helios.goldworks.com> Serge Kolgan <skolgan@Helios.goldworks.com> writes:

>was looking for some light-weight (not perl/Tk) package in perl(5) which 
>allows to draw graphics primitives on the screen interactively, nothing 
>is available on CPAN AFAIK...
>any idea if there's such a beast?

Take a peek at the "Graphics" section of Perl Reference:
 
   http://www.panix.com/~clay/perl/query.cgi?graphics+index

-- 
Clay Irving                                        See the happy moron,
clay@panix.com                                     He doesn't give a damn,
http://www.panix.com/~clay                         I wish I were a moron,
                                                   My God! Perhaps I am!


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

Date: 7 Mar 1997 14:49:30 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: keys() on a map() fails. Why?
Message-Id: <slrn5i0ahd.mso.dave@fast.thomases.com>

On 6 Mar 1997 19:55:06 GMT, Nik Clayton <nik@coconut.blueberry.co.uk> wrote:
> How do,
> 
> I'm trying to use the map() func to build an assoc. array, and then use the
> keys() function to get the keys from this array.
> 
> This works fine if I use a temporary variable to hold the hash, but not
> if I try and use keys() directly on the output of map().
> 
> Why?

Because the result of a 'map' is a list. When you assign a list to a hash
variable, it assumes that it contains alternating key/value pairs. However,
this list is still a list.

'keys' only works with hashes, so when presented with a list (or in this cae
a map iterator generating a list), it gives up.

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 7 Mar 1997 15:06:03 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Multiline Strings into a List/Array
Message-Id: <5fpasr$ic3@fridge-nf0.shore.net>

Alex Schajer (schajer@dircon.co.uk) wrote:

: I've created a variable that contains a web page (LWP library). However
: I want to be able to follow the links on that page and retrieve the next
: set of pages.

In this case, you'll need a regexp to parse the <A HREF>s for you.

Something like:

$link =~ /http[^">]*/; This matches all instances of http;//.../doc..../
                       to (but not including) the ">

Then you can use $& to extract the matches.

OR use HTML::LnkExtor (from the LWP modules) and grab all the hrefs.

Hope this helps!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 7 Mar 1997 16:27:20 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: need some help here
Message-Id: <5fpfl8$b0v@lyra.csx.cam.ac.uk>

In article <331C22FE.5E180FA4@ajs.com>, Aaron Sherman  <ajs@ajs.com> wrote:
>
>Or, if your fields can be empty, you will need to:
>
>	($lname, ...) = split(/ \t/,$_);

Probably not what you mean.   The fields are unlikely to be delimited by
space-followed-by-tab.    Presumably you meant  (also untested :-)

        ($lname, ...) = split(/[ \t]/,$_);

or

        ($lname, ...) = split(/\s/,$_);


Mike Guy


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

Date: Fri, 7 Mar 1997 11:59:43 -0400
From: Chowder <q0c73@unb.ca>
Subject: Opening files in subdirectories
Message-Id: <Pine.SUN.3.95.970307115451.7474A-100000@jupiter>

I'm writing a script the will handle a number of files, which the script
will create. I know it's a simple question but how do I open a file for
output and specify which sub directory it is in. This will be used os a
CGI script and I want to send certain files to certain directories. I am
using the win32 port of perl 5.003. 

I tried 

open (file1, ">/stuff/$filename")

but it didn't work.

an e-mail response would be greatly appreciated as I will get it faster.

Thank you

q0c73@unb.ca

The Chowder King



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

Date: 7 Mar 1997 14:58:45 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl Basic ( DOS/Win)
Message-Id: <5fpaf5$ic3@fridge-nf0.shore.net>

Sun Tong (tsun@fs.com) wrote:

: I am new to perl but I want to learn and use it very much. I've got
: several questions. First let me say I've done my best to solve them and
: they are not silly questions. For:

Where on earth did you get that version of Win32 Perl?  :-)  It looks like
the normal installation process, but if I recall, the installation process
doesn't break like that.

You'll have better luck if you try the lastest beta port available at:
http://www.activeware.com.  Make sure you get the intel binary, NOT the
source and NOT PerlScript.  I suspect that your results will be more 
desirable. :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 7 Mar 1997 13:08:12 GMT
From: gerben@localhost.cs.vu.nl (Gerben Vos)
Subject: Re: Perl/Win32 seems to choke on high bits
Message-Id: <5fp3vs$a1t@star.cs.vu.nl>

"Mark A. Mandel" <mark@dragonsys.com> writes:

>	$pr =~ tr/blahblahblah/okayokayokay/g;

tr doesn't take a /g modifier. Just leave it off, and all will be okay.

 . . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n   V o s   <><
mailto:gerben@cs.vu.nl                           http://www.cs.vu.nl/%7Egerben/
Ceci n'est pas une .signature .


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

Date: Fri, 07 Mar 1997 13:11:07 +0100
From: David Syer <syer@mpa-garching.mpg.de>
To: "William J. Sandman" <wjsand01@starbase.spd.louisville.edu>
Subject: Re: Possible bug in regular expression form /\d{x,x}/
Message-Id: <332005DB.167E@mpa-garching.mpg.de>

William J. Sandman wrote:
> if( $dog =~ /\d{5,5}/)
      ^ typo in original?
> 
> When $dog is less that 5 digits the if evaluates to false. Since the
> upper limit is also 5. If there are more that 5 digits the if SHOULD
> evaluate to false. 

should it?  My interpretation of the rule is that at least 5 digits must
be found, and up to 5 will be matched.  Thus if you did s/\d{5,5}/foo/
it would replace the first five digits with "foo".  And in \d{5,6} at
least 5 must be found and up to 6 will be matched, so 
s/\d{5,6}/foo/ will replace the first five if there are only five and
the first six if there are more.

> In my applications it is evaluating to true in cases
> where the upper limit (second value is either the same as the first of if
> different.
> 

Huh?  More typos?

Dave.


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

Date: 7 Mar 1997 16:29:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Possible bug in regular expression form /\d{x,x}/
Message-Id: <5fpfq1$mjb$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "William J. Sandman" <wjsand01@starbase.spd.louisville.edu> writes:
:Greetings,
:
:	I may have found a bug (or then again it could be pilot error)
:
:When I implement a regular expression evaluation of the form:
:
:	if( @dog =~ /\d{5,5}/){

Don't put the @dog there.

:		do stuff
:	}
:
:	where dog is $dog = 12345; the if evaluates to true.
:
:When $dog is less that 5 digits the if evaluates to false. Since the 
:upper limit is also 5. If there are more that 5 digits the if SHOULD 
:evaluate to false.

Oh no it won't.   

    "This phrase has a 186282.42 +/- 0.06 mps to go." =~ /\d{5,5}/

is true.  There is a point at which no more nor no fewer than five
digits occur.  Actually, there are two such points.

Anchors would alter this: /^\d{5}$/

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
In general, if you think something isn't in Perl, try it out, because it
usually is.  :-)
        --Larry Wall in <1991Jul31.174523.9447@netlabs.com>


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

Date: Fri, 07 Mar 1997 12:48:33 +0000
From: Douglas Seay <seay@absyss.fr>
Subject: Re: Reading from a file in an array arbitrary ????
Message-Id: <33200EA1.623D@absyss.fr>

R. Evers wrote:
> 
> Hi guys,
> 
> I have a question (like everyone who posts to this newsgroup)....
> I want to read a file into an array.
> The problem is:
> I don't want to read all, just a few lines from the file.
> 
> To clear the problem, the usual codes to read a file into an array will be:
> open (FILE, "$FileName");
> @FileArray = <FILE>;
> close(FILE);
> 
> The above is what I usual do. However it will be a problem if I want to
> read a file that contains more than 5000 lines. Imagines how big the array
> is.
> 

open (FILE, "$FileName");
while ( $tmp = <FILE> )
	{
	$line++;
	next if ( $line < $minimum );
	last if ( $line > $maximum );
	push(@FileArray, $tmp);
	}
close(FILE);

or using standard tools

@FileArray = `tail -n +$start $filename | head -$length`;


> The question: Do you know how to see how many lines a file contains ????
>         OR
> Anyone knows a better way ?????


as for how man lines there are in a file, `wc -l` does that
for you.  you can count "\n"s (via read() or <>) but Unix
already has a nice tool box of little utilities, I'd rather
re-use someone else's wheel.


if your usually code

@list = <FILE>;
foreach ( @list )
	{ ; }

just to do line by line processing of a file, I'd say that
you have forgotten about simple while loops.

while ( <FILE> )
	{
	# the line is in $_
	}

doesn't build a huge list and still lets you iterate
over each line.


doug seay
seay@absyss.fr


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

Date: Fri, 7 Mar 1997 06:42:12 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Regexp: Search outside of HTML tags
Message-Id: <4f2pf5.om.ln@localhost>

Bjorn Furuknap (furu@infonett.hm.no) wrote:

: I want to make a searchengine to search HTML-files for a scalar. I don't
: want, though, to search inside of any HTML-tags, but I have not been
: successful in achieving this. 

: I have the searchengine. I need a regexp to exclude tags, but include
: non-tag 'hits'.

: Example 1: Search for 'basketball' SHOULD NOT succeed:
: <HTML><HEAD><TITLE>Sportspages</TITLE></HEAD>
: <BODY BACKGROUND="/basketball/backgr.gif">
: <IMG SRC="/basketball/over.gif"><BR>
: </BODY></HTML>

: Example 2: Search for 'basketball' SHOULD succeed:
: <HTML><HEAD><TITLE>Sportspages</TITLE></HEAD>
: <BODY BACKGROUND="/basketball/backgr.gif">
: <H1>Basketball</H1>                           <-- Because of this line
: </BODY></HTML>


Here is a very simple-minded way, it works only in most (not all) cases
though (UNTESTED):

s/<[^>]*>//g;                        # delete all the tags
print "Matched\n" if /basketball/i;  # search everything that's left


: Anyone who understands my question?

I think so.

: Thank you all in advance.

You're welcome.

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Fri, 07 Mar 1997 08:49:32 -0800
From: Michael Stearns <mstearns@darkwing.uoregon.edu>
Subject: releasing socket connections
Message-Id: <3320471C.7E8C12A0@darkwing.uoregon.edu>

I am trying to learn about sockets. I have a listen script (shown below)
and a connect script that is quite similar. I can open the listen
connection once and have the connect script talk succesfully to it, but
when I try to run the listen script again, I get a "Can't Bind" message.
This situation continues for several more minutes, until, finally, I can
open the connection again and it works fine.

What am I missing here about working with and releasing the port?

THanks,
Michael Stearns

 *****

#!/usr/local/bin/perl

require 5.002;
use Socket;


$line = "Hay ay\n";

$port = 2000;

while (getservbyport ($port, "tcp")) {
$port++;
}

($d1, $d2, $prototype) = getprotobyname ("tcp");

($d1, $d2, $d3, $d4, $rawserver) = gethostbyname ("darkwing");

$serveraddr = pack ("Sna4x8", 2, $port, $rawserver);
socket (SSOCKET, PF_INET, SOCK_STREAM, $prototype) || die ("no socket");
bind (SSOCKET, $serveraddr) || die ("Can't bind");
listen (SSOCKET, 1) || die ("Can't Listen");
($clientaddr = accept (SOCKET, SSOCKET)) || die ("Can't accept");
select (SOCKET);
$| = 1;
print SOCKET ("$line  $port\n");
close (SOCKET);
close (SSOCKET);


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

Date: 07 Mar 1997 14:05:22 +0100
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: Semantics of hashes and NIS+ combined... what to do?
Message-Id: <yfmsp27q2ct.ulp@ls6.informatik.uni-dortmund.de>


>>>>> "Philip" == Philip A Prindeville <philipp@ntex.com> writes:

    Philip> Hi.

    Philip> I'm writing a tied hash module to work with the NISPlus-0.05
    Philip> package for use with certain NIS+ maps like group, passwd, etc.

    Philip> In some of these maps, it is possible to have multiple
    Philip> entries with the same search key.

    Philip> My question is how does this affect the semantics of a hashed
    Philip> array?  Can "keys" return the same key more than once?

No problem with ths. Check DB_File/BTREE. It does allow for duplicate
keys also.

    Philip> And when one does a delete, which entry does it delete?
    Philip> The oldest?  All of them?

Since you write the function (if I got it right), you decide what the
semantics are.

    Philip> I'm stumped as to what The Right Thing To Do is.

I'd propose to use the first key unless the iterator already points to
a matching key. This would allow to implement all possible semantics
ontop.

    Philip> Any help appreciated.  Please reply directly.

Hey. This is a NG - not a helpdesk.

Ulrich Pfeifer
--
@J = split //,"J!k Phau^eHeens%rarrot&\ncl t ";
for(0..24){print $J[$_*7%($#J+1)]


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

Date: 7 Mar 1997 16:00:44 GMT
From: gerben@cs.vu.nl (Gerben Vos)
Subject: SIGPIPE in LWP::Socket::connect on Solaris 2.5.1
Message-Id: <5fpe3c$f6j@star.cs.vu.nl>

Using Randal's WWW tree checking script (at
http://www.stonehenge.com/merlyn/WebTechniques/col07.listing.txt), i got a
SIGPIPE error on a call to LWP::Socket::connect, when that function calls
perl's builtin connect.

It doesn't always happen, but it does for example when fetching
http://www.cs.cmu.edu:8001/afs/cs.cmu.edu/user/jimz/www/the.html .
It also happens when using other programs that use LWP, such as the HEAD
program that comes with it.

www.cs.cmu.edu happens to have two IP addresses, and the connect call to
the first one fails, then the connect to the second one gives a SIGPIPE.
It seems to work OK for any site on which the first IP address succeeds.

Have i misconfigured something, or is this a bug in LWP or in perl?
Or else is there a convenient way to catch SIGPIPE and continue processing
the next URL? Pointers to documentation are OK.


uname -a gives:
  SunOS keg 5.5.1 Generic_103640-03 sun4u sparc SUNW,Ultra-2


perl stack backtrace:
#0  0xef5b8f40 in _libc_sigprocmask ()
#1  0xef789d28 in _connect2 ()
#2  0xef789c20 in __connect ()
#3  0xef789a48 in _connect ()
#4  0x7758c in Perl_pp_connect ()
#5  0x4f0bc in Perl_runops ()
#6  0x1e16c in perl_run ()
#7  0x1cf18 in main ()


Site configuration information for perl 5.003:

Configured by gerben at Fri Jan 17 16:57:37 MET 1997.

Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
  Platform:
    osname=solaris, osver=2.5.1, archname=sun4-solaris
    uname='sunos keg 5.5.1 generic_103640-03 sun4u sparc sunw,ultra-2 '
    hint=recommended, useposix=true, d_sigaction=define
  Compiler:
    cc='cc', optimize='-O4', gccversion=2.7.2
    cppflags='-I/usr/local/include -I/opt/local/include -DDEBUGGING'
    ccflags ='-I/usr/local/include -I/opt/local/include -DDEBUGGING'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, randbits=15
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib -L/opt/local/lib -L/opt/gnu/lib'
    libpth=/usr/local/lib /opt/local/lib /opt/gnu/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -lgdbm -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib -L/opt/local/lib -L/opt/gnu/lib'

I am an avid fan of email copies of answers, so please send me one.
I do read this newsgroup, however, so just posting is also OK.

 . . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n   V o s   <><
mailto:gerben@cs.vu.nl                           http://www.cs.vu.nl/%7Egerben/
Ceci n'est pas une .signature .


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

Date: Fri, 7 Mar 1997 13:30:36 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Simple tr///
Message-Id: <ebohlmanE6oDJ0.B9z@netcom.com>

Dave Thomas (dave@fast.thomases.com) wrote:
:    perl -p -e 's/(.)\010\1/$1/g' <man >man.clean

: Unfortunately you can't use \b for backspace in a regex - it changes meaning
: from 'backspace' in strings to 'word boundary' in regexs.

But not in a character class, so you could write 's/(.)[\b]\1/$1/g' which 
would be a little more readable.



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

Date: 07 Mar 1997 13:56:48 +0100
From: Ulrich Pfeifer <pfeifer@ls6.informatik.uni-dortmund.de>
Subject: Re: Socket/Spawn problems under Solaris - could someone test this for me?
Message-Id: <yfmu3mnq2r3.ulp@ls6.informatik.uni-dortmund.de>


>>>>> "Gideon" == Gideon King <gideon@csarc.otago.ac.nz> writes:

    Gideon> I'm having problems with perl sockets on a Solaris machine
    Gideon> (I have tested it on other unix machines and it works). I
    Gideon> have narrowed is down to using simple example code
    Gideon> available on the web. I have a Client process and a Server
    Gideon> process. The client connects to the server, and returns
    Gideon> the local time from the server. The bug exhibits itself
    Gideon> whether you connect locally or from a remote host.

The problem ist that on solaris the SIGCHLD interrupts the accept()
call. Look at the loop conditions you use. You will see that some
connections are lost.

Ulrich Pfeifer
--
@J = split //,"J!k Phau^eHeens%rarrot&\ncl t ";
for(0..24){print $J[$_*7%($#J+1)]


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

Date: 7 Mar 1997 14:59:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: SSI with PERL and win95/NT
Message-Id: <5fpahd$ic3@fridge-nf0.shore.net>

Vidar Markussen d2b (vidar5@tott.hibu.no) wrote:
: How do you implement Server Side Include in a script 
: on a WIN95 server?

Yes.

: Can you do something with Content-type?

Yes, but this is comp.lang.perl.misc, which has *nothing* to do with
webservers, or hit counters.  You might try: comp.infosystems.www.servers.misc

Good luck!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Fri, 07 Mar 1997 10:01:20 -0500
From: Joe Moore <joemoore@att.com>
Subject: Trapping Segmentation Fault
Message-Id: <33202DC0.76E0@att.com>

I have a program that uses an eval block to execute some code.
The program dumps core with a segmentation fault, but $@ is
not set.  Why not?  Is there a way to catch all faults so I can
exit gracefully instead of dumping core?
-- 
Joe Moore
joemoore@att.com


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

Date: Thu, 06 Mar 1997 23:32:22 -0600
From: woutlet@worldnet.att.net
Subject: Web Hosting Solutions
Message-Id: <857712543.23198@dejanews.com>

	Wolrd Outlet Inc. (http://www.worldoutlet.com)


$39.95 per month.  Quality Web Hosting for Your Business:
www.your_company.com  (see http://www.wolrdoutlet.com)

It is now easier to set your company apart from the rest with your own
domain name. For $39.95 per month and a one time setup fee of $99.00*,
your account will have full email capabilities (you@your_company.com)
and a URL such as "www.your_company.com", as well as all of the
following:

- FREE SUBMISSIONS TO TOP 150 SEARCH ENGINES AND DIRECTORIES

- Domain name registration provided (www.your_company.com)
- Unlimited Email accounts included (you@your_company.com)
- Unlimited e-mail traffic
- 24 hour unlimited updates via your own FTP/TELNET account
- Secure user accounts for the customer to perform content updates
- 500 MB of data transfer per month
- 20 MB of disk space for your html documents & graphics
- Detailed Web usage statistics & access to raw log files
- T1 line to the Internet used exclusively for Web site hosting
- Physically secure facility
- 7x24 Operation with full tape backup capability
- Assisted custom CGI script support
- Support for FrontPage, Perl, Java, and ActiveX
- Video support - AVI, MPEG, QuickTime, SGI and Microsoft Video
- Audio support - WAV and AIFF Audio (RealAudio available)
- Hosted on Sun Microsystems Ultra Servers



All of these for only $39.95 per month!

* THERE IS NO FEE FOR TRANSFERRING AN EXISTING DOMAIN NAME


ADDITIONAL SERVICES:
* Webmaster Service (unlimited/changes & programming)
* Directory Listing Service (search engines & directories)
* Web Site Design & Development
* CGI & Java Programming
* Custom Graphics & Scanning
* Full Commerce Solution
  - Shopping Cart Technology
  - Process credit cards and payments in real-time
  - Control on-line inventory in real-time
  - Remotely Access and update product databases
* Server Solutions (co-location)
  - your own server located at our facility
  - the perfect solution for resellers
  - we can custom build hardware at tremendous savings
* Direct Internet Connections (56K to T-1 Frame Relay)

To see more visit our web site at:

http://www.worldoutlet.com

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


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

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

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