[24888] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7140 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 14 18:06:38 2004

Date: Tue, 14 Sep 2004 15:05:20 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 14 Sep 2004     Volume: 10 Number: 7140

Today's topics:
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <bik.mido@tiscalinet.it>
    Re: $| (undocumented) magic? <abigail@abigail.nl>
        Best place to learn perl? (Page)
    Re: Best place to learn perl? <postmaster@castleamber.com>
    Re: Best place to learn perl? <emschwar@pobox.com>
    Re: Best place to learn perl? <miknrene@drizzle.com>
    Re: Best place to learn perl? <shawn.corey@sympatico.ca>
    Re: Best place to learn perl? (ft4bredn)
    Re: hv_iterinit has side effects - who cares about PL t <tassilo.von.parseval@rwth-aachen.de>
    Re: killing a "nobody's" process and its group <spamtrap@dot-app.org>
    Re: killing a "nobody's" process and its group <spamtrap@dot-app.org>
        perl script to copy mp3 files to your portable mp3 devi (Inetquestion)
    Re: perl script to copy mp3 files to your portable mp3  <postmaster@castleamber.com>
        Regular expression to match month number 1,...,12 (incl (Matt Benson)
    Re: Regular expression to match month number 1,...,12 ( <nospam@nosite.zzz>
    Re: Running as a Service <miknrene@drizzle.com>
    Re: Screen Size <spamtrap@dot-app.org>
        Using RE's to match a word split across lines? les0624@_cox.net
    Re: Using RE's to match a word split across lines? <noreply@gunnar.cc>
    Re: Using RE's to match a word split across lines? <mritty@gmail.com>
    Re: Using RE's to match a word split across lines? <uri@stemsystems.com>
    Re: Xah Lee's Unixism <albalmer@att.net>
    Re: Xah Lee's Unixism <albalmer@att.net>
    Re: Xah Lee's Unixism <albalmer@att.net>
    Re: Xah Lee's Unixism <lin8080@freenet.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 14 Sep 2004 23:10:26 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <f8kek09p6h3v9j3v069dra66t8qj66dkuh@4ax.com>

On 13 Sep 2004 21:16:37 -0700, krakle@visto.com (krakle) wrote:

>> While trying my hand at a new japh[*], 
>
>Why why and why?

Fun?!? Fun, Fun and more Fun?

>Do something productive...useful...

You may think what you want, but IMHO spending some time on JAPHs,
golf et similia is an aid to improve one's programming skills also in
"productive" code.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Tue, 14 Sep 2004 23:10:28 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: $| (undocumented) magic?
Message-Id: <jckek09ghen8j4r7e76aeevs0rpcohtq9r@4ax.com>

On 14 Sep 2004 07:40:16 -0700, jl_post@hotmail.com (J. Romano) wrote:

>   Forgive me for bringing this up one more time, Michele.  I've been
>thinking about this, and it seems to me that $| may have been
>implemented to return 1 (if true) in order to behave like a boolean
>variable.  This would be an advantage when comparing to boolean
>variables, like in this example:

  Forgive me for this answer that most likely won't satisfy you,
Jean-Luc.  I've been thinking about this, and it seems to me that $|
may have been implemented that way to help me finding the final form
for my most recent JAPH: in the original one I used $| for a
completely different purpose[1] and I had C<($"=~$")>[2] in place of
C<--$|>.  This was because I was convinced that I necessarily had to
use a string =~ /^[\0\xFF]+$/ for a certain purpose, whereas I later
realized /^[01]+$/ would have been just good.


[1] That included as a nice side effect to leave $|==1 at print()
time, unlike now. And _I_M_H_O_ that is the current JAPH's *only*
defect in that it clobbers the "\r" effect at least, say, in Linux
console which is definitely too fast for it to be evident (but xterm &
C. and M$-DOS console under Win all seem to work just fine...)

[2] Along with either C<$"|=$"> or C<$"&=$">, according to some
condition I won't mention here, somewhere near the beginning of the
script.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 14 Sep 2004 22:01:56 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: $| (undocumented) magic?
Message-Id: <slrnckeqik.qm8.abigail@alexandra.abigail.nl>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMMXXXII
September MCMXCIII in <URL:news:ci73es$b63$1@mamenchi.zrz.TU-Berlin.DE>:
 ..  J. Romano <jl_post@hotmail.com> wrote in comp.lang.perl.misc:
 .. > 
 .. >    Forgive me for bringing this up one more time, Michele.  I've been
 .. > thinking about this, and it seems to me that $| may have been
 .. > implemented to return 1 (if true) in order to behave like a boolean
 .. > variable.
 ..  
 ..  Well, it *is* a boolean variable.  The state of a filehandle is either
 ..  auto-flushing or not, so it wouldn't make much sense to have $| return
 ..  values other that 0 and 1.


Well, $* is also a boolean variable - but you can assign (almost) anything
to it. $^W acts more like $| though.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 14 Sep 2004 11:11:45 -0700
From: dummymb@hotmail.com (Page)
Subject: Best place to learn perl?
Message-Id: <6742094.0409141011.720703e6@posting.google.com>

Ok.  I give.  I'm throwing in the towell.  No matter how long I use
perl, some of the syntax just doesn't make any sense to me.

Any suggestions on the best place to learn Perl?  I own a 1/2 dozen
books or so and they are only helpful to a point.

Is there an online school or should I try to take a night course at
one of the local colleges?

I just don't get statements like:
for (@{$struct->{treemap}->[0]->{rectangle}}) {
   # do perl stuff here
}


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

Date: 14 Sep 2004 18:45:31 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Best place to learn perl?
Message-Id: <Xns95648BF559837castleamber@130.133.1.4>

dummymb@hotmail.com (Page) wrote in news:6742094.0409141011.720703e6
@posting.google.com:

> Ok.  I give.  I'm throwing in the towell.  No matter how long I use
> perl, some of the syntax just doesn't make any sense to me.
> 
> Any suggestions on the best place to learn Perl?  I own a 1/2 dozen
> books or so and they are only helpful to a point.
> 
> Is there an online school or should I try to take a night course at
> one of the local colleges?
> 
> I just don't get statements like:
> for (@{$struct->{treemap}->[0]->{rectangle}}) {
>    # do perl stuff here
> }

I hope you just don't understand the expression, and not the for 
statement :-D.

First of all, some people just can't. 

Second, in order to understand that expression, read a good chapter on 
references. Once you understand:

$struct->{treemap}

it will get easier to read the rest.


-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Tue, 14 Sep 2004 12:54:13 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Best place to learn perl?
Message-Id: <etomzzsk7fu.fsf@wilson.emschwar>

dummymb@hotmail.com (Page) writes:
> I just don't get statements like:
> for (@{$struct->{treemap}->[0]->{rectangle}}) {
>    # do perl stuff here
> }

I can't address your concerns with night schools (quality varies
drastically depending on the instructor), and most online instruction,
frankly, stinks, but I can at least try to help you decode this snippet.

This is the approach I often use when confronted with odd-looking
syntax like you see here.  It's centered around the notion of starting
with the most obvious parts, and examining those for what they imply
about the not-so-obvious parts.

First off, notice that it's a for loop.  That means you're iterating
over a list.  If you don't get that, then 'perldoc perlsyn'.  So we
know whatever's inside the () is a list.  That, in turn, means that

@{$struct->{treemap}->[0]->{rectangle}}

is going to produce a list somehow.  But how does it do that?  Well,
our next big clue is the

@{ .... } on the outside.  That means that whatever's inside is a
reference to an array, and we're dereferencing it.  Read 'perldoc
perlreftoot' and 'perldoc perlref', in that order, for more
information on references.

Okay, so we know that 

@{$struct->{treemap}->[0]->{rectangle}}

is dereferencing a reference to an array (aka 'arrayref'), so that
means that

$struct->{treemap}->[0]->{rectangle}

is a reference to an array.

At this point, we're left with a fairly standard set of references
pointing to other references.  If you've written code in C, Java, C++,
or even (*spit*) Pascal, you've seen this pattern before.  So instead
of going from the outside in, I'm going to start at the left, and go
to the right.

$struct points to a hash reference.  You can tell because the bit on
the other end of its -> operator is surrounded by curly brackets. 

Each element of that hash points to an array reference.  You can tell
this because the bit on the other end of {treemap}'s -> operator is in
square brackets.

Each element of THAT array points to another hash reference.  If you
don't understand why, ask, but hopefully, it's obvious by now.

And of course, since the ENTIRE expression 

$struct->{treemap}->[0]->{rectangle}

is an array reference (remember, we know that because it's surrounded
by @{...}), we know that that last hash reference points to an array
reference.

So what we have here is a for loop that's iterating over an array
that's deep inside a multi-layered data structure.

BTW, that loop can also be written as 

for (@{$struct->{treemap}[0]{rectangle}}) {
   # do perl stuff here
}

You can decide for yourself whether or not it's clearer to include the
'->' in the middle of the expression or not; I think it's usually less
'->' clear, but I don't believe it's a hard and fast rule.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Tue, 14 Sep 2004 11:59:29 -0700
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: Best place to learn perl?
Message-Id: <m3k6uw8yni.fsf@eric.rossnet.com>

dummymb@hotmail.com (Page) writes:

>Ok.  I give.  I'm throwing in the towell.  No matter how long I use
>perl, some of the syntax just doesn't make any sense to me.
>
>Any suggestions on the best place to learn Perl?  I own a 1/2 dozen
>books or so and they are only helpful to a point.
>
>Is there an online school or should I try to take a night course at
>one of the local colleges?
>
>I just don't get statements like:
>for (@{$struct->{treemap}->[0]->{rectangle}}) {
>   # do perl stuff here
>}

I'll let the gurus address your general question, but in regard to
your specific example: this particular bit of nastiness has to do with
references, which are often confusing to the less-experienced, so much
so that there's a gentle man page to help ease this exact confusion.

perldoc perlreftut


-- 
Mike Slass


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

Date: Tue, 14 Sep 2004 15:53:20 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Best place to learn perl?
Message-Id: <wYH1d.4519$lb5.524908@news20.bellglobal.com>

HI,

I cannot tell you the best place to learn Perl; it depends on where you 
live and what you have access to. I can tell where not to learn Perl: 
don't try learning it from CPAN modules. They use many advance 
techniques to do their job. Wait until you are comfortable with simpler 
stuff before tackling them.

The best way to learn Perl is thru pratice. If you find yourself doing a 
task over and over, try writing a Perl script to do it for you. Many of 
us learnt this way.

A good book to read is the Perl Cookbook from O'Reilly, 
http://www.oreilly.com/ (ISBN 1-56592-243-3).

	--- Shawn

Page wrote:
> Ok.  I give.  I'm throwing in the towell.  No matter how long I use
> perl, some of the syntax just doesn't make any sense to me.
> 
> Any suggestions on the best place to learn Perl?  I own a 1/2 dozen
> books or so and they are only helpful to a point.
> 
> Is there an online school or should I try to take a night course at
> one of the local colleges?
> 
> I just don't get statements like:
> for (@{$struct->{treemap}->[0]->{rectangle}}) {
>    # do perl stuff here
> }



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

Date: Tue, 14 Sep 2004 21:51:34 GMT
From: none@anytime.net (ft4bredn)
Subject: Re: Best place to learn perl?
Message-Id: <GJJ1d.90338$yh.17816@fed1read05>

WOW! I have the "Perl CBT?" thread, and that explanation is what I 
was looking for. I actually understood the way you broke that 
down... Do you know of any books or whatever that break things down 
like that? Expert explanation man!!
ft4bredn

----------------------------------------------
Posted with NewsLeecher v1.0 beta 26
 * Binary Usenet Leeching Made Easy
 * http://www.newsleecher.com/?usenet
----------------------------------------------



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

Date: Tue, 14 Sep 2004 20:54:44 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: hv_iterinit has side effects - who cares about PL theory
Message-Id: <2qot3mF12ad9tU1@uni-berlin.de>

Also sprach Ozgun Erdogan:

[ Perl hash carrying around its own iterator ]

>> The fact that that's the way Perl hashes behave is well known. The
> 
> It may be well known by folks who tried to write OS or DB code in
> Perl. I don't think other users of Perl are really aware of the
> implications of this 'feature'.

It's reasonably clearly laid out in the perldocs on 'each':

	[...]
	
	When the hash is entirely read, a null array is returned in
	list context (which when assigned produces a false (0) value),
	and "undef" in scalar context.  The next call to "each" after
	that will start iterating again.  There is a single iterator
	for each hash, shared by all "each", "keys", and "values" func-
	tion calls in the program; it can be reset by reading all the
	elements from the hash, or by evaluating "keys HASH" or "values
	HASH".
	
	[...]

I would at least expect people to read it when they encounter problems
with iterations over hashes.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Tue, 14 Sep 2004 16:22:14 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <GN6dnbM-k9Nqz9rcRVn-qQ@adelphia.com>

Federico wrote:

> I have problems with a cgi (running as nobody user). The problem is that 
> none kill -9, $cgi_pid or kill $cgi_pid, or kill... whatever is able to 
> kill the processes. But if I run as root user a simple perl -e 'kill(-9, 
> PID)' it is able to kill it.
> 
> Anybody knows what could be happening?

