[16852] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4264 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 8 18:07:48 2000

Date: Fri, 8 Sep 2000 15:05:27 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968450726-v9-i4264@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 8 Sep 2000     Volume: 9 Number: 4264

Today's topics:
    Re: [Q] Matching newlines using . and /s <apandey@u.washington.edu>
    Re: [Q] Matching newlines using . and /s <lr@hpl.hp.com>
    Re: ActivePerl 617 cannot be opened by Windows-Installe <jeffrey.l.susanj@boeing.com>
    Re: Algorithm for data recognition (Logan Shaw)
    Re: Changing ALL leading blanks to zero <markmccarthy1@home.com>
    Re: Changing ALL leading blanks to zero <care227@attglobal.net>
    Re: Changing ALL leading blanks to zero (David H. Adler)
        Commercial websites using perl <schaefer@zanshin.com>
    Re: Date question?  Can't display English style? <flavell@mail.cern.ch>
        Does PERL(Version 5.005 or greater) supports UNIX_SV (N <zyang@emc.com>
    Re: Environment variables - how to list them all? <lr@hpl.hp.com>
    Re: Environment variables - how to list them all? <godzilla@stomp.stomp.tokyo>
    Re: Environment variables - how to list them all? (Charles DeRykus)
    Re: Environment variables - how to list them all? (Craig Berry)
    Re: file creation time ? <lr@hpl.hp.com>
    Re: flush the buffer before closing the <aqumsieh@hyperchip.com>
    Re: flush the buffer before closing the <lr@hpl.hp.com>
    Re: flush the buffer before closing the (Abigail)
    Re: flush the buffer before closing the <tina@streetmail.com>
    Re: flush the buffer before closing the <lr@hpl.hp.com>
    Re: flush the buffer before closing the <lr@hpl.hp.com>
    Re: how can I tell the internet speed of visitor (Logan Shaw)
    Re: how can I tell the internet speed of visitor (Craig Berry)
    Re: how can I tell the internet speed of visitor <flavell@mail.cern.ch>
    Re: how can I tell the internet speed of visitor (Craig Berry)
    Re: How long does flock take? (Chris Fedde)
    Re: How to delete line #1 (Abigail)
    Re: How to delete line #1 <yanick@babyl.sympatico.ca>
    Re: How to delete line #1 <lr@hpl.hp.com>
    Re: How to delete line #1 <stevea@wrq.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 8 Sep 2000 12:02:24 -0700
From: Anshuman Pandey <apandey@u.washington.edu>
Subject: Re: [Q] Matching newlines using . and /s
Message-Id: <Pine.A41.4.21.0009081152460.83694-100000@vergil01.u.washington.edu>


Thank you Steven Kloder and Larry Rosler for your tips. Reading in the
entire file instead of line-by-line or in paragraph mode works.

Steven writes the following:

> You are reading the file one line at a time before applying the
> transformation.  If you want to match regexes across multiple lines, read the
> entire file into one string, or use a different delimeter.  I recommend:
>
> local $/ = undef;        # slurp mode (perldoc perlvar)
> $_=<>;
> s/\{\\macro (.*?)\}/transform()/gse;
> print;

In my code I have the s/// function embedded in a while() loop. I notice
here that you obviate the need for while() by reading the entire file into
$_. 

If I use the original while() loop I get the same desired result:

  local $/ = undef;
  while (<>) {
    s/\{\\macro (.*?)\}/transform()/gse;
    print;
  }

Is there a disadvantage in using while() vs. $_=<>;

Thank you.

Regards,
Anshu




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

Date: Fri, 8 Sep 2000 13:32:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [Q] Matching newlines using . and /s
Message-Id: <MPG.1422ecbcc5241deb98ad47@nntp.hpl.hp.com>

In article <Pine.A41.4.21.0009081152460.83694-
100000@vergil01.u.washington.edu> on Fri, 8 Sep 2000 12:02:24 -0700, 
Anshuman Pandey <apandey@u.washington.edu> says...

 ...

> Steven writes the following:

 ...

> > local $/ = undef;        # slurp mode (perldoc perlvar)
> > $_=<>;
> > s/\{\\macro (.*?)\}/transform()/gse;
> > print;
> 
> In my code I have the s/// function embedded in a while() loop. I notice
> here that you obviate the need for while() by reading the entire file into
> $_. 
> 
> If I use the original while() loop I get the same desired result:
> 
>   local $/ = undef;
>   while (<>) {
>     s/\{\\macro (.*?)\}/transform()/gse;
>     print;
>   }
> 
> Is there a disadvantage in using while() vs. $_=<>;

Yes.  It doesn't say what you mean.

Using while() gives the impression of a loop, even though the loop body 
is executed only once.

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


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

Date: Fri, 8 Sep 2000 19:14:25 GMT
From: "Jeff Susanj" <jeffrey.l.susanj@boeing.com>
Subject: Re: ActivePerl 617 cannot be opened by Windows-Installer
Message-Id: <G0L1G4.1Ct@news.boeing.com>

Alexandra Schubert wrote in message
<20000908131827.11213.qmail@gacracker.org>...
>I wish to run Perl under Windows NT 4.0. In this NG ActivePerl was
>recommended by several people.
>I downloaded the Windows Installer the windows version of Active Perl.
>
>ActivePerl-5.6.0.617-MSWin32-x86-multi-thread.msi
>
>My Windows Installer gives an error message when trying to open the
>packet. I downloaded it 3 times, but still the same result.
>
>Anyone out there who had the same problem? Solution?
>
>--
>Thx, Alexa
>
>

It might be helpful to know what the error message was.  When installing
build 616 of ActiveState's perl I needed to upgrade my version of the
Microsoft installer first.  It then installed OK.


Jeff S.






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

Date: 8 Sep 2000 13:28:49 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Algorithm for data recognition
Message-Id: <8pbb51$gfh$1@provolone.cs.utexas.edu>

In article <39B86373.9D87996B@home.com>,
Andrew Robinson  <awrobinson@home.com> wrote:
>Logan, I've pretty much done everything you suggested through traversing the
>mime parts. At this point, I'm checking the data in each parts returned from
>the mime traversal. I'm trying to distinguish between the "real" data and
>things like signatures.

Well, one of the MIME modules has a remove_sig() (or something like
that) subroutine.  Does that do what you want?  If not, it might help
to explain a little more what you want.  I mean, it's all "real" data.
Some of it is just data you don't want.  But you need to define more
clearly what data you do want and what data you don't.  Perhaps if you
gave a few examples that would help.

>As for wrapping, I'm afraid if the content type of the attachment is text,
>the records could still get wrapped. Am I worrying about something I don't
>need to worry about?

Wrapped as in word-wrapped?  If so, then that's the data.  If you want
to reformat a block of text to make it prettier, you can do that, but
usually mail/news text is just left as-is.  If somebody's mail program
formatted it badly, then that's life.

  - Logan


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

Date: Fri, 08 Sep 2000 19:44:49 GMT
From: "Mark McCarthy" <markmccarthy1@home.com>
Subject: Re: Changing ALL leading blanks to zero
Message-Id: <Rkbu5.63670$xg1.599114@news1.rdc1.sdca.home.com>


"Tom Christiansen" <tchrist@perl.com>

> while (/\G,?(\d+)/g) {
>     print "Found number $1\n";
> }

If I try this example without \G, I get the same answer!

(I chose $_="3,4,5,9,120"; as was suggested )


So whats the benefit of  \G here?

Mark


>
> --tom, whose apparent presence here is merely a transitory figment




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

Date: 08 Sep 2000 20:10:51 GMT
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Changing ALL leading blanks to zero
Message-Id: <39B94562.38AC7493@attglobal.net>

Tom Christiansen wrote:
> 
> --tom, whose apparent presence here is merely a transitory figment


Thats a shame if its true.


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

Date: 8 Sep 2000 21:57:18 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Changing ALL leading blanks to zero
Message-Id: <slrn8rio5u.ka2.dha@panix6.panix.com>

On Fri, 8 Sep 2000 09:10:14 -0400, Jeff Pinyan <jeffp@crusoe.net> wrote:
>[posted & mailed]
>
>On Sep 8, William Cardwell said:
>
>>$x='   ';
>>$x=~s/^ +/0/;
>>$y='  5';
>>$y=~s/^ +/0/;
>>print "$x, $y\n"; # I want: "000, 005". I'm getting "0, 05".
>
>Randal Schwartz answered this a couple years back with:
>
>  s/\G /0/g;
>
>Your approach changes all leading spaces to one 0.  His replaces each
>leading space with a 0.

Or, if you *really* want to do it in a way similar to what you were
doing,

tr/ /0/;

will change all your spaces to 0s.  Of course, this won't work if you
have spaces later in the string that you *don't* want to change...

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
He looked like Elvis '75 - Puffed up but still alive
	- The Merrymakers, "Superstar"


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

Date: Fri, 8 Sep 2000 14:05:15 -0700
From: Bart Schaefer <schaefer@zanshin.com>
Subject: Commercial websites using perl
Message-Id: <Pine.LNX.4.20.0009081355070.9810-100000@aztec.zanshin.com>

I'd like to identify some commercial websites that are using perl as their
"web application server" -- as opposed to Microsoft SiteServer, WebLogic,
Dynamo, BroadVision, StoryServer, XPedio, etc. etc.

I'm trying to disprove the assertion that "only hobbyist sites use perl."

Please email me even if you also post; I read the newsgroup, but our ISP's
newsfeed is spotty at times.



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

Date: Fri, 8 Sep 2000 20:08:05 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Date question?  Can't display English style?
Message-Id: <Pine.GHP.4.21.0009082007320.24353-100000@hpplus03.cern.ch>

On Fri, 8 Sep 2000, Larry Rosler wrote:

> I was just observing the precipitous decline here in Y2K-related 
> 'problems'.  But here we go again!

Well, I'd call them RTFM-related problems...

cheers



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

Date: Fri, 8 Sep 2000 17:29:43 -0400
From: "api" <zyang@emc.com>
Subject: Does PERL(Version 5.005 or greater) supports UNIX_SV (NCR) platform?
Message-Id: <8pblp0$5mk1@emcnews1.lss.emc.com>

Does anyone know if PERL(Version 5.005 or greater) supports UNIX_SV (NCR)
platform?
I couldn't build perl successfully using source code.
You advice is appreciated!

~api~





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

Date: Fri, 8 Sep 2000 11:24:26 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Environment variables - how to list them all?
Message-Id: <MPG.1422ceb3f08125e698ad42@nntp.hpl.hp.com>

In article <sri9lvthljn121@corp.supernews.com> on Fri, 08 Sep 2000 
17:49:51 GMT, Craig Berry <cberry@cinenet.net> says...
> Abigail (abigail@foad.org) wrote:
> : Steve Drewell (bd83h@bedford.waii.com) wrote on MMDLXV September MCMXCIII
> : in <URL:news:1000908144212.29022I-100000@bisv3.bedford.waii.com>:
> : ** I'm new to perl and would like to know how to get a list of ALL
> : ** environment variables and their values from within a perl script.
> : ** Something equivalent to the "env" command in a c-shell is what
> : ** I'm after.
> : 
> : $ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'
> 
> Cute, but
> 
>   $ perl -we 'print "$_=$ENV{$_}\n" for keys %ENV'
> 
> seems more direct.

And much easier to sort by name. 

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


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

Date: Fri, 08 Sep 2000 14:05:16 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Environment variables - how to list them all?
Message-Id: <39B9548C.4C8975C6@stomp.stomp.tokyo>

Larry Rosler wrote:

> Craig Berry wrote:
> > Abigail wrote:
> > > Steve Drewell wrote:

> > : ** I'm new to perl and would like to know how to get a list of ALL
> > : ** environment variables and their values from within a perl script.
> > : ** Something equivalent to the "env" command in a c-shell is what
> > : ** I'm after.

> > : $ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'

> > Cute, but

> >   $ perl -we 'print "$_=$ENV{$_}\n" for keys %ENV'

> > seems more direct.
 
> And much easier to sort by name.


Speaking of cute and sort, this short script produces a
very pretty sorted output and exceptionally nice document
source for those looking to use an html interface.

Godzilla!
-- 
Bark Bent - Ace News Reporter
  http://la.znet.com/~callgirl/android/news.cgi


#!/usr/local/bin/perl

while (($key, $value) = each(%ENV)) 
 {
  $line = $key . " = " . $value;
   push(@Array, $line);
 }

@Array = sort(@Array);

print "Content-type: text/html\n\n
       <HTML><HEAD><TITLE>
       Local Environmental Variables
       </TITLE></HEAD><BODY><BR><BR>
       <FONT FACE=\"arial rounded mt bold\" SIZE=\"3\">
       CGI Environmental Variables
       <HR><PRE>\n\n";

foreach $line (@Array) 
 { print "$line \n"; }

print "
       </PRE></FONT><P><HR>
       </BODY></HTML>";

exit;


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

Date: Fri, 8 Sep 2000 20:48:08 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Environment variables - how to list them all?
Message-Id: <G0L5s8.5t5@news.boeing.com>

In article <sri9lvthljn121@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>Abigail (abigail@foad.org) wrote:
>: Steve Drewell (bd83h@bedford.waii.com) wrote on MMDLXV September MCMXCIII
>: in <URL:news:1000908144212.29022I-100000@bisv3.bedford.waii.com>:
>: ** I'm new to perl and would like to know how to get a list of ALL
>: ** environment variables and their values from within a perl script.
>: ** Something equivalent to the "env" command in a c-shell is what
>: ** I'm after.
>: 
>: $ perl -wle '$, = "="; $\ = $/; print @ENV while @ENV = each %ENV'
>
>Cute, but
>
>  $ perl -we 'print "$_=$ENV{$_}\n" for keys %ENV'
>
>seems more direct.

Or, to be short and direct :) 

