[11991] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5591 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 7 06:08:32 1999

Date: Fri, 7 May 99 03:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 7 May 1999     Volume: 8 Number: 5591

Today's topics:
    Re: ==> REGEX, how do I use a variable as a seach patte (Bart Lateur)
    Re: dbm-Database from Unix to Windows (Lars Gregersen)
    Re: Excel graph using PERL ? <c4jgurney@my-dejanews.com>
    Re: FAQ 1.1: What is Perl? (David H. Adler)
    Re: FAQ 1.1: What is Perl? <uri@sysarch.com>
    Re: Generate matching strings from regex ? (Bart Lateur)
    Re: having problems getting this script to work... (Bart Lateur)
    Re: how to round off numbers? (Bart Lateur)
    Re: how to round off numbers? (Bart Lateur)
    Re: Is there a version of CDDB written in Perl? (Tramm Hudson)
    Re: Luxury Back Massage at SUPER Below market price for <uri@sysarch.com>
    Re: Making executables from .pl files? ralawrence@my-dejanews.com
    Re: Net::FTP not included in ActivePerl 515? <ebohlman@netcom.com>
    Re: Pentium III Chips Released with IDs - Intel won't b <rick@hpdi.demon.co.uk>
        Perl script as "cat" - but slower <caf0013@my-dejanews.com>
    Re: Perl script as "cat" - but slower <caf0013@my-dejanews.com>
    Re: procedure to convert sec to HH:MM:SS format (Bart Lateur)
    Re: processor usage (Sam Holden)
    Re: Q: checking wheather the user exists <uri@sysarch.com>
        Reg Expression pdean@pcmars.cs.ndsu.nodak.edu
    Re: Reg Expression (Larry Rosler)
    Re: Reg Expression <ebohlman@netcom.com>
    Re: Slice [N..end] of unnamed array? (Sam Nelson)
    Re: Slice [N..end] of unnamed array? (Bart Lateur)
    Re: split, pop, and cut (Bart Lateur)
    Re: testing expressions in the IF statement (Bart Lateur)
    Re: The truth about the Pentium III chip and ID --- **b <rdhughes@home.com>
    Re: using $, (was Re: having problems) (Bart Lateur)
    Re: What is the opposite of bind() ? <gellyfish@gellyfish.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 07 May 1999 09:46:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: ==> REGEX, how do I use a variable as a seach pattern
Message-Id: <3736994f.3237334@news.skynet.be>

Larry Rosler wrote:

>> 	$search= "<-(*.?)->|<\\+(*.?)\\+>";
>
>It is easier to read (hence less error-prone) if you use single quotes 
>and single backslashes:
>
>  	$search= '<-(*.?)->|<\+(*.?)\+>';

Well... If your pattern needs to match a literal backslash, you need to
put FOUR backslashes in this pattern string anyway. Talk about a
pitfall.

	print '\\\\';
->
	\\

	Bart.


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

Date: Fri, 07 May 1999 07:43:18 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: dbm-Database from Unix to Windows
Message-Id: <3732990c.82213234@news.dtu.dk>

On Mon, 3 May 1999 11:34:33 +0200, "Stefan Pvhnlein"
<poehnlsn@iis.fhg.de> wrote:

>Hi there everyone,
>
>I have a problem concerning the change of my os.
>I want to use now a perl script, originally used under Linux, under the
>Personal Web Server of Windows 98.
>
>The script works now.

good for you!

>The only problem left are the dbm-databases.
>It seems that the databases made in Linux could not be used with Windows 98.

DBMs are generally not binary compatible. 

>Does anybody know, how I can use the existing databases without hacking in
>all the data again ?

In Linux: Read all your data from your data base and put it in a flat
file.

Move this file to the Windows machine

In Windows: Read the flat file and put it in your data base. 


  Lars

 ------------------------------
Lars Gregersen (lg@kt.dtu.dk)
http://www.gbar.dtu.dk/~matlg


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

Date: Fri, 07 May 1999 08:15:26 GMT
From: Jeremy Gurney <c4jgurney@my-dejanews.com>
Subject: Re: Excel graph using PERL ?
Message-Id: <7gu7er$mj1$1@nnrp1.deja.com>

In article <7gtrm5$c5r$1@nnrp1.deja.com>,
  tvn007@my-dejanews.com wrote:
> Hi,
<snip>
>
> I would like to have these data read in MS-Excel table and
> automatically graph Time VS. speed.

You can control excel from within perl using the Win32::OLE module.

The documentation shows you how to use ole commands but does not document all
that many examples - for this you'll have to use the excel on line help or
look at the ole examples on the MS web site.

HTH

Jeremy Gurney
SAS Programmer  |  Proteus Molecular Design Ltd.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 7 May 1999 02:11:56 -0400
From: dha@panix.com (David H. Adler)
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <slrn7j511c.pk1.dha@panix.com>

On Thu, 06 May 1999 13:43:58 -0700, David Cassell
<cassell@mail.cor.epa.gov> wrote:

