[7823] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1448 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 10 15:17:15 1997

Date: Wed, 10 Dec 97 12:00:24 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 10 Dec 1997     Volume: 8 Number: 1448

Today's topics:
     a certain bug...!!! <Christian.Khoury@inria.fr>
     Re: a certain bug...!!! <zenin@best.com>
     Re: Anyone done any utmp/wtmp stuff with Perl? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Copy complete Directory Tree (Jvrn Bodemann)
     Re: Copy complete Directory Tree (I R A Aggie)
     format NAME = <prl2@lehigh.edu>
     GIFgraph legend <tedgren@ford.com>
     Re: Help with a regex (Mick Farmer)
     Re: Local Array initialized to a constant <zenin@best.com>
     Re: Local Array initialized to a constant (Mike Stok)
     Looking for Perl Spreadsheet <tory1@IDT.NET>
     Looking for Perl Spreadsheet <tory1@IDT.NET>
     Re: mass mailings from Perl:  fonts? scott@softbase.com
     Moved to comp.lang.perl.modules <tedgren@ford.com>
     Re: Need help stripping whitespace <carse@ibm.net>
     need to know what browser the client is using <ric@megsinet.net>
     PERL CGI Parsing <75762.2332@CompuServe.COM>
     RE: Perl NT Build313 source "ntole.cpp" compile error rehana@allmedia.com
     Re: Perl Plug-In for Netscape? (Thaths)
     Please advise. Fastest way to line-count files <ravi@centtech.com>
     Re: Please advise. Fastest way to line-count files <zenin@best.com>
     Re: Please advise. Fastest way to line-count files <tchrist@mox.perl.com>
     print buffer flush <mxu@eecs.ukans.edu>
     Re: print buffer flush <tycage@infi.net>
     Q: find.pl or find.pm with variable <pivari@geocities.com>
     Re: Referring to Perl modules on the net? <zenin@best.com>
     Re: Removing Files older than 14 days (Faust Gertz)
     There's More Than One Way? <jdporter@min.net>
     Re: translate forms to mail (Faust Gertz)
     trapping errors from IPC::Open2 (Robert L. Urban)
     Wanted: Perl5 script to scan+kill POP3 mailbox <amb26@ponder.demon.co.uk>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Dec 1997 19:35:39 +0100
From: Christian Khoury <Christian.Khoury@inria.fr>
Subject: a certain bug...!!!
Message-Id: <348EE0FB.2DF49077@inria.fr>

hi, i'm new to Perl, so mind my "stupid" question..:-)

i read in "Programming Perl" (2nd edition) that i just need to add a
"+>" to a file's name to be able to open it in read write mode...i tried
it and it failed....but with "+<", it worked fine...

is this a known bug?

Thanx,
	Christian

-- 
Christian Khoury
INRIA - Projet SOR - B.P. 105 - 78153 Le Chesnay Cedex - FRANCE
Tel : +33 1 39 63 51 33      e-mail : Christian.Khoury@inria.fr


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

Date: 10 Dec 1997 19:41:59 GMT
From: Zenin <zenin@best.com>
Subject: Re: a certain bug...!!!
Message-Id: <881783135.482217@thrush.omix.com>

Christian Khoury <Christian.Khoury@inria.fr> wrote:
: i read in "Programming Perl" (2nd edition) that i just need to add a
: "+>" to a file's name to be able to open it in read write mode...i tried
: it and it failed....but with "+<", it worked fine...
:
: is this a known bug?

	I have no idea, and neither will anyone else.  You need to include
	the following if you can hope for anyone to help you:

	Your CODE!  Exactly as it is in your file, and it better have the -w
	flag as in "#!/usr/local/bin/perl -w" or you'll probably just get
	flamed since it's all over the standard docs and far to easy to do.

	What, _exactly_ you _thought_ the code should do.

	What, _exactly_ the code _did_ do (ie, HOW did it "fail"???).

	Any, and _ALL_ error messages.

	Any if need be, the complete output of "perl -V".

	To take a wild guess, you might just be getting surprised by the
	fact that "+>filename" will truncate the file to 0 bytes if it
	already exists, and thus you can't read anything from it because
	it's been nuked.

-- 
-Zenin
 zenin@best.com


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