perl -we 'system "env"'


--
Charles DeRykus


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

Date: Fri, 08 Sep 2000 21:57:11 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Environment variables - how to list them all?
Message-Id: <srio5nv0ljn159@corp.supernews.com>

Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: Speaking of cute and sort, this short script produces a
: very pretty sorted output and exceptionally nice document
: source for those looking to use an html interface.
: 
: while (($key, $value) = each(%ENV)) 
:  {
:   $line = $key . " = " . $value;
:    push(@Array, $line);
:  }

Okay, this packs each env var into a "name=value" string...

: @Array = sort(@Array);

 ...but there's a problem with doing the sort here.  Consider that env
variables may contain (e.g.) '-' characters, a character which
sorts lexically before '='.  If you form the full "name=value" string and
then sort the results, you end up with 'foo-bar=baz' before 'foo=quux' in
the output, which violates the usual sort order.  Better to sort the keys
and then iterate over the results.

[snip]
: foreach $line (@Array) 
:  { print "$line \n"; }

If you had added the newlines while generating the sorted strings, you
could just do

  print @Array;

here.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 8 Sep 2000 11:13:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file creation time ?
Message-Id: <MPG.1422cc37b79105d98ad41@nntp.hpl.hp.com>

In article <39b8ee78$1@cs.colorado.edu> on 8 Sep 2000 07:49:44 -0700, 
Tom Christiansen <tchrist@perl.com> says...
> In article <8papo5$k6t$1@nnrp1.deja.com>,
> Margarit Nickolov  <man@rila.bg> wrote:
> 
> >simple question: how can I get creation time of a file (not last
> >modification time(stat(file))[10]) ) ? Thanks.
> 
> Preferred mechanism to finding file-creation time:
>     1) Write your own operating system