>Uri Guttman wrote:
>> check back a few months for a thread i started on the origins of perl
>> features. it got pretty hot and heavy and was fairly educational. i
>> don't recall the title but search for origin and some of the language
>> names like basic, lisp, etc and you should find it.
>
>Uri,
>
>Thanks for the heads-up.  I wonder how I could have missed it.  Must
>have been one of those spells when I was out of town or something.
>
>So, hopefully, that ends this thread now.

Nah, that would be too easy.  :-)

I just wanted to point out that Elaine Ashton is working on what
sounds like a pretty extensive history of Perl, which she is due to
present at yapc (http://www.yapc.org).

HTH.

dave

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"You're on dry land! Squeaky Whale can't save you now!"
	- Stephen Cole


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

Date: 07 May 1999 03:07:52 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <x7d80duzlj.fsf@home.sysarch.com>

>>>>> "DHA" == David H Adler <dha@panix.com> writes:

  DHA> On Thu, 06 May 1999 13:43:58 -0700, David Cassell
  DHA> <cassell@mail.cor.epa.gov> wrote:

  >> Uri Guttman wrote:
  >>> check back a few months for a thread i started on the origins of perl
  >>> features. it got pretty hot and heavy and was fairly educational. i
  >>> don't recall the title but search for origin and some of the language
  >>> names like basic, lisp, etc and you should find it.
  >> 
  >> So, hopefully, that ends this thread now.

  DHA> I just wanted to point out that Elaine Ashton is working on what
  DHA> sounds like a pretty extensive history of Perl, which she is due to
  DHA> present at yapc (http://www.yapc.org).

that sounds cool. i am leaning more and more to go to yapc. my boss at
home says i should! dave, what is the story on flights to steel city
from beantown?

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 07 May 1999 09:47:04 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Generate matching strings from regex ?
Message-Id: <373eb013.9065590@news.skynet.be>

vepxistqaosani wrote:

>As a new user, I find that regexen are occasionally (well, always)
>difficult to read. It would be helpful to have a script that could take
>a regex as input and produce a matching string.
>
>So, if the input is
>  /(.*)\d\s\w(.*)/
>some possible outputs are
> "any0 Xany"
> "any7\tbany"
>etc.

Interesting. I might take that up one day. :-)

I think a nice output would be to simply create a VALID, commented //x
regex. A regex commenter, with possible output like in David Cassell's
post.

As a first side remark: you cannot do everything using regexes alone.
Nested submatches don't translate into regexes. You probably would need
a parser for that. Example of nested submatches:

	/(a(b*)c)/

	Bart.


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

Date: Fri, 07 May 1999 09:46:44 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: having problems getting this script to work...
Message-Id: <3735962c.2434605@news.skynet.be>

Uri Guttman wrote:

>  AQ> 	{ local $, = ', '; print @array }
>
>and i would do:
>
>	print join( ', ', @array);
>
>which is shorter and faster. and probably clearer as most people don't
>use $,

It's not faster. See my benchmark.

I don't set $, all the time. Often I set it once, at the top of the
script, so it's OBVIOUSLY valid for the whole script. So this is my
version:

	print @array;

Now which is clearer? :-)

If you care so much about 1% speed difference, you shouldn't be using
Perl.

p.s. I'm getting bored of this...

	Bart.


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

Date: Fri, 07 May 1999 09:46:51 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how to round off numbers?
Message-Id: <37379b2a.3712161@news.skynet.be>

David Cassell wrote:

>No no no no no.  Umm, did I say `no'?  :-)
>
>Please don't do that.  It doesn't handle the `integer+0.5' case 
>correctly in half the cases.

	($\,$,) = ("\n","\t");
	foreach (3/2,5/2) {
		print $_,int($_+.5), sprintf('%.0f',$_);
	}
__END__
	1.5	2	2
	2.5	3	2

Personally, I'd say that (integer+.5) gives the right result. :-)
Rounding halves to the "nearest even number" is about the most stupid
rule I've ever seen. I've had graphical displaying programs with nasty
bugs because of this silliness.

But the REAL pitfall here is for negative numbers. int() rounds towards
zero, turning -1.9 to -1, so *adding* 0.5 is wrong there.

	Bart.


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

Date: Fri, 07 May 1999 09:47:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: how to round off numbers?
Message-Id: <373baa79.7630949@news.skynet.be>

Uri Guttman wrote:

>and you are? 

He's the guy from the Sunshine Band.

<duck and run!>

	Bart.


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

Date: 6 May 1999 23:33:23 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Is there a version of CDDB written in Perl?
Message-Id: <7gttv3$6t2@llama.swcp.com>