Date: Wed, 10 Dec 97 11:58:31 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Anyone done any utmp/wtmp stuff with Perl?
Message-Id: <348eca46$3$ofn$mr2ice@speaker>

In <66ik7a$r6c$1@hermes.bit.net.au>, on 12/09/97 at 03:14 PM,
   "Andrew Pollock" <apollock@bit.net.au> said:
+-----
| I'm about to wade through CPAN, but I thought I'd ask here first...
+--->8

It'd be more productive for you to reverse your causality next time.

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)


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

Date: Wed, 10 Dec 1997 19:08:29 +0100
From: bodemann@do.isst.fhg.de (Jvrn Bodemann)
Subject: Copy complete Directory Tree
Message-Id: <MPG.ef8f90bfd8b3f3d989684@news>


Hello to the Perl community,

I have seached the module list and the FAQs
for a module or a function which is able to
copy a complete directory tree including all
files and dirs.

Any ideas?

Jvrn


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

Date: Wed, 10 Dec 1997 14:24:46 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Copy complete Directory Tree
Message-Id: <-1012971424470001@aggie.coaps.fsu.edu>

In article <MPG.ef8f90bfd8b3f3d989684@news>, bodemann@do.isst.fhg.de (Jvrn
Bodemann) wrote:

+ Hello to the Perl community,
+ 
+ I have seached the module list and the FAQs
+ for a module or a function which is able to
+ copy a complete directory tree including all
+ files and dirs.
+ 
+ Any ideas?

Ummm...

system "cp -r /tree/to/be/copied/ /place/to/be/copied/to/";

?? If you want a pure perl program, you'll have to use the File::Find 
and File::Copy modules, and program in that functionality.

Alternatively, you could use File::Listing and File::Copy. I haven't done
a step-down-a-directory tree program, so my advice may not be worth much.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 10 Dec 1997 19:00:21 GMT
From: "Phil R Lawrence" <prl2@lehigh.edu>
Subject: format NAME =
Message-Id: <01bd059d$da8cb220$3e03b480@mm>

Some of the addresses returned in the code below have only 1 or 2 of the 3
possible address lines.  Is there a way to modify the format statament to
cut those lines if unused?  If no, what way would anyone recommend I get
around this?  

I was thinking I would do something like the following if I can't modify my
current format statement:

if ($street_line2 eq "") {
	select FILEHANDLE;
	$~ = '1_LINE_ADDR_REPORT'
} elsif ($street_line3) {
	select FILEHANDLE;
	$~ = '2_LINE_ADDR_REPORT'
} else {
	select FILEHANDLE;
	$~ = '3_LINE_ADDR_REPORT'
}

I hate to do that because of the major redundancy entailed in creating the
3 different format definitions.


EXISTING CODE:
 ...
format REPORT =
LAST NAME:  @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
			$last_name
FIRST NAME: @<<<<<<<<<<<<<<<  MI: @<<<<<<<<<<<<<<<  STUDENT ID:@<<<<<<<<
			$first_name,     $spriden_mi,			$id
ADDRESS:     @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
		 	$street_line1
                      @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
			$street_line2
                      @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
			$street_line3
                      @<<<<<<<<<<<<<<<<<<<, @<<
			$city,	         $stat_code
                      @>>>>>>>>>  @>>>>>
		 $zip, 		$natn_code
 .

 ...

	while ( 	($id,
		$last_name,
		$first_name,
		$mi,
		$apdc_code,
		$street_line1,
		$street_line2,
		$street_line3,
		$city,
		$stat_code,
		$zip,
		$natn_code,
		) = $sth->fetchrow_array) {
		$id		= 	($id)		?  $id		: "";
		$last_name	= 	($last_name)	?  $last_name	: "";
		$first_name	= 	($first_name)	?  $first_name	: "";
		$mi		= 	($mi)		?  $mi		: "";
		$apdc_code	= 	($apdc_code)	?  $apdc_code	: "";
		$street_line1	= 	($street_line1)	?  $street_line1	: "";
		$street_line2	= 	($street_line2)	?  $street_line2	: "";
		$street_line3	= 	($street_line3)	?  $street_line3	: "";
		$city		= 	($city)		?  $city		: "";
		$stat_code	= 	($stat_code)	?  $stat_code	: "";
		$zip		= 	($zip)		?  $zip		: "";
		$natn_code	= 	($natn_code)	?  $natn_code	: "";
		write REPORT;
	}