It would be much cheaper to buy a copy of any Windows/DOS operating 
system, for example.  Ignorant of arcana such as inodes, they store 
file-creation time in the file system, and -C or (stat)[10] return that 
value.

Despite your flip answer, you (TomC) know this, but one would never know 
it from `perldoc -f -X` or `perldoc -f stat`:

    -M  Age of file in days when script started.
    -A  Same for access time.
    -C  Same for inode change time.

 10 ctime
      inode change time (NOT creation time!) in seconds since the epoch

Even perlport lies about this, by omission -- nothing under -X, and this 
under stat:

mtime and atime are the same thing, and ctime is creation time instead 
of inode change time. (Mac OS) 

device and inode are not meaningful. (Win32)

device and inode are not necessarily reliable. (VMS)

mtime, atime and ctime all return the last modification time. Device and 
inode are not necessarily reliable. (RISC OS)

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


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

Date: Fri, 08 Sep 2000 18:05:05 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: flush the buffer before closing the
Message-Id: <7almx2zrn0.fsf@merlin.hyperchip.com>


nik <nic.alagna@tiscalinet.it> writes:

>     who can tell me how to flush the buffer in a file opened in writing
> mode before closing it ?

I can.

Closing the file handle automatically flushes the buffer.

--Ala


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

Date: Fri, 8 Sep 2000 11:30:57 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: flush the buffer before closing the
Message-Id: <MPG.1422d03c27a139298ad43@nntp.hpl.hp.com>