An ordinary user cannot signal a process that's owned by another user. 
Root can.

That's not a Perl question, by the way. You are sending a signal with 
Perl's kill() function, but the answer has to do with process ownership 
and system security, and would have been identical if you had been using 
C's signal() function or the kill command in a shell script.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 14 Sep 2004 16:24:56 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: killing a "nobody's" process and its group
Message-Id: <GN6dnbI-k9MEztrcRVn-qQ@adelphia.com>

A. Sinan Unur wrote:

> That is gibberish.

That was rude. Check the originating address - Obviously English is not 
his first language.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 14 Sep 2004 12:51:45 -0700
From: inetquestion@hotmail.com (Inetquestion)
Subject: perl script to copy mp3 files to your portable mp3 device - inetquestion
Message-Id: <d3cf151.0409141151.40d18c7@posting.google.com>

#####################################################################
###															      ###
###	The purpose of this script is to randomize the loading of mp3 ###
### files from your archive to a portable device of known size	  ###
### size.  ie: rio or some other device which mounts as a drive.  ###	
###		   	   	  	   		 								  	  ###
###	Specify File locations as follows:  c:\temp\whatever	  	  ###
### Would be:  c:\\temp\\whatever							  	  ###
###		  	   												  	  ###
### Wishlist features: 											  ###  
### 1.  Save list of files into a file and	process from that	  ###
### file if present instead of reading the source each time.	  ###
### 2.  Generate playlist based on mp3 tags.	  	   			  ### 
### 	   														  ###
#####################################################################
	
