[24081] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6275 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 18 18:05:40 2004

Date: Thu, 18 Mar 2004 15:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 18 Mar 2004     Volume: 10 Number: 6275

Today's topics:
        chm decompiler <meneerjansen@europe.be>
        count unique values in array <nospam_007@yahoo.com>
    Re: count unique values in array <emschwar@pobox.com>
    Re: count unique values in array <dha@panix.com>
        FIFO problem - yet another .sig rot script... <bik.mido@tiscalinet.it>
        get filename using regexp and if <PerlGuRu2b@bobotheclown.org>
        Help: Deleting Entries in Flat File Database <pin@purdue.edu>
    Re: HOW TO PARSE A VAST FILE! <luke@program.com.tw>
    Re: oracle socket creation <Juha.Laiho@iki.fi>
        perl compilation problems <fdffdas@cpl.net>
    Re: perl2exe can't locate DBI.pm <ittyspam@yahoo.com>
    Re: Printing in Perl <me@privacy.net>
    Re: Printing in Perl (Malcolm Dew-Jones)
        Reading ASCII-Hex file, and saving it as a binary file (Ben Nguyen)
    Re: Reading ASCII-Hex file, and saving it as a binary f <roel-perl@st2x.net>
        Regular Expressions Question (Emil Falcon)
    Re: Regular Expressions Question <ittyspam@yahoo.com>
        Script to scan directories and delete certain dirs (Trev)
    Re: Script to scan directories and delete certain dirs <ittyspam@yahoo.com>
    Re: Simple Sort Keys Question from a Simpleton <bumble@what.the.heck>
        Spring Cleaning V 1.1... <69-no-spam@sandor-communications.hr>
    Re: stripping out ASCII chars using regexp? <bmb@ginger.libs.uga.edu>
        working with multiple handles in perl <abdel.said@galazar.com>
    Re: working with multiple handles in perl <emschwar@pobox.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Mar 2004 21:42:57 +0100
From: "meneerjansen" <meneerjansen@europe.be>
Subject: chm decompiler
Message-Id: <c3d1jd$m5m$1@reader13.wxs.nl>

Greetings,
I'm looking for a Perl script (or a platform-independent exe outputting to
STDOUT) that converts chm (HTML Help) files to text or HTML.
Does anyone know if such program exists?

Thanks for your time,
Janssen




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

Date: Thu, 18 Mar 2004 21:15:42 GMT
From: Don Stefani <nospam_007@yahoo.com>
Subject: count unique values in array
Message-Id: <2ko6c.25814$MK7.20624@newssvr29.news.prodigy.com>

Greetings,

My quest:
Using the results of a query in the form of an array, I'd like to find...
- The number of unique values
- The number of times that each unique value is repeated in the array

Current solution:
To do this I am doing two queries, on for the DISTINCT values
and one for all of the values in bulk

Heres a test script ###

#!/usr/bin/perl
use warnings;
use strict;

my @array1 = qw(12 20 30); # sample distinct query results
my @array2 = qw(12 12 20 30 20 20 20); # sample query results in bulk
my %cnt_hash;

foreach ( @array1 )
{
     my $count = 0;
     my $string = join(' ', @array2);
     $count++ while ($string =~ /\b$_\b/g);
     $cnt_hash{$_} = $count; # hash to use later
}

### check it
foreach my $key (sort keys %cnt_hash)
{
    print "$key => $cnt_hash{$key}\n";
}

# prints
12 => 2
20 => 4
30 => 1
# This is what I want


Ok, that's fine but for the sake of doing it better, what I'd like to figure out is;
How to skip the DISTINCT query and find the distinct values with a regexp from the bulk 
array or string version of the bulk array.

Thanks,

Don


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

Date: Thu, 18 Mar 2004 14:33:10 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: count unique values in array
Message-Id: <eto4qslet7t.fsf@fc.hp.com>