[posted and cc'd to cited author]

bobby <bobby@DIESPAMDIEbarnworth.com> wrote:
> I'm looking for a way to uniquely identify audio/data cd's and think
> CDDB may be the way to go. Is there a version of CDDB written in Perl?
> (I only care about generating some unique string so I can identify the
> CD and don't really care about communicating with the cddb
> server...yet).

The documentation on the protocol can be found from freecddb.freecddb.org.
Here is a somewhat specialized module that I use with my s-link jukebox.
CDDB::query returns a code pointer that you call until it either die's
on you or returns a hash of values.

The function CDDB::discid accepts a table of contents (an array of
lengths of tracks) and returns the "unique" discid suitable for a query
to the database.


package CDDB;
use strict;
use Carp;
use IO::Socket;
use IO::Select;
use DB_File;
use UNIVERSAL qw(isa);
use vars qw($server $database);

$server = 'freecddb.freecddb.org';
$database = './cddb.dbm';
my %cddb;
tie %cddb, 'DB_File', $database;


sub open_server
{
	while( $_[0] =~ /^-/ ) {
		my $arg = shift;
		# Should do a reconnect arg here
	}
	my ($server,$port) = @_;
		
	my $sd = IO::Socket::INET->new(
		PeerAddr	=> $server,
		PeerPort	=> $port,
		Proto		=> 'tcp', )
			or die "Unable to connect to $server:$port: $!\n";

	return $sd;
}


my $global_sd;
my $debug = 1;
my $default_timeout = 0.5;
my $max_count = 10000;

my %states;

$states{login} = sub
{
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	die "unknown error: $_\n"		unless /^200/;

	$info->{sd}->print( "cddb hello hudson swcp slink 0.2\n" );
	$_[0] = $states{send_query};
	return;
};

$states{send_query} = sub
{
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	die "unknown error: $_\n"		unless /^200/;

	$info->{sd}->print( "cddb query $info->{discid} ",
		(join ' ', @{$info->{cmdstring}}), "\n" );
	$_[0] = $states{recv_query};
	return;
};

$states{recv_query} = sub
{
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	die "no such disc: $_\n"		if /^202/;
	if( /^211/ ) {
		$_[0] = $states{approx_result};
		return;
	}
	if( /^200/ ) {
		(undef,$info->{cat},$info->{discid},$info->{title})
			= split / /, $_, 4;
		print "CDDB: found $info->{cat} $info->{title}\n"
			if $debug;

		return $info if $info->{just_query};
		$_[0] = $states{send_read};
		return $_[0]->($_,$info,$_[0]);
	}
	die "unknown error: $_\n";
};

$states{approx_result} = sub
{
	my $sd		= shift;
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	($info->{cat},$info->{discid},$info->{title})
		= split / /, $_, 3;
	print "CDDB: approx $info->{cat} $info->{title}\n"
		if $debug;

	return $info if $info->{just_query};
	$_[0] = $states{drain_approx};
	return;
};

$states{drain_approx} = sub
{
	my $sd		= shift;
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	return					unless /^\./;
	$_[0] = $states{send_read};
	return $_[0]->($_,$info,$_[0]);
};

$states{send_read} = sub
{
	local($_)	= shift;
	my $info	= shift;

	# We just go ahead and send
	$info->{sd}->print( "cddb read $info->{cat} $info->{discid}\n" );
	$_[0] = $states{recv_read};
	return;
};

$states{recv_read} = sub
{
	local($_)	= shift;
	my $info	= shift;

	die "server error: $_\n"		if /^5/;
	die "error 401?: $_\n"			if /^401/;
	die "unknown error: $_\n"		unless /^210/;

	$_[0] = $states{recv_tracks};
	return;
};

$states{recv_tracks} = sub
{
	local($_)	= shift;
	my $info	= shift;

	return					if /^#/;
	return cache_record($info)		if /^\./ or /^EXTD/;

	my ($key,$value) = split /=/, $_, 2;
	if( $key =~ /^DTITLE/ ) {
		($info->{artist}, $info->{title})
			= split /\//, $value, 2;
		return;
	}
	if( $key =~ /^TTITLE(\d+)$/ ) {
		$info->{tracks}->[$1] = $value;
		return;
	}

	return;
};

sub lookup
{
	my $just_query;
	my $just_cache;
	my $reuse;
	my $timeout = $default_timeout;

	while( $_[0] =~ /^-/ ) {
		my $arg = shift;
		
		$just_cache = 1, next		if $arg eq '-cache';
		$just_query = 1, next		if $arg eq '-query';
		$timeout = shift, next		if $arg eq '-timeout';
		$reuse = 1, next		if $arg eq '-reuse';
		
		croak "Invalid argument to CDDB::lookup: $arg\n";
	}


	my ($cat,$discid,$playtime,@toc,@cmdstring);

	if( $just_cache ) {
		($cat,$discid) = @_;
	} else {
		($playtime, @toc) = @_;
		($discid, @cmdstring) = discid( $playtime, @toc );
	}

	my $info = {
		discid		=> $discid,
		playtime	=> sec2ms($playtime),
		lengths		=> [map {sec2ms($_)} @toc],
		cmdstring	=> \@cmdstring,
	};


	if( exists $cddb{$discid} ) {
		#print "CDDB: Cached: $discid\n";
		my ($cat,$artist,$title,@tracks) = split /\|/, $cddb{$discid};
		$info->{tracks}	= \@tracks;
		$info->{title}	= $title;
		$info->{artist}	= $artist;
		$info->{cat}	= $cat;
		return wantarray ? (undef,sub { $info }) : $info;
	}

	die "no such disc: $discid\n" if $just_cache;

	print "CDDB: Connecting to server to query $discid\n";

	my $sd = $reuse && $global_sd
		? $global_sd
		: open_server( $server, 888 );

	my $sel = IO::Select->new( $sd );

	$info->{sd}	= $sd;
	$info->{sel}	= $sel;

	print "CDDB: Server connected, entering statemachine, to=$timeout\n";


	my $state = $states{login};
	my $callback = sub
	{
		print "CDDB::callback: @_\n";
		while( $_[0] =~ /^-/ ) {
			my $arg = shift;
			$timeout = shift, next	if $arg eq '-timeout';
			croak "CDDB::callback: invalid arg $arg\n";
		}

		my $rc;

		while($sel->can_read($timeout)) {
			my $line = <$sd>;
			die "CDDB::callback: server closed on us\n"
				unless defined $line;

			$line =~ s/[\n\cM]*$//;
			print "CDDB: read $line\n" if $debug;

			$rc = $state->($line, $info, $state);
			return $rc if $rc;
		}
		return;
	};

	wantarray ? ($sd,$callback) : $callback->(-timeout => undef);
}


sub cache_record
{
	my $info = shift;
	#my ($cat,$artist,$title,@tracks) = split /\|/, $cddb{$discid};
	$cddb{$info->{discid}} = join '|',
		$info->{cat},
		$info->{artist},
		$info->{title},
		@{$info->{tracks}};
	untie %cddb;
	tie %cddb, 'DB_File', $database;
	return $info;
}


sub cddb_sum
{
	my $len = shift;
	my $rc = shift;
	while( $len > 0 ) {
		$rc += $len % 10;
		$len /= 10;
	}
	return $rc;
}

sub discid
{
	my ($total_time,@tracks) = @_;
	my $playtime;

	for( @tracks ) { $playtime += $_ }

	my $offset = $total_time - $playtime;
	my @offsets;
	my $sum = 0;

	for( @tracks ) {
		$sum += cddb_sum( $offset );
		push @offsets, $offset * 75;
		$offset += $_;
	}

	my $discid = sprintf( "%08x",
		  ($sum % 0xFF) << 24
		| $playtime << 8
		| scalar(@tracks) );

	return ($discid, scalar(@tracks), @offsets, $playtime);
}


sub sec2ms
{
	my $sec = shift || 0;
	my $min = int($sec/60);
	$sec %= 60;

	sprintf( "%d:%02d", $min, $sec );
}

1
__END__


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

Date: 07 May 1999 03:03:38 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Luxury Back Massage at SUPER Below market price for internet ONLY
Message-Id: <x7g159uzsl.fsf@home.sysarch.com>

>>>>> "JS" == James Scott <James> writes:

  JS>  Luxury Back Massage

  JS>  Real Leather, Light Weight, Portable, 100 finger-massage with
  JS> handy cigeratte lighter plug for home, office car or anywhere.

does it use the module Jewish::Food::Latkes::Massage::Back?

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 07 May 1999 09:12:53 GMT
From: ralawrence@my-dejanews.com
Subject: Re: Making executables from .pl files?
Message-Id: <7guaqj$pa8$1@nnrp1.deja.com>

In article <ylhfpq1yxy.fsf@windlord.stanford.edu>,
  Russ Allbery <rra@stanford.edu> wrote:
> Asbjorn Gjemmestad <agjemmes@extremeonline.com> writes:
>
> > When selling a commercial product, would you want other people to mess
> > with, change, and possibly redistribute your product? Me and my partner
> > have developet a neat copy protection system which contacts our server,
> > and thus people won't be able to do anything about it if the code is
> > pre-compiled.
>
> You are under no obligation to share your code with me, but I'm under no
> obligation to help you hide it.  Perl is free software.  Writing
> proprietary software using free software is an activity that Larry Wall
> has chosen to explicitly allow in this case, which to me demonstrates just
> how generous of a person he is.  It doesn't prevent me from thinking that
> you're being extremely rude, and I certainly don't have any desire to help
> you.
>
> Someone else here might.  *shrug*  But lots of people here have the same
> opinion that I do, so don't be surprised when you run into it repeatedly.

Having spoken to several people on this subject, there seems to be a lot of
people who have the opinion that if you develop something on something that
was free then what you developed should also be free and open.

However, IMO, people should be careful with that opinion. If we subscribe to
it then does that mean that if someone writes a book on a free wordprocessor
then they should give the book away for free? Of course not. But it _was_
developed on something that was free!

Or how about my friend who writes music using free samples with a free tracker
program, adds effects with a free audio mixing package and uses a free program
to etch these songs onto CD. Because he's developed it on stuff that was free
should he not be able to make money from it? I don't think so.

Or how about anything developed on GCC which doesn't have source available? (I
can think of several good bits of software like that).