-- 
Phil R Lawrence
Systems and Networking Development Services
Programmer/Analyst
prl2@lehigh.edu


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

Date: Wed, 10 Dec 1997 11:32:43 -0500
From: Tim Edgren <tedgren@ford.com>
Subject: GIFgraph legend
Message-Id: <348EC42B.5171@ford.com>

I've looked at (and run) the sample scripts for Martien's GIFgraph, but
don't seem to find a way to build a legend among the option
documentation.  Is there a way to use the logo option (or some other
way) to show a dynamically-built legend?

I'm currently using gnuplot (which supports legends, albeit rather
inflexibly) but I'd rather have a bit more control over my various
graphs.


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

Date: Wed, 10 Dec 1997 17:19:58 GMT
From: mick@picus.dcs.bbk.ac.uk (Mick Farmer)
Subject: Re: Help with a regex
Message-Id: <EKzHHA.C1r@mail2.ccs.bbk.ac.uk>

Dear Scott,

Try changing your regular expression to something like the
following.

^([^.]+)\.(\d+\.\d+)?\.([PIWMs]+)?.tgz$

Regards,

Mick


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

Date: 10 Dec 1997 17:33:02 GMT
From: Zenin <zenin@best.com>
Subject: Re: Local Array initialized to a constant
Message-Id: <881775400.4502@thrush.omix.com>

[ posted & mailed, and comp.lang.perl.modules removed from list ]