Don Stefani <nospam_007@yahoo.com> writes:
> My quest:
> Using the results of a query in the form of an array, I'd like to find...
> - The number of unique values
> - The number of times that each unique value is repeated in the array
>
> Current solution:
> To do this I am doing two queries, on for the DISTINCT values
> and one for all of the values in bulk

<snip example>

> Ok, that's fine but for the sake of doing it better, what I'd like to figure out is;
> How to skip the DISTINCT query and find the distinct values with a
> regexp from the bulk array or string version of the bulk array.

Use a hash to collect totals:

my %count;
my @values = qw/10 11 12 10 20 20 20 20/;
foreach my $value ( @values ) {
  $count{$value}++;
}

my @values = sort keys %count;

I assume you can figure out how to get the count of each value, yes?

In general, every time in Perl you think "unique" or "distinct", or
"count occurrences", think "I should use a hash."

-=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: Thu, 18 Mar 2004 22:21:57 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: count unique values in array
Message-Id: <slrnc5k885.2mt.dha@panix2.panix.com>

In article <2ko6c.25814$MK7.20624@newssvr29.news.prodigy.com>, Don
Stefani wrote:

> Using the results of a query in the form of an array, I'd like to find...
> - The number of unique values
> - The number of times that each unique value is repeated in the array
> 
> Heres a test script ###
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> my @array1 = qw(12 20 30); # sample distinct query results
> my @array2 = qw(12 12 20 30 20 20 20); # sample query results in bulk
> my %cnt_hash;
> 
> foreach ( @array1 )
> {
>      my $count = 0;
>      my $string = join(' ', @array2);
>      $count++ while ($string =~ /\b$_\b/g);
>      $cnt_hash{$_} = $count; # hash to use later
> }
> 
> ### check it
> foreach my $key (sort keys %cnt_hash)
> {
>     print "$key => $cnt_hash{$key}\n";
> }
> 
> # prints
> 12 => 2
> 20 => 4
> 30 => 1
> # This is what I want
> 
> 
> Ok, that's fine but for the sake of doing it better, what I'd like to figure out is;
> How to skip the DISTINCT query and find the distinct values with a regexp from the bulk 
> array or string version of the bulk array.

I'm not sure exactly why you want to use a regexp.  If I understand you
correctly, would something like this work?

<code>
#!/usr/bin/perl
use warnings; use strict;

my @array = qw(12 12 20 30 20 20 20); # sample query results in bulk
my %hash;
$hash{$_}++ for @array;
print scalar keys %hash, " distinct values\n";
print "Those values have these counts:\n";
print "$_ => $hash{$_}\n" for sort keys %hash;
</code>

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Uh, yeah.  Well, that's my mistake for the year...
        - Larry Wall


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

Date: Thu, 18 Mar 2004 23:17:29 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: FIFO problem - yet another .sig rot script...
Message-Id: <7s7k501nlspece1k34henniocs9qqkj7vo@4ax.com>

<intro>
I'm trying to write a .sig rotation script for client-independet use
by means of a FIFO. This attempt is also and (possibly even) *mainly*
for learning purposes: the fact that I'm encountering the difficulties
described hereafter shows that indeed it is well suited for that...
</intro>

Well, to make a long story brief, I adatped code and suggestions from
'perldoc perlipc' and 'perldoc -q daemon' to conjure up a script
(pasted below with non-significative portions commented out) that
actually works well with e.g. 

  cat .signature

or 

  perl -lpe "" .signature

But when I try it with pine when composing a mail, the process started
by my script dies and .sig is not inserted!

I tried a "simpler", non-daemonized version too, but it behaves quite
in the same way, with a "Broken pipe" message on the tty. Note that
pine's ^R (Insert File) command works seamlessly too.

QUESTION1: is there any way I can fix the script so that it can work
with pine's .sig insertion mechanism too? (whatever it does!)