####################################
###  Begin Configurable options  ###
####################################															
$mp3_src="c:\\temp\\source";								#Source location of your MP3 Files
$mp3_dest="c:\\temp\\mp3";									#Destination for files.  ie:  your
mp3 player
$DestSizeMB=512;		  									#Enter destination drive size.  ie:  20 =
20MB
####################################
###   End Configurable options   ###
####################################


use File::Copy;												#Define modules to use
$Dsize=$DestSizeMB*1000*1024;							  	#Convert the size entered to
bytes
&DoStatusDisplay("Space available: $Dsize");				#status
&DoStatusDisplay("Deleting files");		  				   	#status
&DeleteExistingMP3("$mp3_dest");						   	#Deleting pre-existing mp3
files on: <$mp3_dest>

&DoStatusDisplay("getting files");							#status
@mp3source=&GetFilesAndSize("$mp3_src");					#build list of files and
get their size

&DoStatusDisplay("sorting playlist", "\n");					#status
@mp3source=array_shuffle(@mp3source);						#sort array containing mp3
files and sizes

$mp3source_count=@mp3source;								#Number of mp3's on source
location
while ( 1 )													#keep going
{	  
	$z=pop(@mp3source);									  	#pull first file from array and
process
	($size,$file)=split(/\|/,$z,3);							#split array element into
filesize & full path
	$mp3_remaining=@mp3source;								#Number of mp3 files remaining in
array
	if ($mp3_remaining == 0){								#Check for zero
	   last;		   	  								   	#All array elements were exhausted, end
processing.
	}
	if (($Dsize-$size)>0){								 	#Check for destination full			 
	   $Dsize=$Dsize-$size;								   	#Decrement remaining size with
size of current file
	   printf ("%11s\t%-30s\n",&AddCommas($size),$file);	#status
	   copy("$file", "$mp3_dest") or die "copy failed: $!"; #Copy files
from Source -> Destination
	   $i++;		 			  	 	 	   		   		#Increment counter
	   } else {
	   	 printf ("%11s\t$file -- skipped.  File is to large for remaining
space: %-11s\n",&AddCommas($size),&AddCommas($Dsize));
	   } 
}

print "\n\nMp3's Loaded: $i\n"; 	 		   		   	  	#status
printf ("Bytes available: %-10s\n",&AddCommas($Dsize));		#status
exit;  		   			  									#Bye-Bye!





sub DoStatusDisplay {
	local($message)=shift;
	local($trailer)=shift;
	print "Status:  $message...\n$trailer";
}

sub AddCommas {
    my $text = reverse $_[0];
    $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
    return scalar reverse $text;
}

sub DeleteExistingMP3 {
    local($dir) = shift;					  					
    opendir (DIR, "$dir/");
    @FILES = grep(/.mp3/,readdir(DIR));
    closedir (DIR);
    foreach $FILES (@FILES) {
#			print "Deleting:  $dir/$FILES\n";
			unlink("$dir/$FILES") or die "Can't delete $FILENAME: $!\n";
    }
}

sub array_shuffle {
    my @old = @_;  				  	 	 			   		#Assign local array and set to
value of subrountine inputs
    srand;	  												#no idea
    @new = ();												#creat new array
    for( @old ){											#process all elements
        my $r = rand @new+1;								#no idea
        push(@new,$new[$r]);								
        $new[$r] = $_;
    }
	return @new;   	  										#Return sorted array to calling function
}

sub GetFilesAndSize {
	local($dir) = shift;		  	 	 			   		#assign subroutine inputs to
local variable
    local($path); 											#local variable
	    unless (opendir(DIR, $dir)) {						#Check status of directory
        warn "Can't open $dir\n";
        closedir(DIR);	 		 							#close filehandle
        return;												
    }
    foreach (readdir(DIR)) {	 	 	 			   		#process all contents in
directory
        next if $_ eq '.' || $_ eq '..'; 			   		#Skip . & ..
        $path = "$dir/$_";	 	   		 			   		#Concatenate file and path
to get full path
        if ((-d $path) && (! -l $path)) {			   		#Non-symlink dir,
enter it
            &GetFilesAndSize($path);						#Get it recursively
        } elsif ((-f _) && (! -l $path)) {					#Plain file, but not a
symlink
            $size = -s $path; 	 		 					#Get the size in bytes
			$ksize = $size / 1000;							#Convert to kilobytes 
			push(@temp_array,"$size|$path");				#Load current element onto
array
		}
    } closedir(DIR);										#Be a good boy and clean up after
yourself
	return @temp_array;										#Return loaded array to calling function
}


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

Date: 14 Sep 2004 21:37:04 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: perl script to copy mp3 files to your portable mp3 device - inetquestion
Message-Id: <Xns9564A90B33C3castleamber@130.133.1.4>

inetquestion@hotmail.com (Inetquestion) wrote in
news:d3cf151.0409141151.40d18c7@posting.google.com: 

[ snip garbage ]

Was that Perl? Perl 4 probably?

 ... my eyes! my eyes!

-- 
John                               MexIT: http://johnbokma.com/mexit/
                           personal page:       http://johnbokma.com/
        Experienced programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html


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

Date: Tue, 14 Sep 2004 21:52:28 +0200
From: mbens@hotmail.com (Matt Benson)
Subject: Regular expression to match month number 1,...,12 (including e.g. 04,05)
Message-Id: <ci7i5r$c56$00$1@news.t-online.com>

How does a regular expression look like which should match exactly one of the
twelve possible month numbers
1,...,12
Prepending a zero to one-digit month numbers should be allowed e.g. 07

Matt



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

Date: Tue, 14 Sep 2004 13:06:09 -0700
From: Paul Lutus <nospam@nosite.zzz>
Subject: Re: Regular expression to match month number 1,...,12 (including e.g. 04,05)
Message-Id: <10kejpk2ctu3a68@corp.supernews.com>

Matt Benson wrote:

First, DO NOT CROSS-POST as you are doing. Choose at most two newsgroups.

> How does a regular expression look like which should match exactly one of
> the twelve possible month numbers
> 1,...,12
> Prepending a zero to one-digit month numbers should be allowed e.g. 07

Simple, but you need to say which language/utility/command you plan to
process the expression. The below won't find the single-digit versions, but
it will work for the double-digit forms:

(01|02|03|04|05|06|07|08|09|10|11|12)

Unambiguously and uniquely finding all the delimited cases is slightly more
complex.

-- 
Paul Lutus
http://www.arachnoid.com



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

Date: Tue, 14 Sep 2004 11:08:36 -0700
From: Michael Slass <miknrene@drizzle.com>
Subject: Re: Running as a Service
Message-Id: <m33c1kafkr.fsf@eric.rossnet.com>

"Barry_Alder" <alder.bw@forces.gc.ca> writes:

>I have a PERL script that I want to run as a service in Windows NT4 and
>2000, but it stops whenever I log off the server. While I'm logged on, it
>works fine. I am using SRVANY.exe to run it. In the SRVANY documentation,
>it mentions that I must be set up to ignore the CTRL_LOGOFF_EVENT.
>Unfortunately, I haven't been able to find any documentation on how to do
>this. Can someone point me in the right direction?
>
>Thanks,
>
>Barry
>

There are packages available for implementing Perl programs as Win32
services directly.

One is Win32::Daemon::Simple, which ActiveState package manager can
find for you. (search with hyphens instead of ::)

Here's a toolkit (found with google: perl windows service)
http://downloads.builder.com/thankyou.aspx?docid=76459&promo=500222&view=76459


You can also write a small c wrapper for your perl script that will do
all the things the SCM expects, like handling SCM events and system
messages.   There are examples on the web of how to do this
to run a Java program as a service; those could easily be adapted to
start a perl script.
-- 
Mike Slass


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

Date: Tue, 14 Sep 2004 16:28:33 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Screen Size
Message-Id: <HYOdnTrQUIzvydrcRVn-gg@adelphia.com>

Rich wrote:

> Does anyone know how to get the screen size of the client using
> straight Perl (no javascript)?

Client? Javascript? Are you talking about web programming?

>  I have seen several posts which use
> "ioctl.ph" but I have been unable to locate this file.

Oh, I guess you're not talking about web programming.

Well, what *are* you talking about then? A text console? A GUI?

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Tue, 14 Sep 2004 19:25:05 GMT
From: les0624@_cox.net
Subject: Using RE's to match a word split across lines?
Message-Id: <XlH1d.297976$Oi.14402@fed1read04>

I'm trying to match specific words in a file that get split across lines,
and end with a newline. The problem is that I do not know where in the word
it will be split. Take for example, if I'm trying to find the word "Camel",
followed by a newline. The input file may contain:

Word1 word2 word3 Cam
el

OR

Word1 word2 word3 word4 Came
l

OR

Word1 C
amel

etc...

I want to match all of the above, as they all have the word "Camel", with
"\s" whitespace somewhere inside the word, and a newline at the end of the
word.
Is there an easy way to match all of the above using RE's perhaps with the
"\s" modifier?

Thanks,
Les.


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

Date: Tue, 14 Sep 2004 22:15:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Using RE's to match a word split across lines?
Message-Id: <2qp1rcF11g1b1U1@uni-berlin.de>

les0624@_cox.net wrote:
> I'm trying to match specific words in a file that get split across
> lines, and end with a newline. The problem is that I do not know
> where in the word it will be split. Take for example, if I'm trying
> to find the word "Camel", followed by a newline. The input file may
> contain:
> 
> Word1 word2 word3 Cam
> el
> 
> OR
> 
> Word1 word2 word3 word4 Came
> l
> 
> OR
> 
> Word1 C
> amel
> 
> etc...
> 
> I want to match all of the above, as they all have the word
> "Camel", with "\s" whitespace somewhere inside the word, and a
> newline at the end of the word.

> Is there an easy way to match all of the above using RE's perhaps
> with the "\s" modifier?

Of course there are solutions to the problem. I for one would like to
see the code you have tried so far.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Tue, 14 Sep 2004 20:24:21 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Using RE's to match a word split across lines?
Message-Id: <VrI1d.6729$IO5.3481@trndny04>

<les0624@_cox.net> wrote in message
news:XlH1d.297976$Oi.14402@fed1read04...
> I'm trying to match specific words in a file that get split across
lines,
> and end with a newline. The problem is that I do not know where in the
word
> it will be split. Take for example, if I'm trying to find the word
"Camel",
> followed by a newline. The input file may contain:
>
> Word1 word2 word3 Cam
> el
>
> OR
>
> Word1 word2 word3 word4 Came
> l
>
> OR
>
> Word1 C
> amel
>
> etc...
>
> I want to match all of the above, as they all have the word "Camel",
with
> "\s" whitespace somewhere inside the word, and a newline at the end of
the
> word.
> Is there an easy way to match all of the above using RE's perhaps with
the
> "\s" modifier?

My solution would be:
1) read the entire file into one large string [1]
2) remove the newlines from this string.
3) look for your word.