Marc Page <PageMan@BigFoot.com> wrote:
:       local(@code)={
                    /|\
                     |
              Here---|

	Change this to ()s :

	local (@code) = (
		...values
	);

	BTW, my() is better most of the time:

	my @code = (
		...values
	);

-- 
-Zenin
 zenin@best.com


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

Date: 10 Dec 1997 13:28:23 -0500
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Local Array initialized to a constant
Message-Id: <66mn07$6jr$1@stok.co.uk>

In article <B0B420E4-A8CA8@130.164.17.4>,
Marc Page <PageMan@BigFoot.com> wrote:
>I'm trying to initialize a local array variable to a list of string
>constants.  Here is what I tried:
>
>	local(@code)={
>	            "7CE8C9A91D953C06E384D1351400", 	#0

  [...]

You need to use () around the list rather than {}  The {} put the enclosed
list into an anonyous hash and return a reference to it, which in your
case will be the sole element of @code.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 10 Dec 1997 15:57:07 GMT
From: James Frogel <tory1@IDT.NET>
Subject: Looking for Perl Spreadsheet
Message-Id: <66me4j$ggk@nnrp3.farm.idt.net>

Anybody have code for a perl spreadsheet

Thanks in Advance

Jim


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

Date: 10 Dec 1997 16:39:57 GMT
From: James Frogel <tory1@IDT.NET>
Subject: Looking for Perl Spreadsheet
Message-Id: <66mgkt$hjc@nnrp3.farm.idt.net>

Anybody got code for a Perl spreadsheet??

Thanks in Advance

Jim


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

Date: 10 Dec 1997 19:07:44 GMT
From: scott@softbase.com
Subject: Re: mass mailings from Perl:  fonts?
Message-Id: <66mpa0$dmr$6@mainsrv.main.nc.us>

Phil R Lawrence (prl2@lehigh.edu) wrote:
> I am trying to think of a way to do mass mailing letters from Perl.
> Big question:  Can I use different fonts printing from Perl?

It depends on what you're printing! If your script emits RTF, HTML,
PostScript, troff, or something you could change the font. This depends
more on the output than Perl itself.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: Wed, 10 Dec 1997 11:43:55 -0500
From: Tim Edgren <tedgren@ford.com>
Subject: Moved to comp.lang.perl.modules
Message-Id: <348EC6CB.7FE5@ford.com>

Apologies.  This question probably belongs in comp.lang.perl.modules.


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

Date: Wed, 10 Dec 1997 11:15:26 -0700
From: "John Carse" <carse@ibm.net>
Subject: Re: Need help stripping whitespace
Message-Id: <348edce2.0@news1.ibm.net>

cc'd to Rob Braden manually!

Rob Braden wrote in message <348d78e8.4607544@snews.zippo.com>...
>Hi!
>  I've got a problem. We've got some software here that is munging
>some data. In particular, it's inserting spaces into URLs, which is a
>bad thing, obvioulsy. I don't have the source to this particular
>program, and it's critical to our operations, so I just have to wait
>patiently for a patch from the vendor.
>
>In the meantiime, I need to write a program that wil identify and
>remove any whitespace within the URLs - there may be more than one URL
>per line. I'm pretty new to Perl, and this one's got me scratching my
>head. I'm sure I could figure it out, but I need it quick! Any
>assistance will earn my eternal gratitude, and  I'll buy you dinner if
>you're ever in the neighborhood.
>
>Thanks!
>Rob Braden
>rob@gadgetguru.com

I think I have your solution:

open(HTM, "testcase.htm");
while (<HTM>) {
 print;
 if (/([\S+\s+]*):\/\/(\S+)\s+(\S+)"([\S+\s+]*)/i) { $left = $1; $string =
$2 . $3; $right= $4; }
 if ($string) { print "\n$left:\/\/$string\"$right\n"; } else {print
"\nNOTHING!\n";}
}
close(HTM);

What you really need to pay attention to is the regular expression and the
$1, $2 ... etc.. You'll have to write your own stuff to get re-write the HTM
document, but that shouldn't be difficult, but e-mail me if you want some
help (I'm kinda new to Perl myself; these problems give me practice).

John Carse





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

Date: Wed, 10 Dec 1997 12:39:08 -0600
From: Ricky <ric@megsinet.net>
Subject: need to know what browser the client is using
Message-Id: <348EE1CC.10F4F820@megsinet.net>

hey all!  ok, i'm another one of those perl newbies y'all are probably
sick of but i'm kinda stuck so here's my question.

there's this page i have.  i rigged it with javascript to open another
little window on top of it when it loads (onLoad=littlewindow( ) ), but,
it's a problem with AOL users.  it works fine with netscape and IE, but
totally screws up on AOL.  so, instead of making a regular <a
href="blah.html">link</a>, i made this one --->  <a
href="/cgi-bin/blah.pl">link</a> where blah.pl is a perl script that
checks the client browser and returns the javascripted page for netscape
and IE users, or an alternative page for AOL users.  here's my problem.
i have no idea what "name" for AOL would be in the environment
variable.  shoot, i don't even know the name for netscape or IE.  how
can i check for them if i don't know what to check for?  i thought
netscape's would be Mozilla, but it returns true for IE also, which is
fine but it also returns true for AOL, which is not fine.  in a
nutshell, i need to know what name is used for AOL, IE, and Netscape
that is stored in the HTTP_USER_AGENT environment variable, so i can
differentiate between the browsers thereby getting the desired result.
i didn't think i'd need to provide the script, but if you would like to
see it i'll post it later upon request.  if anyone can help me with
this, i'd appreciate it immensely.  thanks to all gurus in advance and
may ye have the happiest of holiday seasons.

ricky



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

Date: Wed, 10 Dec 1997 13:56:48 -0500
From: Ruben Safir <75762.2332@CompuServe.COM>
Subject: PERL CGI Parsing
Message-Id: <OnL$e1ZB9GA.204@nih2naab.prod2.compuserve.com>

Hello

Perhaps someone can help me with a CGI written in perl that I am 
working on.

The script is taking data from a form which is user edited.  It 
is then
parsed or decoded, then looked up on a database file called 
ussaf.txt.
When a matching key is found, it is the entire database is copied
record by record into a new file, with the changed information.
  Then the newfile is renamed the old file.

I seem to be having trouble with the two opened files.
I am not being permited to open one file for reading
and another for writing.  When I get to the print DATAOUT
command, I'm getting an error message in the Appache log
as follows

Undefined subroutine &main::DATAOUT called at 
/var/lib/httpd/cgi-bin/add_lable.cgi line 27
<DATAIN> chunk1.

Ruben 75762.2332@compuserve.com


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

Date: Wed, 10 Dec 1997 11:51:54 -0600
From: rehana@allmedia.com
Subject: RE: Perl NT Build313 source "ntole.cpp" compile error
Message-Id: <881775941.1905197060@dejanews.com>

The newer ActiveState Perl builds need VC++4.2 or higher, because the
Windows OLE SDK has changed.

Build110 compiles with VC++4.0 only, compilation fails with higher
releases. Build313 compiles with VC++4.2+ (including 5.0) releases.

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


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

Date: 10 Dec 1997 19:10:48 GMT
From: thaths@nospam.com (Thaths)
To: lvirden@cas.org
Subject: Re: Perl Plug-In for Netscape?
Message-Id: <66mpfo$goa2@continuity.mcom.com>

[Posted and mailed]

In article <66mf11$27k$2@srv38s4u.cas.org>,
	lvirden@cas.org writes:
> According to Alex Tang  <altitude@ren.us.itd.umich.edu>:
>:I'm not sure if this is what you're talking about, but try
>:http://interact.canoe.ca/~bsugars/nsapi_perl.htm
> 
> when I attempt access to that page, I get:
> 
> Not Found


It is now available from CPAN.

http://language.perl.com/CPAN/modules/

Thaths
-- 
                 "He who laughs last gets dirty stares."
                   http://people.netscape.com/thaths/
                    %remove_this%thaths@netscape.com


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

Date: Wed, 10 Dec 1997 11:10:00 -0600
From: Ravi Kumar <ravi@centtech.com>
Subject: Please advise. Fastest way to line-count files
Message-Id: <348ECCE8.718A@centtech.com>

All,

	I have 2 sets of files. The first set is a bunch of 
small (<10K lines) files. The second set is a bunch of large
(> 200K lines ) files. I need to line-count these. 
1. I have found that perl is faster than wc(1)
2. In perl I can do it in two ways.
A1:
open FH, $file;
while (<FH>){$linecount++}
 ...   
  OR
A2:
open FH, $file;
@jj = <FH>;
$linecount = $#jj + 1;

Here are the nebulosities.
1. Which approach is faster for small/large files.
2. For large files, @jj will be massive. How do we deallocate 
   @jj when done (in other words, does @jj=() work instantly???)
3. The file sizes are significant (small files: 3M , large files: 60M
   and all reside on a single server. If I split this job on multiple
   machines, I create congestion and dont gain any time. So looks like
    I have to run this on a single fast machine. 

Appreciate any help on this matter.

 

Cheers,
-- Ravi Kumar, Centaur Technology, 512 418 5738


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

Date: 10 Dec 1997 17:43:24 GMT
From: Zenin <zenin@best.com>
Subject: Re: Please advise. Fastest way to line-count files
Message-Id: <881776022.245134@thrush.omix.com>

Ravi Kumar <ravi@centtech.com> wrote:
	>snip<
: 1. Which approach is faster for small/large files.
	A1, but check out the Benchmark module if you want to be sure.

: 2. For large files, @jj will be massive. How do we deallocate 
:    @jj when done (in other words, does @jj=() work instantly???)

	Yes it's "instant", but not the way you think.  If @jj causes
	perl to suck up some huge amount of memory, @jj = () or undef @jj
	will free(3) it, but only for reallocation.  Ie, your process
	will still have that memory allocated until it exits.  If you
	do another similar huge memory allocation after you do undef @jj
	you malloc(3) any (or at least much, depending) more memory but
	once you have taken memory from the system you can't give it back
	until you exit.

: 3. The file sizes are significant (small files: 3M , large files: 60M
:    and all reside on a single server. If I split this job on multiple
:    machines, I create congestion and dont gain any time. So looks like
:     I have to run this on a single fast machine. 

	I'd suggest if performance is _that_ much of an issue, you might
	think about doing it in C, optimizing it by reading data at the
	native block size and not using stdio.  But then, this wouldn't
	be 2 lines of perl code either. :-)

-- 
-Zenin
 zenin@best.com


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

Date: 10 Dec 1997 18:40:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Please advise. Fastest way to line-count files
Message-Id: <66mnn3$bu2$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    Ravi Kumar <ravi@centtech.com> writes:
:All,
:
:	I have 2 sets of files. The first set is a bunch of 
:small (<10K lines) files. The second set is a bunch of large
:(> 200K lines ) files. I need to line-count these. 
:1. I have found that perl is faster than wc(1)

I'm surprised.

Try this:

    (undef) = <FH> ;
    $count  = $.   ;

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

I'm a programmer: I don't buy software, I write it.
    --Tom Christiansen


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

Date: Wed, 10 Dec 1997 11:09:11 -0600
From: Mousheng Xu <mxu@eecs.ukans.edu>
Subject: print buffer flush
Message-Id: <348ECCB7.167E@eecs.ukans.edu>

Dear Experts and Semi-experts:
	
	I am dealing with very large files, the problem is that the "print"
doesn't follow the order implemented in file. For example,
	
        if(...) {
		......
		<do a lot of things>
		print FILEA, "abc\n";
	}
	print FILEB, "123\n";


You would expect FILEA is written first and FILEB is wrtten second. But
in my program, FILEB is written first, even in the case of true of the
if statement -- just trust me. :)

	The delay could be hours or days!
	So, if I do want the order of printing, what can I do? I am trying to
flush the printing buffer everytime it prints, but there is not a
"fflush" function in Perl.
	Any help is highly appreciated.
	Thanks a lot.

				Sincerely,
				Mousheng Xu


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

Date: Wed, 10 Dec 1997 14:02:32 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: print buffer flush
Message-Id: <348EE748.1FF2AAFE@infi.net>

Mousheng Xu wrote:
> 
>         The delay could be hours or days!
>         So, if I do want the order of printing, what can I do? I am trying to
> flush the printing buffer everytime it prints, but there is not a
> "fflush" function in Perl.

man perlvar

Search for $|

It sets output channels to non-buffered.  You'll need to check out
select in perlfunc as well.

Hope this helps,
  Ty

-- 
+---+
Ty Cage Warren                                           tycage@infi.net
Systems Engineer                                                 InfiNet
Homepage: http://tazer.engrs.infi.net/~tycage
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78  B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------


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

Date: Wed, 10 Dec 1997 19:23:02 +0000
From: Fabrizio Pivari <pivari@geocities.com>
Subject: Q: find.pl or find.pm with variable
Message-Id: <348EEC16.2C67@geocities.com>

Hi,

Why I can't use sub wanted with a varible, for example

$match="pdf";
sub wanted {/$match/ && print "$name\n";}    ?

Thanks in advance
-- 
     _/_/_/_/ _/_/_/     Fabrizio Pivari
    _/       _/    _/   mailto:pivari@hotmail.com
   _/_/_/   _/_/_/     mailto:pivari@yahoo.com
  _/       _/         mailto:pivari@geocities.com
 _/       _/         http://www.geocities.com/CapeCanaveral/Lab/3469/


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

Date: 10 Dec 1997 18:02:54 GMT
From: Zenin <zenin@best.com>
Subject: Re: Referring to Perl modules on the net?
Message-Id: <881777189.954551@thrush.omix.com>

Kartik Subbarao <subbarao@aurora.lf.hp.com> wrote:
: 1) I'd like to easily move a script from machine to machine (or mail
: someone a script), and not have to worry if they have the modules installed.

	Remember you also have the problem of platform depend code in many
	of the modules, including native shared libs.  You'd have to say
	something like:
		use Some::Module-1.2-FreeBSD.2.2.5-STABLE;

: 2) As I'm thinking about it, it would also be nice to be able to say "use
: foo-1.2", if I wanted to make sure that I got version 1.2 of foo. Even if
: someone else has a given module, they might have an earlier, perhaps buggy
: version. Or they may have a later version where the interface is no longer
: compatible.

	Well, it does half this. -You can request the min version, but not
	the max.  Hopefully the author of the module wasn't a dingbat and
	didn't change the interface.  Reusable code isn't if the interface
	can't be relied upon.