In article <slrn8ri7v5.vlt.abigail@alexandra.foad.org> on 08 Sep 2000 
17:21:36 GMT, Abigail <abigail@foad.org> says...
> nik (nic.alagna@tiscalinet.it) wrote on MMDLXV September MCMXCIII in
> <URL:news:39B8FD4D.CD62842D@tiscalinet.it>:
> ==     who can tell me how to flush the buffer in a file opened in writing
> == mode before closing it ?
> 
>      close HANDLE or die "Failed to close file: $!";

That's rather drastic.  A seek() will also do it.

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


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

Date: 08 Sep 2000 19:20:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: flush the buffer before closing the
Message-Id: <slrn8rieug.vlt.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDLXV September MCMXCIII in
<URL:news:MPG.1422d03c27a139298ad43@nntp.hpl.hp.com>:
$$ In article <slrn8ri7v5.vlt.abigail@alexandra.foad.org> on 08 Sep 2000 
$$ 17:21:36 GMT, Abigail <abigail@foad.org> says...
$$ > nik (nic.alagna@tiscalinet.it) wrote on MMDLXV September MCMXCIII in
$$ > <URL:news:39B8FD4D.CD62842D@tiscalinet.it>:
$$ > ==     who can tell me how to flush the buffer in a file opened in writing
$$ > == mode before closing it ?
$$ > 
$$ >      close HANDLE or die "Failed to close file: $!";
$$ 
$$ That's rather drastic.  A seek() will also do it.