Or do we go as far as to say, well that was developed on a free OS, therefore
you can't make money from it? I'm sure Oracle and Lotus wouldn't be too happy
about that after they've made the bold decision to support Linux.

Of course, a lot of this is too general and we are talking about Perl here. I
think that whether people choose to "hide" code is up to them. If you wrote
an inpressive encryption/decription system then you might not want to hand
out the source code. There are programs out there that serve to turn Perl
code into C. There are lots of downsides to them but they do make it harder
for people to see the code. Now, they could be written out of morbid
curiosity, but I'd suspect that there is a demand for it (hell, one company
*charges* for it, so they must have a demand).

Some people will see this posting as making excuses for those that want to
hide their code, but I'm just pointing out the other side for a fair and
balanced debate. My personal opinion is undecided, as with everything, there
are pros and cons.

However, if the Perl licence specifically FORBIDS "hiding" your code, then we
are onto a whole new ball game ...

Rich.


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 7 May 1999 06:56:54 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Net::FTP not included in ActivePerl 515?
Message-Id: <ebohlmanFBCoMu.DuM@netcom.com>

leonandrews@my-dejanews.com wrote:
: Can anyone tell me why I don't get Net::FTP with the new version of Active
: Perl and also why it no longer seems to be available using PPM?

It's part of the libnet bundle, which isn't part of the default 
distribution.  libnet *is* available using PPM.



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