QUESTION2: once I get this thing working, could you give me your
suggestions about how to modify it so that (i) it avoids running twice
at the same time, (ii) it terminates when the shell it was called in
is exited? (I'd preferably call it in my .bashrc or .bash_profile)


Note: I am aware that both my question and possible answers to it
(especially the 2nd) may have an OT, OS-related component.


  #!/usr/bin/perl
  
  use strict;
  use warnings;
  use POSIX;
  
  $|++;
  setsid;
  (my $home=$ENV{HOME}) =~ s|/$||; # BTW: is s/// necessary?
  my $fifo="$home/.signature";
  
  # [SNIP - redirecting STDOUT, STDIN, STDERR]
  
  while (1) {
      unless (-p $fifo) {
  	unlink $fifo;
  	mkfifo $fifo, 0777 or 
  	  die "Can't mkfifo() `$fifo': $!\n";
      }
      {
  	my $sig = 
  	open my $fh, '>', $fifo or
  	  die "Can't write to `$fifo': $!\n";
  	print $fh do {
  	    # [SNIP - actual content generation]
  	};
      }
      sleep 1;
  }
  __END__


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Thu, 18 Mar 2004 21:37:19 GMT
From: Rocky <PerlGuRu2b@bobotheclown.org>
Subject: get filename using regexp and if
Message-Id: <pan.2004.03.18.21.41.32.413018@bobotheclown.org>

hello everyone 
I have a small issue:
here is code that I wrote (please don't make fun of it as I am a newbie)
to get the highest numbered backuplog from a veritas server via ftp:
@filenums = 0;
foreach $file (@files)  {
        if   ($file  =~ m/([A-Za-z]{2}X)(\d+)(\.txt)/)	{
            push(@letter, $1);
            push(@filenums, $2);
            push(@ext, $3);
	$ext = pop(@ext);
}
if ($file  =~ m/([A-Za-z]{2}X)(\d+)(\.xml)/) {
	push(@letter, $1);
	push(@filenums, $2);
	push(@ext, $3);
	$ext = pop(@ext);
}
}
$letters = pop(@letter);
$highest = (sort { $a <=> $b } @filenums)[-1];
$ftp->get($letters . $highest . $ext) or print FILENAMES $letters . $highest . $ext . "\n";


Please note the last line which prints to a file if it cannot get the file
it wants.  I updated the script to get any file modified in the last 24
hours and bearing the extension .txt or .xml (necessary since some of the
servers have two jobs per night)
here is the new code:

$rightnow = time();
[snip]

 @filenames = $ftp->ls;
foreach  $file (@filenames)      {
 $time = $ftp->mdtm($file);
 $goodfile = $rightnow - $time;
 $ftp->get($file) if ($goodfile < "86400" & $file =~ /.*\.txt|.*\.xml/);

the problem:
whenever I add "or print FILENAMES ..." to the last line it gets every file in
the remote dir.
I must have the files missed as I use them in another script.  Please help
Thank you,
Rocky Allen
Itried changing it to else but that didn't work either


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

Date: Thu, 18 Mar 2004 16:37:54 -0500
From: "TP" <pin@purdue.edu>
Subject: Help: Deleting Entries in Flat File Database
Message-Id: <c3d4rn$q3h$1@mozo.cc.purdue.edu>

Hi all, i am a newbie in Perl and have been playing around with FFD,
and i have succefully scripts for add, read  and search for my database. I
have some problem writing the scripts for deleting entries from my database.

my database  looks like this
john |21 | male | 3553

i wrote a html and ask from a user what name they want to remove from the
database. And for example, if the user enter john, all other field with john
will be deleted.

i know i have to search thru the whole database before i can delete them.
But after i run the script, all my entries are deleted no matter what is the
input from the user.


Here are partial code from my scripts
$del1=$formdata{'del'}; # get the input what user want to delete

#Open DB for Reading

$dbpath = 'dbnew.txt';

open(DB,"$dbpath");
@array=<DB>;
close(DB);

$count =0;
$continue=0;

#check for match
foreach $line(@array){
if($line=~ /$del1/){
$continue++;
}
}

if($continue > 0){
#convert to hash
foreach $line(@array){
$key=$count++;
$value=$line;
$movies{$key}="$value";
}
}
else
{  # go to sub if continue=0
notfound();
}

#use join function to build value search
$delete_value = $del1 ;

#### HOw should i define this $delete_value.. and i believe this has cause
me problem

#remove newline chracters
chomp $delete_value;
chomp %movies;

#get matching key for value
while (($key,$value)=each(%movies)){
if($value eq $delete_value){
#delete the key
delete $movies{$key};
}
}

# Rewrite the file
open(DB,">>$dbpath");
while(($key,$value)=each(%movies)){
print DB"$value\n";
}
close(DB);
}

thanks for any help





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

Date: Fri, 19 Mar 2004 03:09:00 +0800
From: "news.hinet.net" <luke@program.com.tw>
Subject: Re: HOW TO PARSE A VAST FILE!
Message-Id: <c3cs4v$8vo@netnews.hinet.net>

I do this job by follow list.

1. load all data from databse to hash  ($hash{$data}=1)
2. parse data from logfile and find $hash{$data}=1??
if $hash{$data} !=1 then insert into database

i just want to know. if define the IP field in that table as unique, attempt
to batch-insert
everything you've found, and let MySQL handle the uniqueness itself  It's
almost guaranteed to be more efficient than  doing it by above ??




"Glenn Jackman" <xx087@freenet.carleton.ca> ¦b¶l„ó
news:slrnc5jpbb.1c.xx087@smeagol.ncf.ca ¤¤¼¶¼g...
> news.hinet.net <luke@program.com.tw> wrote:
> [...]
> >  i want to find  ip(163.22.3.7  218.172.162.134 ...) that are not exist
in
> >  mysql.
> >  if it is exist in db then reject or insert into db.
> >  the procedure only  do this job.
>
> Are you doing a db insert every time you see a new IP?
> You should store the info until you finish reading the file,
> then do a bulk insert.
>
> -- 
> Glenn Jackman
> NCF Sysadmin
> glennj@ncf.ca




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

Date: Thu, 18 Mar 2004 20:52:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: oracle socket creation
Message-Id: <c3d1vo$qem$1@ichaos.ichaos-int>

Perl GuRu2b <PerlGuRu2b@bobotheclown.org> said:
>DBD::Oracle will be great but I don't know about the ping function.  If it
>gets systime it may be using the system users tablespace and that still
>doesn't tell me if the actual instance is running.

If the instance is down, you can't even select from DUAL - so the ping
will fail. Of course there may still be any number of reasons for the
database not working properly (tablespace in read-only or backup mode;
tablespace offline; disk full; ...), but you will be able to pick whether
or not the instance is up and available. Do the test as a non-privileged
user, and it will also tell you that the instance is not running in
restricted mode.

Of course, having the test table/record is not much different; just make
sure that no-one does clean it up as unnecessary clutter, and you'll also
get confirmation that at least that one tablespace is on-line. But then,
I guess you have more than one tablespaces - so the test is not thorough;
for that you'd need to query a number of Oracle data dictionary tables.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Thu, 18 Mar 2004 13:24:50 -0800
From: "Shawn Ramsey" <fdffdas@cpl.net>
Subject: perl compilation problems
Message-Id: <Eso6c.55657$iO.3863@fe21>

Im trying to compile Perl 5.8.3 on FreeBSD 4.7-STABLE. Its bombing out when
it gets to MIME:Base64. The same module does the exact same error if I try
to compile this module for the currently installed version, which is 5.6.0.
This system doesn't have any other compile issues... Pretty much anything
else I try to compile, will compile just fine :



       Making MIME::Base64 (dynamic)
cc -c    -DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.2/BSDPAN" -DHAS_FPSETMASK -
DHAS
_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include -O -pipe    -DVER
SION
=\"2.21\"  -DXS_VERSION=\"2.21\" -DPIC -fPIC "-I../../.."   Base64.c
Base64.xs: In function `XS_MIME__Base64_decode_base64':
Base64.xs:219: `dowarn' undeclared (first use in this function)
Base64.xs:219: (Each undeclared identifier is reported only once
Base64.xs:219: for each function it appears in.)
*** Error code 1

If anyone has a better suggestion as to where to send this, please tell
me... I've never had a problem compiling perl on any platform before, and it
compiles on another 4.7 (RELEASE) system. The FreeBSD port bombs with the
same error.








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

Date: Thu, 18 Mar 2004 14:09:53 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: perl2exe can't locate DBI.pm
Message-Id: <20040318140750.K21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Bunny wrote:

> Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040318101447.T21521@dishwasher.cs.rpi.edu>...
> > On Thu, 17 Mar 2004, Bunny wrote:
> >
> > > Date: 17 Mar 2004 22:38:02 -0800
> > > From: Bunny <bunny1112@yahoo.com>
> > > Newsgroups: comp.lang.perl.misc
> > > Subject: perl2exe can't locate DBI.pm
> > >
> > > Hi!
> > > I have perl5.00503 loaded on my Linux and I have downloaded and loaded
> > > perl2exe V1.09U on Linux 6.1
> > >
> > > I have written a small code for extracting data from database.  Now my
> > > perl script runs fine and an appropriate output is also rendered by
> > > the web browser.
> > >
> >
> > Have you tried looking at the user's manual for perl2exe, or did you
> > consider asking the world for help your first recourse instead?
> >
> > http://www.indigostar.com/pxman.htm
> > FAQ #15:  How to use DBI with Perl2Exe
> >
> > Paul Lalli
>
> Thanks Paul Lalli!!
> I am sure you would not have gone through my code properly and thats
> you had raised this question.. I had gone through the pxman.htm file
> already and had added the statement "use DBI;"  I also tried adding
> the line "use DBD::mysql;" in my script but still getting the same
> errors?????

I did read your code "properly", and saw that you had not included the
DBD::mysql line.  That's why I sent you to the FAQ.  Regardless, at this
point I have to be wondering if this is simply a bug in the old version of
perl2exe.  Perl2exe's homepage says not to use the version specifically
built for 5.005, even if that's what you 'normally' code with.  Perl2exe's
distribution includes a bundled Perl interpeter, so it doesn't matter what
perl version is installed on your system.  I would suggest downloading the
latest version of Perl2exe and see what happens.

Paul Lalli


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

Date: Fri, 19 Mar 2004 08:07:45 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: Printing in Perl
Message-Id: <c3cs5e$25ui22$1@ID-172104.news.uni-berlin.de>


"Bill Soistmann" <bsoist@sdf.lonestar.org> wrote in message
news:slrnc5jrjt.cbn.bsoist@sdf.lonestar.org...
> Greetings
> I have not used perl in some time and I was wondering if I could ask a
> quick question.

Of course.

>
> Are parenthesis now required for printing? I know that had not always
> been the case.

Actually you need a printer for printing.


>
> If so, I have another quick question
> Is there an option to make old scripts work.

Yes, run them.




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

Date: 18 Mar 2004 11:44:18 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Printing in Perl
Message-Id: <4059fc12@news.victoria.tc.ca>

Bill Soistmann (bsoist@sdf.lonestar.org) wrote:
: Greetings
: I have not used perl in some time and I was wondering if I could ask a 
: quick question.

: Are parenthesis now required for printing? I know that had not always
: been the case.

no.

: If so, I have another quick question
: Is there an option to make old scripts work.

What doesn't work?  We have lots of old scripts that have continued to 
function unaltered for many years through many perl upgrades.  



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

Date: 18 Mar 2004 11:32:59 -0800
From: benn686@hotmail.com (Ben Nguyen)
Subject: Reading ASCII-Hex file, and saving it as a binary file
Message-Id: <e604be8.0403181132.52c846b6@posting.google.com>

I have a file containing ascii characters : 0-9, A-F, and I would like
to convert it to pure binary  (so that every 2 digits in the original file
will produce a single binary byte).

Is there an easy that Perl can make quick work of this??

Ben


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

Date: 18 Mar 2004 20:59:17 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: Reading ASCII-Hex file, and saving it as a binary file
Message-Id: <slrnc5k3d9.ev.roel-perl@localhost.localdomain>

On Thu, 18 Mar 2004 at 19:32 GMT, Ben Nguyen <benn686@hotmail.com> wrote:
> I have a file containing ascii characters : 0-9, A-F, and I would like
> to convert it to pure binary  (so that every 2 digits in the original file
> will produce a single binary byte).
> 
> Is there an easy that Perl can make quick work of this??
> 
> Ben

perldoc -f split

perldoc -f pack



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

Date: 18 Mar 2004 11:12:50 -0800
From: emilfalcon@hotmail.com (Emil Falcon)
Subject: Regular Expressions Question
Message-Id: <effb7e33.0403181112.64f67b87@posting.google.com>

What regular expression must I use to match all lines NOT containing a
certain word? I basically need to sift through a large file and remove
all lines not beginning with the word "Display". Any help would be
appreciated.

Thanks,
Emil.


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

Date: Thu, 18 Mar 2004 14:20:12 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Regular Expressions Question
Message-Id: <20040318141906.G21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Emil Falcon wrote:

> What regular expression must I use to match all lines NOT containing a
> certain word? I basically need to sift through a large file and remove
> all lines not beginning with the word "Display". Any help would be
> appreciated.

while (<FILE>){
	push @good_lines if $_ !~ /^Display/;
}

@good_lines now contains all your good lines.  Do with them as you please.

Paul Lalli


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

Date: 18 Mar 2004 12:25:57 -0800
From: trevor@jpl.co.za (Trev)
Subject: Script to scan directories and delete certain dirs
Message-Id: <790dc6f3.0403181225.5e6d7e1d@posting.google.com>

Hi,

I have a server that saves all our user's windows profiles (Roaming
profiles), Many users have loads of Temp files, cookies and Temporary
internet files.  I would like to write a script that will scan through
all the user profiles and delete the contents of these folders.

Do any of you know of a script that can do this or where I can get
info on how to do this?

Thanks
Trevor


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

Date: Thu, 18 Mar 2004 15:34:01 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Script to scan directories and delete certain dirs
Message-Id: <20040318153235.T21521@dishwasher.cs.rpi.edu>

On Thu, 18 Mar 2004, Trev wrote:

> Hi,
>
> I have a server that saves all our user's windows profiles (Roaming
> profiles), Many users have loads of Temp files, cookies and Temporary
> internet files.  I would like to write a script that will scan through
> all the user profiles and delete the contents of these folders.
>
> Do any of you know of a script that can do this or where I can get
> info on how to do this?