: Thanks for the pointer. I'll look into it some more. 

	Yes, the CPAN module will probably help. -You can use it to
	auto-install modules anywere you like directly without having
	to do the low level work or (most of the time) have the user
	enter any input.

-- 
-Zenin
 zenin@best.com


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

Date: Wed, 10 Dec 1997 20:01:07 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Removing Files older than 14 days
Message-Id: <348ef05f.1009849@news.wwa.com>

Hugh wrote:

> I am having difficulty writing an efficient script to delete all files in a
> preset directory over a certain age. If a file is older than 14 days I want
> to delete it. There are likely to be upwards of a couple of thousand or so
> files in the directory. How is the best way to check the create dates and
> delete if appropriate. As I said there is no need to recurse subdirs as they
> won't exist. All files to be deleted will have a .ABC suffix, the routine
> should ignore files without this.

Here is some untested code:

1>for (<*.ABC>) { 
2>   undef $1;
3>    /^[*\.ABC)$/;   
4>    (-M $1 < 14) || (unlink $1) || warn "$0 is having trouble
deleting $1: $!";
5>}

Line 1 begins a loop which will go through each filename found by the
glob.  Line 2 and 3 are there to untaint the filenames.  Line 2 makes
sure that you aren't going to try to delete a leftover value in $1 and
line 3 tries to grab the file name and place it in $1.  You will
probably want to change the regular expression in line 3 to suit your
purposes.  Line 4 should check to see if the file has been modified in
the last fourteen days.  If it has, we move on to the next value.  If
it hasn't, we try to delete it with unlink.  If unlink doesn't seem to
want to work, we output a warning.  If you don't care about checking
the return value of unlink or untainting the filenames, you could
probably just write: 