Date: Fri, 7 May 1999 10:32:59 +0100
From: "Rick Price" <rick@hpdi.demon.co.uk>
Subject: Re: Pentium III Chips Released with IDs - Intel won't budge
Message-Id: <926069500.1574.0.nnrp-11.9e98b131@news.demon.co.uk>

I thought the addition of the ID was to stop chip/pc thefts or at least make
it easy to prove that a cheap chip was a stolen chip.  This seems like a
good Idea to me.

Big brother can always trace us.  He doesn't need us to use a pentium III.


Andrew L. Peterson wrote in message <37322fe3.433346052@news.micron.net>...
>
>I was kind of upset when I first heard about these new chips with
>serial numbers in them, however, the other day I noticed that my
>mother board also has a serial number in it. I am sure there is a way
>through software to find out what it is too. This was on a mother
>board with P166 chip. I have a feeling tracking us by serial numbers
>have been around longer that we think.
>
>Andrew
>
>
>
>
>On Wed, 05 May 1999 21:07:19 GMT, Intelz@nospam.net (Intel No Privacy)
>wrote:
>
>>
>> Pentium III chip with the individual serial number that can
>>track your web surfing and buying habits can now have the ID number
>>turned on and off by software.  Following some links I found the
>>www.fightdivx.com website and noticed that they have a Intel Boycott
>>page with links, quotes and info on why you should boycott the
>>invasion of privacy Pentium III chips. Just like everyone suspected,
>>the ID number can be taken without a customers knowledge. Just like
>>cellular phone fraud, once someone has your unique ID number, they
>>could pose as you on the internet.  Do not be fooled by reports that
>>this problem is fixed because Intel disabled this feature by software
>>on their up coming chips.  Information is power. They want to know
>>your surfing and buying habits. That is what this is all about. Here
>>is the link to the page with the boycott info and links.
>>
>>http://www.fightdivx.com/intelboycott.htm
>>
>>Also you will find a Boycott Intel screen saver and banner on their
>>page above. Spread it around.
>>
>>
>




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

Date: Fri, 07 May 1999 07:26:18 GMT
From: caf <caf0013@my-dejanews.com>
Subject: Perl script as "cat" - but slower
Message-Id: <7gu4io$k87$1@nnrp1.deja.com>

Hi,

At my site we have just run some testing and I was capturing screen output
with "script", creating a file for each user session, now if I cat the
resultant file I see all the screen fine, but if I use more, I get all the
escape codes, so what I want to do is write a perl script (which I have never
done before) to slowly go through the output.

If I use the following,

#!/usr/contrib/bin/perl

while ( <> ) {
        print $_;
        system( sleep 1 );
}

It goes through the LINES slowly, but unfortunatly because some of the escape
codes make the cursor move to different points of the screen and insert text
(with being a line) so bits of the file speed through.

Is there are way to go through a configurable number of characters and then
pause rather than be line based ?

thanks
--
All thought welcome,

caf
com.yahoo@caf0013

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 07:30:48 GMT
From: caf <caf0013@my-dejanews.com>
Subject: Re: Perl script as "cat" - but slower
Message-Id: <7gu4r9$kjf$1@nnrp1.deja.com>