[untested]
#!/usr/bin/perl
use strict;
use warnings;

local $/;  #enable slurping
open my $file, 'filename.txt' or die "Cannot open file: $!";
my $contents = <$file>;  #read whole file;
$contents =~ s/\n//g;  #remove newlines
if ($contents =~ /\bcamel\b/i) {
    print "The file contained 'Camel'\n";
}
__END__

Modify the above as needed to suit your exact purposes.

Paul Lalli

[1]  This will become increasingly inefficient as the size of the input
file grows, as the entire file will have to reside in memory.




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

Date: Tue, 14 Sep 2004 21:26:44 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Using RE's to match a word split across lines?
Message-Id: <x7y8jcv8ys.fsf@mail.sysarch.com>

>>>>> "PL" == Paul Lalli <mritty@gmail.com> writes:

  PL> My solution would be:
  PL> 1) read the entire file into one large string [1]


  PL> local $/;  #enable slurping
  PL> open my $file, 'filename.txt' or die "Cannot open file: $!";
  PL> my $contents = <$file>;  #read whole file;

might as well do a module plug:

use File::Slurp ;

	my $contents = read_file( 'filename.txt' ) ;

shorter, clearer and faster. pick all three! :)

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 14 Sep 2004 11:59:02 -0700
From: Alan Balmer <albalmer@att.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <nofek0lliu5f8l6veemppumnrp31f5d1nq@4ax.com>