You didn't get the point. He wants to flush the buffers before closing it.
You might as well close right away, as that will seek the buffers. An
extra seek doesn't seem necessary.


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
__END__
A pair of kingfishers // nest in the branches of a she-oak // tree. A duck nests.


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

Date: 8 Sep 2000 19:58:25 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: flush the buffer before closing the
Message-Id: <8pbgd1$cltcd$1@ID-24002.news.cis.dfn.de>

hi,
In comp.lang.perl.misc nik <nic.alagna@tiscalinet.it> wrote:
>     who can tell me how to flush the buffer in a file opened in writing
> mode
> before closing it ?

$|=1;
select HANDLE;

HTH,
tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Fri, 8 Sep 2000 13:38:46 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: flush the buffer before closing the
Message-Id: <MPG.1422ee2f87a2250298ad49@nntp.hpl.hp.com>

In article <8pbgd1$cltcd$1@ID-24002.news.cis.dfn.de> on 8 Sep 2000 
19:58:25 GMT, Tina Mueller <tina@streetmail.com> says...
> In comp.lang.perl.misc nik <nic.alagna@tiscalinet.it> wrote:
> >     who can tell me how to flush the buffer in a file opened in writing
> > mode before closing it ?
> 
> $|=1;
> select HANDLE;

Those statements are in the wrong order.  And, as I just acknowledged, 
the question read literally has no content.

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


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