> Hi,
>
> At my site we have just run some testing and I was capturing screen output
> with "script", creating a file for each user session, now if I cat the
> resultant file I see all the screen fine, but if I use more, I get all the
> escape codes, so what I want to do is write a perl script (which I have never
> done before) to slowly go through the output.
>
> If I use the following,
>
> #!/usr/contrib/bin/perl
>
> while ( <> ) {
>         print $_;
>         system( sleep 1 );
> }
>
> It goes through the LINES slowly, but unfortunatly because some of the escape
> codes make the cursor move to different points of the screen and insert text

sorry typo

> (withOUT being a line) so bits of the file speed through.
>
> Is there are way to go through a configurable number of characters and then
> pause rather than be line based ?

thanks
--
All thought welcome,

caf
com.yahoo@caf0013

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 07 May 1999 09:46:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: procedure to convert sec to HH:MM:SS format
Message-Id: <3734956c.2242642@news.skynet.be>

Tad McClellan wrote:

> There are 60 seconds in a minute.
>
>   There are 60 minutes in an hour.
>
>   Perl has division and modulus operators.
>
>   Just do the arithmetic  :-)

Perl doesn't have an INTEGER division operator.

Well... it has, but it's not obvious.

	{
		use integer;
		print 3599 / 60;
	}

-->
	59

The surreounding block limits the effect of "use integer" to that block.

Ordinary users (like me) would tend to use

	print int(3599/60);

Also, note that (s)printf('%d', NONINTEGER) also rounds towards zero
(aka "truncate"), so you don't really need all that. If you want to
round (to the nearest), you can use (s)printf('%.0f', NONINTEGER).

	Bart.


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

Date: 7 May 1999 06:12:49 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: processor usage
Message-Id: <slrn7j5130.k34.sholden@pgrad.cs.usyd.edu.au>

On Fri, 07 May 1999 05:41:24 GMT, tbsmith@deltacom.net wrote:
>How can i run a program that uses infinite loops without using 99% of the
>processor?

Instead of asking again why don't you read the answers to the first post
you made...

*plonk*

-- 
Sam

Simple rule: include files should never include include files.
	--Rob Pike


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

Date: 07 May 1999 03:02:07 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: checking wheather the user exists
Message-Id: <x7iua5uzv4.fsf@home.sysarch.com>

>>>>> "JS" == John Stanley <stanley@skyking.OCE.ORST.EDU> writes:

  JS> In article <x74slpwux5.fsf@home.sysarch.com>,
  JS> Uri Guttman  <uri@sysarch.com> wrote:

  JS> No, no. Shadow does not map user names to uids, it maps user names to
  JS> passwords, and sometimes password expirations. Nsswitch.conf does not
  JS> map names to uids, it specifies which maps to use.

i know that too. i was just stating things related to /etc/passwd.
please, i have been hacking unix for 15 years including porting, and
drivers. 

  >> but my point was valid, if he figures out how other programs do it, then
  >> he could figure out how perl can do it. 

  JS> I was not replying to what you say is your point. I was replying to the
  JS> part I quoted, which asks how you would map without looking in the
  JS> password file. 

and the original poster is long gone and may never learn about getpwuid.

this thread is going nowhere. i hereby kill it.

hitler.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 07 May 1999 06:20:12 GMT
From: pdean@pcmars.cs.ndsu.nodak.edu
Subject: Reg Expression
Message-Id: <7gu0mq$g7p$1@nnrp1.deja.com>

Hi,	I have a doubt please let me know whether it is possible thru' reg
exp or not.I'm reading a line and looking for a word and if that matches i'm
trying to take the value present in that line.

eg.
	No. of input values : 12
here i'm looking for input and i want to take 12 from this line if this is
possible please throw some light.
Thankx

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 6 May 1999 23:52:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Reg Expression
Message-Id: <MPG.119c2d7763b63b529899f1@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7gu0mq$g7p$1@nnrp1.deja.com> on Fri, 07 May 1999 06:20:12 
GMT, pdean@pcmars.cs.ndsu.nodak.edu <pdean@pcmars.cs.ndsu.nodak.edu> 
says...
> Hi,	I have a doubt please let me know whether it is possible thru' reg
> exp or not.I'm reading a line and looking for a word and if that matches i'm
> trying to take the value present in that line.
> 
> eg.
> 	No. of input values : 12
> here i'm looking for input and i want to take 12 from this line if this is
> possible please throw some light.

Something like this (data in $_)?

    if (/\binput\b\D*(\d+)/) { $value = $1 }

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


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

Date: Fri, 7 May 1999 07:02:59 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Reg Expression
Message-Id: <ebohlmanFBCox0.E5y@netcom.com>

pdean@pcmars.cs.ndsu.nodak.edu wrote:
: Hi,	I have a doubt please let me know whether it is possible thru' reg
: exp or not.I'm reading a line and looking for a word and if that matches i'm
: trying to take the value present in that line.

: eg.
: 	No. of input values : 12
: here i'm looking for input and i want to take 12 from this line if this is
: possible please throw some light.

It's extremely easy.  You really need to read perlre and the section of 
perlop about matching operators to develop your skills in this sort of 
thing; go right to those documents if you don't understand the below:

$num=$1 if /input.*?:\s*(\d+)/;



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