On Tue, 14 Sep 2004 19:13:41 +0300, Bulent Murtezaoglu <bm@acm.org>
wrote:

> Not that the replacement would be any better necessarily (indeed
>he might be worse in many ways), but this kind of poor judgement needs
>to have political consequences domestically. 

So, for the sake of Bush getting what you consider his just desserts,
you are willing to have a replacement who would be worse. In the
middle of a war.

People like you frighten me.

-- 
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net


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

Date: Tue, 14 Sep 2004 12:05:39 -0700
From: Alan Balmer <albalmer@att.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <r6gek0diq28jqi0ie18hku87r8865lt3p8@4ax.com>

On 14 Sep 2004 10:15:27 -0700, Patrick Scheible <kkt@drizzle.com>
wrote:

>Chuck Dillon <spam@nimblegen.com> writes:
>
>> Coby Beck wrote:
>> 
>> >>
>> >>And, of course, entertaining the possibility that his agenda is just
>> >>what he says it is, is completely out of the question.
>> > Not out of the question, be obviously untrue.
>> 
>> Again, I'll point out that it is naive to put this entirely on the
>> administration.  We're in Iraq because we effectively declared
>> war. The dance with the U.N. went on for some 3 months.  It was clear
>> where we were headed.  Our congress, including Kerry and all of the
>                                                           ^^^
>Not all.  I'm happy to say my representative and one of my senators
>voted against the resolution authorizing the war.
>
>Congress doesn't have its own intelligence service.  If the
>administration claims to have clear evidence that a country has WMD
>there's only so much that a minority party in congress can do to find
>out if the administration is lying or engaged in wishful thinking.