Date: Fri, 8 Sep 2000 13:36:36 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: flush the buffer before closing the
Message-Id: <MPG.1422edb31bb8ef4b98ad48@nntp.hpl.hp.com>

In article <slrn8rieug.vlt.abigail@alexandra.foad.org> on 08 Sep 2000 
19:20:43 GMT, Abigail <abigail@foad.org> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMDLXV September MCMXCIII in
> <URL:news:MPG.1422d03c27a139298ad43@nntp.hpl.hp.com>:
> $$ In article <slrn8ri7v5.vlt.abigail@alexandra.foad.org> on 08 Sep 2000 
> $$ 17:21:36 GMT, Abigail <abigail@foad.org> says...
> $$ > nik (nic.alagna@tiscalinet.it) wrote on MMDLXV September MCMXCIII in
> $$ > <URL:news:39B8FD4D.CD62842D@tiscalinet.it>:
> $$ > ==     who can tell me how to flush the buffer in a file opened in writing
> $$ > == mode before closing it ?
> $$ > 
> $$ >      close HANDLE or die "Failed to close file: $!";
> $$ 
> $$ That's rather drastic.  A seek() will also do it.
> 
> 
> You didn't get the point. He wants to flush the buffers before closing it.
> You might as well close right away, as that will seek the buffers. An
> extra seek doesn't seem necessary.

You are right.  I read 'as an alternative to closing it', not 'before 
closing it', because the latter is so bizarre, and I guess my mind was 
seek()ing some sort of rational content to the question.
  
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 8 Sep 2000 13:46:51 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <8pbc6r$gib$1@provolone.cs.utexas.edu>

In article <sri7nprsljn136@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>Denson Tang (nospam.tom@hotmail.com) wrote:
>: I want to know the internet speed connection of a website visitor, how 
>: can I achieve that we PERL?
>
>Ask them.  Seriously.  Every possible method for "sniffing" bandwidth has
>flaws so serious that it should not be used.

And asking them doesn't have flaws?  Even if the user is able to
correctly identify what device they have (assuming you have it on your
list), there's no guarantee that it's operating like they think it is
or that it's the bottleneck.

Looking at it another way, you probably don't want to know what the
speed of their connection is.  Instead, you probably want to know how
many bytes per second you can throw at them and reasonably expect them
to receive, and the only answer to that is to find out empirically and
be conservative.

  - Logan


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

Date: Fri, 08 Sep 2000 19:07:29 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <srie7h33ljn34@corp.supernews.com>

Logan Shaw (logan@cs.utexas.edu) wrote:
: In article <sri7nprsljn136@corp.supernews.com>,
: Craig Berry <cberry@cinenet.net> wrote:
: >Denson Tang (nospam.tom@hotmail.com) wrote:
: >: I want to know the internet speed connection of a website visitor, how 
: >: can I achieve that we PERL?
: >
: >Ask them.  Seriously.  Every possible method for "sniffing" bandwidth has
: >flaws so serious that it should not be used.
: 
: And asking them doesn't have flaws?  Even if the user is able to
: correctly identify what device they have (assuming you have it on your
: list), there's no guarantee that it's operating like they think it is
: or that it's the bottleneck.

Yes, but typically you're asking them so you can deliver the appropriate
version of some streaming resource.  If you ask them and they guess too
high, and the resulting stream misbehaves, they then have a clue how to
fix the problem.  If you "sniff" their connection and get it wrong,
they're out of luck.  And the out-of-luckness can manifest either as an
attempt to send a stream they actually can't receive reliably, *or*
sending them a stream which is slower than they could actually handle.

False high *and* false low readings are appallingly common in connection
speed sniffing.

: Looking at it another way, you probably don't want to know what the
: speed of their connection is.  Instead, you probably want to know how
: many bytes per second you can throw at them and reasonably expect them
: to receive, and the only answer to that is to find out empirically and
: be conservative.