1>for (<*.ABC>) {   (-M $_ < 14) || unlink $_  }

It is up to you.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: Wed, 10 Dec 1997 13:07:28 -0500
From: John Porter <jdporter@min.net>
Subject: There's More Than One Way?
Message-Id: <348EDA60.7850@min.net>

Quoth Larry, "There's more than one way to do it", as we are all aware.

This is interesting, philosophically, because it means that 
For every problem in the universe of problems,
the number of solutions (in Perl) is >= 1.
That is, there are no problems which can not be solved in Perl.

Just a thought... :-)

John Porter
jporter@logicon.com


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

Date: Wed, 10 Dec 1997 19:41:22 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: translate forms to mail
Message-Id: <348dc8d7.11966637@news.wwa.com>

On Tue, 09 Dec 1997 18:41:33 GMT, d.rosmi@pd.nettuno.it (Denis) wrote:

>I would like to know how i could translate some datas inserted in a html form 
>to mail (subject, name, address, etc.)

You could do it by writing a CGI script.  As this is a perl newsgroup,
I recommend you write it in Perl.   :-)

Read the FAQ
(http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html), especially
the sections entitled 'How do I decode a CGI form?' and 'How do I
send/read mail?'.  Then, you might want to look at Robert Seymour's
simple, safe, and generic CGI backend mail script named 'rjsemail.cgi'
at
ftp://uiarchive.uiuc.edu/pub/lang/perl/CPAN/scripts/infoserv/WWW/rjsemail.cgi
for a specific example of what you may seek.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large


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