http://intelligence.house.gov/
http://intelligence.senate.gov/

-- 
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net


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

Date: Tue, 14 Sep 2004 12:09:21 -0700
From: Alan Balmer <albalmer@att.net>
Subject: Re: Xah Lee's Unixism
Message-Id: <h9gek09d62651te861d33nhvqgqm4htdf5@4ax.com>

On 14 Sep 2004 09:52:15 -0700, Patrick Scheible <kkt@drizzle.com>
wrote:

>Morten Reistad <firstname@lastname.pr1v.n0> writes:
>
>> I do not agree. Kennedy and  Clinton had a lousy foreign-policy
>> record. The Bay of Pigs, Vietnam, the Cuba crisis were all 
>> examples of glorious miscalculations. Ditto Rwanda, Somalia, and
>> the 
>
>Vietnam was certainly a catastrophe, but the blame goes to Johnson,
>not Kennedy.  There were only a few thousand U.S. troops in training
>and advisory roles in Vietnam by Kennedy's assassination.  Johnson
>decided to escalate the war and have U.S. forces fight directly.
>
>Even the best presidents can't have nothing but successes.  The Bay of
>Pigs was a failure, but at least Kennedy didn't compound the mistake
>by sending in U.S. troops where Cuban expats failed.
>
I didn't get the reference to the "Cuba crisis", either. I assume it
refers to the missile crisis (which kept me in Oakland for a week
while the Army decided which country to send us to.) I thought it was
the Cubans and Russians who miscalculated that one.