The trouble is that empiricism itself is tough to apply, given that the
available connection speed between you and the client is subject to
bottlenecks at many nodes along the trip, and can vary on timescales of
seconds, minutes, or hours, with various magnitudes.  Any sample long
enough to average out the high-frequency components is burdensome, and
might still be meaningless an hour later.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 8 Sep 2000 21:48:45 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <Pine.GHP.4.21.0009082137590.24353-100000@hpplus03.cern.ch>

On Fri, 8 Sep 2000, Craig Berry wrote:

> The trouble is that empiricism itself is tough to apply, given that the
> available connection speed between you and the client is subject to
> bottlenecks at many nodes along the trip, and can vary on timescales of
> seconds, minutes, or hours, with various magnitudes. 

Right.  Let's assume, like other comments on the thread, that the real
purpose of the question was to ship some kind of streamed real-time
content...

> Any sample long
> enough to average out the high-frequency components is burdensome, and
> might still be meaningless an hour later.

So you need a protocol which handshakes in real time (such as making 
use of RTP's reception loss report mechanisms) to adapt to the
average throughput, and which has some kind of resilience (e.g
redundancy and packet-loss-repair mechanisms *) built-in to deal with
short-term losses.

(*)   just as an example of the latter approach I'd mention 
http://www-mice.cs.ucl.ac.uk/multimedia/software/rat/

OK, this is off-topic, and I'm not a specialist in that field (I've
only used it - with reasonable success), so I'll shut up for now.



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

Date: Fri, 08 Sep 2000 21:28:33 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how can I tell the internet speed of visitor
Message-Id: <srimg1foljn21@corp.supernews.com>

Alan J. Flavell (flavell@mail.cern.ch) wrote:
: > Any sample long
: > enough to average out the high-frequency components is burdensome, and
: > might still be meaningless an hour later.
: 
: So you need a protocol which handshakes in real time (such as making 
: use of RTP's reception loss report mechanisms) to adapt to the
: average throughput, and which has some kind of resilience (e.g
: redundancy and packet-loss-repair mechanisms *) built-in to deal with
: short-term losses.

Exactly.  If you put the sniffing into the protocol itself, it can react
dynamically to changing conditions, and you avoid the problems I and
others have been enumerating.  You run into problems if you sample then
extrapolate.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


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

Date: Fri, 08 Sep 2000 18:46:39 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: How long does flock take?
Message-Id: <juau5.21$W3.170898944@news.frii.net>

In article <8op231$du6$1@charm.magnus.acs.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to jason 
><elephant@squirrelgroup.com>],
>who wrote in article <MPG.141a662c4ce87bcc989742@localhost>:
>> why not use Time::HiRes to put a *real* timestamp in there .. it's 
>> standard in 5.6 - not sure about earlier perls so you might need to get 
>> it from CPAN .. goes down to microseconds
>
>... which most probably mean nothing.  I would guess that on most
>systems the *granularity* of HiRes is of order of 10ms...  There are
>some exceptions, of course...
>
>Ilya

I think that your guess is off by around 3 orders of magnatude.
At least on common pentium boxen.

chris

#!/usr/bin/perl -w
#

use strict;
use Time::HiRes 'time';
use Statistics::Descriptive;
my $then = time;
my $now;
my $delta;
my $stats = Statistics::Descriptive::Full->new;

for (0..10000)
{
    $now = time;
    $delta = $now - $then;
    $stats->add_data($delta);
    $then = $now;
} 

print $stats->mean, " ", $stats->standard_deviation, "\n";
__END__

u.i.sl3d.com $ perl u
0.000155241176398107 6.58795592146588e-06
-- 
    chris fedde
    303 773 9134


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

Date: 08 Sep 2000 18:38:11 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to delete line #1
Message-Id: <slrn8ricen.vlt.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDLXV September MCMXCIII in
<URL:news:MPG.1422bd9d73426f6598ad3d@nntp.hpl.hp.com>:
"" In article <_A6u5.2750$WD3.83306@news20.bellglobal.com> on Fri, 08 Sep 
"" 2000 14:20:42 GMT, Yanick Champoux <yanick@babyl.sympatico.ca> says...
"" 
"" ...
"" 
"" > 	$ perl -ne'log$.&&print' whatever.txt
"" 
"" Fancy, but unnecessarily arcane and slow, and one stroke too long at 
"" that.
"" 
""  	$ perl -ne'$.-1&&print' whatever.txt