perldoc File::Find
perldoc -f unlink
perldoc -f rmdir


Paul Lalli


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

Date: Thu, 18 Mar 2004 21:14:45 -0000
From: "Bumble" <bumble@what.the.heck>
Subject: Re: Simple Sort Keys Question from a Simpleton
Message-Id: <c3d3d8$e2h$1@news7.svr.pol.co.uk>

James Willmore wrote:
> On Thu, 18 Mar 2004 07:08:19 -0800, Bumble Bee Boy 2 at Google wrote:
> [ ... ]
<snip>
> Now, if you need to print or use the salesperson again, you don't
> have to do something  like "$surname $firstname" all the time :-)
>
> HTH

Thanks Paul and James!

-- 
Bumble
http://bumble.rumble.at
http://www.cossar.co.uk

"PaulB is nowt more than a top-posting fuckwit. Ignore the prat." -
Paul-B




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

Date: Thu, 18 Mar 2004 15:00:48 -0500 (EST)
From: "Agent 69" <69-no-spam@sandor-communications.hr>
Subject: Spring Cleaning V 1.1...
Message-Id: <aTMyNzY4.4310be7a1980541c34e5da8aa798d6c8@1079640048.nulluser.com>

Going through a box of books, I came upon the JC Penney company's Fall & Winter 1997 Catalogue.
I wonder if anyone knows who the gorgeous brunette on the cover is.  I want to know because I 
want to be able to Google for more pictures of her, clothing optional of course.