-- 
Al Balmer
Balmer Consulting
removebalmerconsultingthis@att.net


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

Date: Tue, 14 Sep 2004 11:26:36 +0200
From: lin8080 <lin8080@freenet.de>
Subject: Re: Xah Lee's Unixism
Message-Id: <4146B94C.35120847@freenet.de>



Steve O'Hara-Smith schrieb:
> 
> On Sat, 11 Sep 2004 23:30:28 +0200
> lin8080 <lin8080@freenet.de> wrote:

> > Steve O'Hara-Smith schrieb:

> > >         One thing I always found amusing is the amount of science *fiction*
> > > written in the first half of this period about what would happen if the
> > > worlds computers became linked together.

> > Hi,
> > as long as nothing new goes in, nothing. Maybe we read yesterdays
> > papers?

>         Most of the SF carried the assumption that once a certain level of
> complexity was reached the network would "wake up" as some kind of self aware
> intelligence.

Collecting Neurons do not make a spirit.
To wake-up needs an event - every program waits for a call.
Adding AI-Routines will not produce sense for human interpreters.
Leaving the mediante among humans needs a purpose. (possible makeable)
 ...

Hmmm. Like a big bang or so many small steps no one could realised?
Mystify viewpoint - 
 ... searching for controller(s) ...

stefan

be aware of self recocnition




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 7140
***************************************


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