Date: 7 May 1999 08:21:57 GMT
From: sam@cs.stir.ac.uk (Sam Nelson)
Subject: Re: Slice [N..end] of unnamed array?
Message-Id: <7gu7r5$bt$1@wallace.stir.ac.uk>

In article <ohhsg7.nd7.ln@magna.metronet.com>, tadmc@metronet.com (Tad McClellan) writes:
| Sam Nelson (sam@cs.stir.ac.uk) wrote:
| : If I just generated an array whose length I don't know, how do I take a slice
| : containing item N onwards? 
| 
|    Your use of "unnamed array" is confusing, since that term is
|    not used in Perl.
| 
|    Perl has "lists" and "anonymous arrays".
| 
|    Did you mean one of those?
| 
Dunno.  I mean, a list of things that arises as an intermediate result inside
an expression, such as the result of split() run on a line of input data.

|    Post a little code that generates whatever data structure it
|    is that you _do_ mean, and we could likely show how to
|    slice and dice it.
|    
Input file is, for the purposes of the example, a fictional file whose lines
containing an arbitrary number of comma-separated fields.  What I want to do
is ignore the first N fields and grab the rest, but I don't know in advance
how many fields there are.

  while(<>) {
    @LastFewFields=(split(':'))[$N..-1]; }

for example?  Except that, while that slice makes sense when read, it doesn't
work.  But I can use

  while(<>) {
    @WholeLot=split(':');
    @LastFewFields=$WholeLot[$N..-1]; }

or

  while(<>) {
    ($D1,$D2,$D3,..,$DN,@LastFewFields)=$WholeLot[$N..-1]; }

but neither of these is particularly elegant.