Faster, and saving 3 strokes:

    	$ perl -pe'INIT{<>}' whatever.txt


Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54"; s/<<EOT/<<EOT/e; print;
Just another Perl Hacker
EOT


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

Date: Fri, 08 Sep 2000 19:05:57 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: How to delete line #1
Message-Id: <pMau5.245520$1h3.4608574@news20.bellglobal.com>

Larry Rosler <lr@hpl.hp.com> wrote:
: In article <_A6u5.2750$WD3.83306@news20.bellglobal.com> on Fri, 08 Sep 
: 2000 14:20:42 GMT, Yanick Champoux <yanick@babyl.sympatico.ca> says...

: ...

:> 	$ perl -ne'log$.&&print' whatever.txt

: Fancy, but unnecessarily arcane and slow, and one stroke too long at 
: that.

:  	$ perl -ne'$.-1&&print' whatever.txt

	Arcane and slow, I can live with, but one stroke too long? 
	Aah, the shame, the shame... This being said, one more stroke 
	can be substracted by doing

	$ perl -pe'$_ x=$.>1' whatever.txt

	But I saw that Abigail came with a solution yet two strokes
	shorter than that. *sigh*

/Yanick

-- 
$_ = localtime;      $i = 3814279.10476024;         $\ = ' ';
do{ s/.*(er)l/hack$1./  ; s/.*(er)$/P$1l/ ; 
    s/.*(t).*/ano$1her/ ; s/.*:.*/Just/   ; print; }while( $i = log $i );


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

Date: Fri, 8 Sep 2000 12:01:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to delete line #1
Message-Id: <MPG.1422d77d3a774e5098ad46@nntp.hpl.hp.com>

In article <slrn8ricen.vlt.abigail@alexandra.foad.org> on 08 Sep 2000 
18:38:11 GMT, Abigail <abigail@foad.org> says...
> Larry Rosler (lr@hpl.hp.com) wrote on MMDLXV September MCMXCIII in
> <URL:news:MPG.1422bd9d73426f6598ad3d@nntp.hpl.hp.com>:
> "" In article <_A6u5.2750$WD3.83306@news20.bellglobal.com> on Fri, 08 Sep 
> "" 2000 14:20:42 GMT, Yanick Champoux <yanick@babyl.sympatico.ca> says...
> "" 
> "" ...
> "" 
> "" > 	$ perl -ne'log$.&&print' whatever.txt
> "" 
> "" Fancy, but unnecessarily arcane and slow, and one stroke too long at 
> "" that.
> "" 
> ""  	$ perl -ne'$.-1&&print' whatever.txt
> 
> Faster, and saving 3 strokes:
> 
>     	$ perl -pe'INIT{<>}' whatever.txt

Magnificent!

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


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

Date: 08 Sep 2000 12:09:31 -0700
From: Steve Allan <stevea@wrq.com>
Subject: Re: How to delete line #1
Message-Id: <u66o68zv8.fsf@wrq.com>

"Mike Grimes" <megrimes@flash.net> writes:

>Howdy y'all,
>
>I would like to delete the first line of a log file. 

From the command line

  perl -ne "print if 2 .. eof" oldlog > newlog

Inside a script

open(LOG, $logfile) or die "Can't open $logfile for reading: $!";
my @log = <LOG>;  # read file into array
shift @log;       # strip first line
open(LOG, ">$logfile") or die "Can't open $logfile for writing: $!";
print LOG @log;
close LOG;

> Is there an expert who
>could give me some advide on how I might accomplish this?
>
>I open a file for reading and writing, read each line and perform some
>operations 

I conveniently ignored the 'perform some operations' step.  Hopefully,
those operations can be applied on the shifted array in the second
example prior to printing - maybe a job for map or grep?

HTH

-- 
-- Steve __


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4264
**************************************


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