Date: 10 Dec 1997 16:45:51 GMT
From: urban@rto.dec.com (Robert L. Urban)
Subject: trapping errors from IPC::Open2
Message-Id: <66mgvv$dc$1@rtnews.rto.dec.com>

Hello all,

If the following script is run without arguments, it spits out

	"open3: exec of some cmd and args failed at /tmp/otest line 5"

However, if run with the argument "catch", it simply prints the pid
of the spawned process.  I presume this is because IPC::Open3 is doing
the 'croak' in question in the child process.

Has anyone come up with a decent way of trapping the error?

The script:
------------------ snip snip -----------------
#!/usr/local/bin/perl

use IPC::Open2;

if ($ARGV[0] eq 'catch') {
	eval {
		$pid = open2(\*RDR, \*WTR, 'some cmd and args');
	};
	if ($@) {
		print "open2 failed\n";
		exit;
	} else {
		print "pid=$pid\n";
	}
} else {
	$pid = open2(\*RDR, \*WTR, 'some cmd and args');
	print "pid=$pid\n";
}
------------------ snip snip -----------------

-- 
Rob Urban
Digital Equipment GmbH
Freischuetzstr. 91
81927 Muenchen
Germany


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

Date: Wed, 10 Dec 1997 17:02:12 +0000
From: "A.M. Basman" <amb26@ponder.demon.co.uk>
Subject: Wanted: Perl5 script to scan+kill POP3 mailbox
Message-Id: <348ECB14.6383@ponder.demon.co.uk>

I would like a nice script that, given username, password,
POP3 server, and a file full of regexps, will run through
the mailbox and trash any message whose From address
matches any of the expressions.

Yes, a spam filter.

Does anyone have anything like this?

No, I do not have the time/expertise to write one myself,
at least, not one that I'd trust :)

Antranig.


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 1448
**************************************

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