Anyone know where there are REAL nude pictures of Sophie Marceau and Nina Badrię, the famous Croatian singer?

I want to spring-clean my pipes too if you will...


69
Article Copy 3 of 3 -- corrected and split

Disclaimer:
I'm resending this corrected message with a Supersede header; if your server does
not honour supersedes, please forgive the cyber-detritus they didn't see their way
clear to allow to be erased by the real author.  I also had to cut my message into three
pieces -- to stop the C/-\ble Des(rambler and par{$ H|lt0n se% tape they need to break
some eggs.  Actually I'm glad they do it.




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

Date: Thu, 18 Mar 2004 15:29:50 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: stripping out ASCII chars using regexp?
Message-Id: <Pine.A41.4.58.0403181526200.7672@ginger.libs.uga.edu>

On Thu, 18 Mar 2004, Greg wrote:
> I had:
>
> $_ = $word ;
>
> s/\240//g ;
> s/[\200-\377]//g ;
> tr/\177-\377//d ;
> s/\&#65533//g ;
>
> but i never had the line:
>
> $word = $_ ;

In that case, you probably want to do this:

for( $word ) {
    s/\240//g ;
    s/[\200-\377]//g ;
    tr/\177-\377//d ;
    s/\&#65533//g ;
}

It's the usual Perl idiom, and $_ is properly scoped for you, i.e., you're
less likely to stomp on somebody's else $_.

Regards,

Brad


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

Date: Thu, 18 Mar 2004 15:48:33 -0500
From: Abdel Said <abdel.said@galazar.com>
Subject: working with multiple handles in perl
Message-Id: <hXn6c.7135$kc2.170998@nnrp1.uunet.ca>

Hi,
I'm trying to write a program that watches multiple processes output.
for example:
#################################################################
my %commands = ();
my $command = "ls; cat";
open( $commands{ 1 }, "$command |" ) or die "can't open the command 
'$command' : $!";
open( $commands{ 2 }, "$command |" ) or die "can't open the command 
'$command' : $!";

while( 1 )
{
     foreach my $command ( keys %commands )
     {
	my $handle = $commands{ $command };
         while( <$handle> )                           # <-------------
         {
		print $_;
                 last;
         }
          sleep(4);
     }
}

close( $commands{1} );
close( $commands{2});
#################################################################
What I need is to watch both processes for output. So, the problem here 
is when the "ls" command finished, the "cat" command hangs which is 
normal in the shell but is there a way to know if something to read in 
the buffer.
for example: instead of while( <$handle> ), I need something like, 
while( &issomethinginthebuffer() );
instead of waiting for cat command to display something.


Thanks for any idea.





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

Date: Thu, 18 Mar 2004 14:28:00 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: working with multiple handles in perl
Message-Id: <eto8yhxetgf.fsf@fc.hp.com>

Abdel Said <abdel.said@galazar.com> writes:
> What I need is to watch both processes for output. So, the problem
> here is when the "ls" command finished, the "cat" command hangs which
> is normal in the shell but is there a way to know if something to read
> in the buffer.

Then you want IO::Select.  Alternatively, you can use the
four-argument form of select(), but trust me, IO::Select is much
easier.

-=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: 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 6275
***************************************


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