-- 
SAm.                               (Insert bandwidth-wasting disclaimer here)
       `Let's hurry up and take this before Billy's slippers wear off...'


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

Date: Fri, 07 May 1999 09:46:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Slice [N..end] of unnamed array?
Message-Id: <3739a765.6843270@news.skynet.be>

Sam Nelson wrote:

>If I just generated an array whose length I don't know, how do I take a slice
>containing item N onwards?  Obviously I can put the slice into an intermediate
>array (@Temp, say) and slice `@Temp[$N..-1]' or something like that but while
>the syntax makes sense, a slice like `(split(':'))[$N..-1]' always seems
>to get me nothing at all.  Is there some obvious reason I'm missing why this
>can't work

Yes. I myself have brought this up before. I think you're right: Perl
SHOULD be able to understand it. Pure DWIM. It doesn't. Applescript
does. The most stupid programming language ever invented (IMO)
understands it!

The reason why it doesn't work, is because ($N..-1) is interpreted as a
list without any regards of what this list is going to be used for.

It only works if $N is negative.

	print @Temp[-3..-1];

prints the 3 last items in the array. (-3..-1) stands for (-3,-2,-1). So
now you can probably see why it doesn't work if the number on the left
is bigger than the number on the right.

	$, = " "; $\ = "\n"; # nice printing
	print -3..-1;
-->
	-3 -2 -1

	print 2..-1; # nada
-->


You can create a temporary array (say @Temp) and use $#Temp instead of
-1, or (@Temp-1) if you like.

	Bart.


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

Date: Fri, 07 May 1999 09:47:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: split, pop, and cut
Message-Id: <373dab06.7772162@news.skynet.be>

Peter Eisengrein wrote:

>I am looking for a way to split not by delimiter (which is like the UNIX
>'cut -d'), but instead by character count, like the UNIX 'cut -c'
>command. 

I'm not sure exactly what this command does. Do you want characters from
the start, or from the end?

Anyway, look at the docs for substr(). It can *return* any subpart from
a string.

>I know I can cut off the end with pop, but that isn't exactly
>right either.

I think you should be quoting chop() instead. That removes one character
from the end, and returns it.

Anyway, I've been wondering about this just yesterday.

You can use substr() to get part of a string, or replace it. But you
can't do both at once. I mean the functionality of splice for arrays:

	@ary = qw(a b c);
	@extract = splice @ary, 0, 2;
	
which BOTH removes qw(a b) from the array, and returns it.

You can't do the same with substr. This is the closes I get:

	$str = 'abc';
	$extract = substr($str,0,2);	#extract
	substr($str,0,2) = '';  	#delete	

See the redundancy?

	Bart.


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

Date: Fri, 07 May 1999 09:46:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: testing expressions in the IF statement
Message-Id: <373aaa1c.7538621@news.skynet.be>

  wrote:

>try the following:
>
>if ( ($x < 5 ) && ($x > 2) ) {
>print" $x is less than 5 and greater than 2 \n";
>}

"and" instead of "&&" works too. The only difference between those two
is the precedence, but that doesn't make any difference in this case.

	Bart.


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

Date: Fri, 07 May 1999 02:08:39 -0500
From: Rob Hughes <rdhughes@home.com>
Subject: Re: The truth about the Pentium III chip and ID --- **boycott info**
Message-Id: <37329177.D4BC72AE@home.com>

Go away, toad boy. Why don't you post this in the MAC groups. They may
care.

Intel No Privacy wrote:

who cares?


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Fri, 07 May 1999 09:46:53 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: using $, (was Re: having problems)
Message-Id: <37389d3f.4245592@news.skynet.be>

Uri Guttman wrote:

>i seem to recall join was faster. i will have to reread the
>benchmark. can you post it again or email it to me?

See bottom.

>  BL> Readbility. I think
>
>  BL> 	print @data;
>
>  BL> looks a LOT less horrible (and is therefore less error-prone) than 
>
>  BL> 	print join("\t",@data)."\n";
>
>you forgot the "\n", on yours

I didn't forget. I always set $\ and $, at the same time.

	print @data;

simply outputs a complete row. How confusing can that be?

>only when i output a line to the tabbed file do i need to do that and it
>is very obvious what is going on. a hidden $, use is more obscure IMO.

Depends on your definition of "obscure". Whenever my main output is a
tab delimited text file, I set $\ and $, at the top of my script, and
make it VERY obvious that this is now the main rule. If you want Perl's
default rule back, simply localize $\ and $, and you've got it back.

BENCHMARKS

I've modified Larry's original code, so that it's more realistic. I have
a row of 50 cells, and the length of each cell line is random (between 5
and 29). Different runs provide different data. Apparently, how these
routines compare, depends on the data! Sometimes your code is faster,
sometimes mine. But before you get too carried away, be aware of the
fact that the "localize" of the special variables is one of the things
that take a lot of the time. If I move setting the variables to outside
the test sub, mine becomes the clear winner.

 my $loops = 1 << (shift || 11);
 timethese($loops, {
  Bart => sub { local($\,$,) = ("\n", "\t"); print OUT @data },
  uri => sub { print OUT join("\t",@data),"\n" },
  Interpolated => sub { local $" = "\t"; print OUT "@data\n" },
  Localize => sub { local($\,$,) = ("\n", "\t") },
 });
 {
    local($\,$,) = ("\n", "\t");
	timethese($loops, {
	  BartNoLocalize => sub { print OUT @data },
	});
 }

** RUN 1
Benchmark: timing 2048 iterations of Bart, Interpolated, Localize,
uri...
      Bart:  7 wallclock secs ( 6.76 usr +  0.00 sys =  6.76 CPU)
Interpolated:  7 wallclock secs ( 7.14 usr +  0.00 sys =  7.14 CPU)
  Localize:  0 wallclock secs ( 1.70 usr +  0.00 sys =  1.70 CPU)
       uri:  7 wallclock secs ( 6.81 usr +  0.00 sys =  6.81 CPU)
Benchmark:
timing 2048 iterations of BartNoLocalize...
BartNoLocalize:  5 wallclock secs ( 6.10 usr +  0.00 sys =  6.10 CPU)

** RUN 2
Benchmark: timing 2048 iterations of Bart, Interpolated, Localize,
uri...
      Bart:  7 wallclock secs ( 6.32 usr +  0.00 sys =  6.32 CPU)
Interpolated:  7 wallclock secs ( 6.59 usr +  0.00 sys =  6.59 CPU)
  Localize:  1 wallclock secs ( 1.70 usr +  0.00 sys =  1.70 CPU)
       uri:  5 wallclock secs ( 5.77 usr +  0.00 sys =  5.77 CPU)
Benchmark:
timing 2048 iterations of BartNoLocalize...
BartNoLocalize:  5 wallclock secs ( 5.27 usr +  0.00 sys =  5.27 CPU)


What is not obvious to me is the large difference between
"BartNoLocalize"+"Localize" and plain "Bart". There's a 0.75 seconds
difference, and it's not just the sub call; I added a 

	Empty => sub { },

line to the benchmark, and this uses up only 0.16 seconds. 0.6 seconds
are gone missing.

	Bart.


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

Date: 7 May 1999 09:20:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: What is the opposite of bind() ?
Message-Id: <3732a25d@newsread3.dircon.co.uk>

Kenny McCormack <gazelle@yin.interaccess.com> wrote:
> In article <ssirg7.hi6.ln@magna.metronet.com>,
> Tad McClellan <tadmc@metronet.com> wrote:
>>
>>: Thank you for totally derailing this thread.
>>
>>
>>   The point being that you are the only person who knows
>>   what book you are using, hence what code you are using.
> 
> If I thought it was particularly relevant, I'd have included it.
> 
> The question is almost more of a Unix question than a Perl question,
> so the actual code being used didn't seem important.
> 
> The question is: Is there an unbind() system call in Unix?  The answer
> appears to be "No - but you can work around it by using SO_REUSEADDR."

You might find it illuminating to look at :

<http://www.freebsd.org/doc/psd/20.ipctut/paper.html>

<http://www.freebsd.org/doc/psd/21.ipc/paper.html>

If your are not on a 4.4BSD based system such as FreeBSD.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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