[8016] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1641 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 14 19:07:19 1998

Date: Wed, 14 Jan 98 16:00:23 -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, 14 Jan 1998     Volume: 8 Number: 1641

Today's topics:
     [Bug]atan2 in Math::Complex returns incorrect signs <P26053@email.mot.com>
     Re: Anyone got a pretty printer for perl? (Bruce Gray)
     Approximate <***armiento@mclink.it***>
     ASIC and Verilog applications of Perl? (Thomas A. Coonan)
     Re: Can Perl talk smtp protocol under NT4? (Martien Verbruggen)
     Re: Comparing strings <doug1@weboneinc.com>
     DBD/DBI and Oracle8 <dwl@slip.net>
     deleting old files (James Amihara)
     Re: deleting old files (Tad McClellan)
     Re: Displaying GIFs - oops (Martien Verbruggen)
     Re: Getting an error in dbmopen <rootbeer@teleport.com>
     Re: Looking for online auction script (Martien Verbruggen)
     multi level scripts output and dynamic code modificatio <hans.leichtl@digital.com>
     Parsing in Perl (Craig Berry)
     printing report using format (Jamshed Nawaz)
     Re: Searching in directories? (Charles DeRykus)
     Re: simple perl script to add directory to PATH if not  (Martien Verbruggen)
     Re: source into binary code (Abigail)
     Re: source into binary code (Abigail)
     Re: source into binary code <wschow@Comp.HKBU.Edu.HK>
     Re: Speaking of Looping through hashes... (M.J.T. Guy)
     Re: Syntax coloring for POD format (Chris Nandor)
     Re: unlink () doesn't work under NT (Martien Verbruggen)
     Re: unlink () doesn't work under NT <rootbeer@teleport.com>
     Re: Why would stat return 12/31/69 (Martien Verbruggen)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Jan 1998 16:28:06 -0700
From: Frank Buntschuh <P26053@email.mot.com>
Subject: [Bug]atan2 in Math::Complex returns incorrect signs
Message-Id: <34BD4A07.8E616B1@email.mot.com>

I think I came across a bug in Math::Complex in the atan2() function.  This is
on perl 5.004_1 under HP-UX, and 5.004 under Sun/Solaris.  I am unable to test
it on any other platforms, but looking at the code seems to support this as a
real bug.  Here is some sample code to create the bug:

-------------------------------------
#!/usr/bin/perl -w

use Math::Trig;

foreach $i (0 .. 24) {
# full circle of angles from 0 to 360
    $deg = $i * 15;
# in radians
    $rad = deg2rad($deg);
# find x and y components
    $x = cos($rad);
    $y = sin($rad);
# get the angle back
    $radout = atan2($y, $x);
    print "$deg\t$rad\t$x\t$y\t$radout\t";
# correct the sign
    $sign = ($x < 0) ? -1 : 1;
    $radout *= $sign;
    print "$radout\n";
}
-------------------------------------

I compared the results to the same input angles in Excel and Matlab - the
results after the sign correction match and are correct.

If this is confirmed as a real bug, I will submit it via perlbug, but I would
like some confirmation first.

advTHANKSance

Frank

+--------------------------------------+-------------------------------+
| Frank Buntschuh                      | Sometimes, the dragon wins.   |
| Frank_Buntschuh-P26053@email.mot.com +-------------------------------+
| Voice: (602)732-4158                 |  Motorola Satellite Comm.     |
| Fax:   (602)732-6702                 |  #include <std.disclaimer>    |
+--------------------------------------+-------------------------------+
------------------------ Remember the Names! ---------------------------


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

Date: Wed, 14 Jan 1998 23:40:48 GMT
From: bgray@mindspring.com (Bruce Gray)
Subject: Re: Anyone got a pretty printer for perl?
Message-Id: <34bb9b9e.93885390@nntp3.mindspring.com>

On 09 Jan 1998 09:42:25 -0700, Randal Schwartz <merlyn@stonehenge.com>
wrote:

>>>>>> "Michael" == Michael Schilli <schilli@tep.e-technik.tu-muenchen.de.> writes:
>
>Michael> Hi everybody,
>Michael> has anyone written a keyword-highlighting, line-numbering program
>Michael> for Perl-Scripts? Just asking before re-inventing the wheel ...
>
>It's nearly impossible in general.  Perl resists all attempts at
>beautification. :-)
-snip-
>    Perl is incredibly difficult to parse.  For example,
>    what's the difference between these:
>
>	    time /3 ;#/; print "hello";
>	    sin /3 ;#/; print "goodbye";
-snip

A Perl to LaTeX converter was announced in c.l.p.announce on Dec 21, 1997
by Chris Traxler <Christoph.T.Traxler@theo.physik.uni-giessen.de> . The
converter uses different fonts, bold, and italics to print comments and
keywords. It does fail Randal's test above; it thinks that the line
containing "hello" has no comments.  It does not number lines, but that
should be easy to add in a preprocessing step. I had to install the teTeX
distribution with it, and tweak the script a little, but the printed output
looks pretty.

A question from the Perl FAQ (3) suggests a better solution:

  How do I cross-reference my Perl programs?                  
    The B::Xref module, shipped with the new, alpha-release Perl
    compiler (not the general distribution), can be used to
    generate cross-reference reports for Perl programs.
       perl -MO=Xref[,OPTIONS] foo.pl                          

If the developers are adding code to the parser to output a
cross-reference, it may not be a far jump to have the parser output
a tagged copy of the program, showing how each element of the sytax was
parsed. After all, since Perl *is* "incredibly difficult to parse", why not
let the real perl parser do the parsing, and then let a pretty printer (or
other utility) processes the pre-parsed Perl program?


Here is the meat of Chris Traxker's announcement:

>I'd like to make an announcement of a C++/Perl->LaTeX
>converter (that produces beautiful program listings). 
>It has many configurable features that allow you to use
>LaTeX formulas and even include EPS pictures in program comments.

>You can download the script at 
 > ftp://krabat.physik.uni-giessen.de/pub/traxler/listing.tgz

>Try it! (to see its main features, try it on itself). You'll love it.
>To use all of its features, you need LaTeX (with makeindex and psfig),
>dvips, xdvi, and psnup running on your system. And, of course, Perl.

>Uh, I should not forget to mention that this software is still beta.

>Regards,

>   Chris






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

Date: Thu, 15 Jan 1998 00:23:34 +0100
From: "Aldo Armiento" <***armiento@mclink.it***>
Subject: Approximate
Message-Id: <69jhi0$qhu@news1.mclink.it>

If in a $var I have the value 1.74234234 there are a command that assign to
$var2 the truncate value 1 or approximate value 2 ?

thanks, Aldo.




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

Date: Wed, 14 Jan 1998 23:07:12 GMT
From: tcoonan@mindspring.com (Thomas A. Coonan)
Subject: ASIC and Verilog applications of Perl?
Message-Id: <34bd43fc.648349@news.mindspring.com>

I just started using Perl.  It's great.  It'll help a lot with my
scripting related to Verilog and ASIC design.  I'm especially
interested in techniques for parsing through Verilog code:
looking for modules, reporting on various things, etc. etc.
I'd love to see some samples.  Would anyone share?
I did some WWW searches and didn't come up with
much, except for Celia's page, but she's doing mostly
Synopsys scripts.

tom coonan
Scientific Atlanta

tcoonan@mindspring.com



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

Date: 14 Jan 1998 22:14:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Can Perl talk smtp protocol under NT4?
Message-Id: <69jdbu$61g$4@comdyn.comdyn.com.au>

In article <34bda3f3.2823013468@news.mmc.org>,
	drummj@mail.mmc.org (Jeffrey R. Drumm) writes:

> Net::Domain::_hostname(D:\Perl5.04\lib\site/Net/Domain.pm:55):
> 55:             chop($host = `(hostname) 2>/dev/null`); # BSD'ish
>   DB<1>
> The system cannot find the path specified. << 1st error

I seem to remember that on win32, you can either use a path specified
with the backslash as a specifier OR a normal slash. You're not
allowed to mix them. I suppose that that might be the source of the
error.

Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Wed, 14 Jan 1998 17:40:08 -0500
From: Douglas Clifton <doug1@weboneinc.com>
Subject: Re: Comparing strings
Message-Id: <34BD3EC7.64735FF2@weboneinc.com>

John Porter wrote:

> Kyle wrote:
> >
> > > I kind of new to perl and am trying to compare two strings but when I
> > > use:
> > > if ($string1 == $string2) it doesn't work... it's always true.  I thought
> > > that was legal.
>
> Sure it's legal, but it's still wrong.  To compare strings, you should
> use
> cmp, not ==, like so:
>
>     if ( $s1  cmp  $s2 ) { ...
>
> > > I've tried /$string1/g == $string2  but there are brackets in $string1
> > > and it keeps saying:
> > > unmatched [] in regexp at .... line ..
> > >
> > Oops... the /$string1/g == $string2 is supposed to be:
> > /$string1/g =~ $string2
>
> You're way off.  =~ is the operator which binds (applies) a regular
> expression on the RIGHT to a plain string on the LEFT.
> Regular expressions are typically enclosed in // (slashes).
> So the following would be valid:
>
>     if ( $s1  =~  /$s2/ ) { ...
>
> The expression is true if the string on the left is matched by
> the regex on the right.
> Unfortunately, the construct ( /$s1/ =~ $s2 ) is also legal,
> although not likely EVER to be what you want.
>
> In any case, you wanted to do a simple string comparison: cmp.

Wrong, wrong, wrong use `eq'. cmp is for sort:

if ($s1 eq $s2)    {
    print "Strings are identical\n";
}

--
Douglas Clifton
Unix/C/Perl/CGI/HTML Programmer

===================
Web One Inc.
Website Development
Phone: 888-699-WEB1
Phone: 616-552-9999
Fax:   616-552-9920
sales@weboneinc.com
www.weboneinc.com
===================




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

Date: 14 Jan 1998 23:47:48 GMT
From: David Lee <dwl@slip.net>
Subject: DBD/DBI and Oracle8
Message-Id: <69jir4$rdd$1@owl.slip.net>

Hi,

Are the latest DBD-Oracle (0.47) and DBI (0.90) compatible with
Oracle8? I'm having problems updating (failed to prepare update
statement) Oracle8. Selects work fine. BTW, I'm assuming the
above versions are the latest. Please let me know if there are
newer versions I need to get to work with Oracle8.

Please respond by e-mail.

Thanks
David

DWL@slip.net



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

Date: 14 Jan 1998 21:51:36 GMT
From: amihara@Hawaii.Edu (James Amihara)
Subject: deleting old files
Message-Id: <69jc18$cu6@news.Hawaii.Edu>

	i want to write perl code to read a directory, and
	delete any files that are older than 7 days from the
	current system date. does anyone know how to do that?
	how do you get the last modified date on a file
	and read that into a perl program? thanks...

--
James Amihara
amihara@hawaii.edu


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

Date: Wed, 14 Jan 1998 17:19:10 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: deleting old files
Message-Id: <e5hj96.ec5.ln@localhost>

James Amihara (amihara@Hawaii.Edu) wrote:
: 	i want to write perl code to read a directory, and
                                     ^^^^^^^^^^^^^^^^

perldoc -f opendir

perldoc -f readdir

: 	delete any files that are older than 7 days from the
        ^^^^^^     ^^^^^

perldoc -f unlink


: 	current system date. does anyone know how to do that?

Yes.


: 	how do you get the last modified date on a file
: 	and read that into a perl program? thanks...


perldoc -f stat

and

perldoc -f -X


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 14 Jan 1998 22:23:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Displaying GIFs - oops
Message-Id: <69jds5$61g$5@comdyn.comdyn.com.au>

In article <34BC5381.3B3C5210@coos.dartmouth.edu>,
	Chipmunk <rjk@coos.dartmouth.edu> writes:
> Martien Verbruggen wrote:

[something dumb]

> No no no!
> 
> print <IMAGE>; will read in and print every line in the file.

I realised that after I had posted the message :/ 
sorry.
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: Wed, 14 Jan 1998 15:34:42 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ramesh Balasubramanian <rbala@quantum-usa.com>
Subject: Re: Getting an error in dbmopen
Message-Id: <Pine.GSO.3.96.980114153354.2093F-100000@user2.teleport.com>

On Tue, 13 Jan 1998, Ramesh Balasubramanian wrote:

>  I am a newbie to Perl and am getting the following error while
> attempting a dbmopen with this syntax:
>   dbmopen(%last_good,"lastdb",0666);
> error: AnyDBM_File doesn't define a TIEHASH method
> 
> Why?

Part of your Perl installation is almost certainly misinstalled. Ask
whoever installed it to try again. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 14 Jan 1998 22:58:49 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Looking for online auction script
Message-Id: <69jfv9$69g$2@comdyn.comdyn.com.au>

In article <34BC8B21.E3809EC0@it-tradesources.com>,
	Dar Ny <darny@it-tradesources.com> writes:
> Hi
> 
> I'm looking over the internet for good auction script. but no luck.
> anyone has the script??

I suppose you mean a CGI script or application? Check out
www.cgi-resources.com for that sort of stuff. 

CGI != perl, perl != CGI.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: Wed, 14 Jan 1998 16:59:54 -0500
From: "Hans Leichtl" <hans.leichtl@digital.com>
Subject: multi level scripts output and dynamic code modification
Message-Id: <69jcgu$svv$1@mrnews.mro.dec.com>

Hi,

1.
given  i have a perl wrapper script, which in turn calls other perl scripts
or csh scripts, how to i get the output of these called scripts to STDOUT?

one workaround i could think of is to redirect the output of each of the 2nd
level scripts to a file and then print the file at the end.
if the 2nd level script is perl and i 'print STDERR "string"' i get the
output, but regular prints and echos in csh scripts don't do that.

any suggestions greatly appreciated.

2. (while i'm at it)

perl script:

$op = 'm';
if($op eq 'm') {
    $expr = 'i*=2';
}
else {
    $expr = 'i+=2';
}

for($i =0; $i<max; $exr) {
 ..}

(basically i would like to change the expression
of the for loop depending on an input parameter)
is there any way to do something like the above.
i do no know how the interpeter of perl works.
can 'eval' be used to do something like the above?

thanks a bunch

hans

hans




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

Date: 14 Jan 1998 23:13:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Parsing in Perl
Message-Id: <69jgrl$3um$1@marina.cinenet.net>

I'm working on a script which will parse out a source file with mildly 
complex syntax and generate some binary data based on what it 
finds...it's rather similar to a programming language compiler, though 
that's not actually what it is. :)

Obviously, I'd prefer not to reinvent the wheel, and I figure I can't be 
the first one to attempt this.  A quick check at CPAN revealed only one 
apparently relevant module (Parse::Lex), but its documentation is in 
French, which I don't read.

Can anyone recommend modules which might solve my problem, please?

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 14 Jan 1998 15:42:31 -0800
From: jnawaz@zzyzx.usc.edu (Jamshed Nawaz)
Subject: printing report using format
Message-Id: <69jih7$3su$1@zzyzx.usc.edu>


Hello,

I'm using format to print a report with page numbers. Somewhere in the
middle I want the report to start on a new page and start anew with
page numbers. The way I'm doing it is to set $- and $% variables to
zero, and the top-of-page format gets invoked and the page number gets
reset but it won't start the new page..... can anyone explain why
setting $- to zero by itself works, but not when $% is also set to
zero? And how do I solve my problem?? Thanks.

jn



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

Date: Wed, 14 Jan 1998 21:08:49 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Searching in directories?
Message-Id: <EMsLEq.A89@bcstec.ca.boeing.com>

In article <884790996.24444941@dejanews.com>,  <skulk@glue.umd.edu> wrote:
>I am new to Perl and am trying to figure out how to do this problem.
>I need to search through directories to find out which files do not have a
>cover page, basically a file with blah_blah_cover.txt for each .txt in
>the directory. how do i go about this?
>

perldoc File::Find
and perhaps:  perldoc File::Basename

The rest is left as an exercise for the reader :)



HTH,
--
Charles DeRykus


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

Date: 14 Jan 1998 22:12:28 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: simple perl script to add directory to PATH if not there already
Message-Id: <69jd8c$61g$3@comdyn.comdyn.com.au>

In article <34ba510a.327224093@relay>,
	randolph.a.bey@norwest.com (Randy Bey) writes:

[SNIP]
> Disclaimer: My words and opinions are my own,
> and Norwest neither is aware of or endorses anything
> I say or do. Actually, Norwest would throw me to
> the wolves if it came down to it.
> And now, for some tasty spammer bait:
> root@127.0.0.1
> postmaster@127.0.0.1
> webmaster@127.0.0.1
[SNIP big list of addresses]

Please don't do that. This stuff has to go all over the world,
clogging up disk space and bandwidth everywhere. If you feel you have
to do put those addresses in, try to keep it minimal.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.       | enough features yet.
NSW, Australia                      | 


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

Date: 14 Jan 1998 23:20:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: source into binary code
Message-Id: <69jh7m$mso$1@client2.news.psi.net>

Mr. Chow Wing Siu (wschow@Comp.HKBU.Edu.HK) wrote on 1597 September 1993
in <URL: news:69htb3$3soi$1@power42t.hkbu.edu.hk>:
++ 
++ 
++ Oops... I mean *.pl to Sun binary... not making the compiler.
++ 
++ e.g., hello.pl  (already executable)
++ #!/usr/local/bin/perl
++ print "hello world\n"
++ 
++ How to make the above code into Sun binary executable?


Why do you want to do that?



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 14 Jan 1998 23:24:34 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: source into binary code
Message-Id: <69jhfi$mso$2@client2.news.psi.net>

Dan Boorstein (dboorstein@ixl.com) wrote on 1597 September 1993 in
<URL: news:34BCD4B1.833924F3@ixl.com>:
++ Tom Christiansen wrote:
++ > 
++ >  [courtesy cc of this posting sent to cited author via email]
++ > 
++ > In comp.lang.perl.misc,
++ > :Hi, I would like to know how to turn the perl source code
++ > :into binary/executable code due to security.
++ > 
++ > Compiling produces no security.  Read the FAQ.
++ > 
++ 
++ i have to disagree with this statement. i can't read compiled
++ code just by opening a file. in order to understand just
++ what's going on internally i would have to disassemble the code.
++ as it just so happens, i don't know how to do that. so, if
++ the original poster can compile his code, it keeps me from
++ exploiting his mistakes through explicit knowledge of what they
++ are. instead i would have to make assumptions about "typical"
++ mistakes. that sounds like added security to me. furthermore,
++ i'd bet that there are a lot of others like me.
++ 
++ sure, it's no absolute, but most security (computers and otherwise),
++ is simply the act of adding more or taller "hurdles". putting
++ a flood light outside my house doesn't stop someone from breaking
++ in but it might make them think twice, and try the neighbors house
++ instead.


Rubbish. If they want to "steal" your code, and there is an easier
alternative available, they won't use your code at all. You might
as well not make it available (which is pretty secure).

And if you settle for "it prevents someone from who doesn't know
how to disassemble from getting the code", I guess you don't have
anything valuable to hide anyway.

What is it that the copyright laws don't give you?


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 14 Jan 1998 23:04:46 GMT
From: "Mr. Chow Wing Siu" <wschow@Comp.HKBU.Edu.HK>
Subject: Re: source into binary code
Message-Id: <69jgae$a52$1@power42t.hkbu.edu.hk>



Dan Boorstein <dboorstein@ixl.com> wrote:
: Tom Christiansen wrote:
: > 
: >  [courtesy cc of this posting sent to cited author via email]
: > 
: > In comp.lang.perl.misc,
: > :Hi, I would like to know how to turn the perl source code
: > :into binary/executable code due to security.
: > 
: > Compiling produces no security.  Read the FAQ.
: > 

: i have to disagree with this statement. i can't read compiled
: code just by opening a file. in order to understand just
: what's going on internally i would have to disassemble the code.
: as it just so happens, i don't know how to do that. so, if
: the original poster can compile his code, it keeps me from
: exploiting his mistakes through explicit knowledge of what they
: are. instead i would have to make assumptions about "typical"
: mistakes. that sounds like added security to me. furthermore,
: i'd bet that there are a lot of others like me.

: sure, it's no absolute, but most security (computers and otherwise),
: is simply the act of adding more or taller "hurdles". putting
: a flood light outside my house doesn't stop someone from breaking
: in but it might make them think twice, and try the neighbors house
: instead.

: thank you for your time,

: dan


Well, I do not like to argue either source code or bytecode is
secure or not.  If one has the method how to hide my perl source
code in any sense, please tell me. I need: run my perl but hide
my perl source for all users.  My goal is simple. 

- -- 
PGP PUBLIC KEY: https://www.comp.hkbu.edu.hk/~wschow/pgp.html
Key fingerprint = 15 C4 36 D6 EC CF 1D A4  7F D8 F9 EF 2E D7 32 A6


Version: 2.6.3i
Charset: noconv

iQCVAwUBNL1JBL3ixeOqBhAdAQGvjAP/R+tX0TczO6icBErEr/IXG6ipRMp8zSbK
9602L6r7n7O095LzwSEldf8iBrHJiGEcJax9HkN9u6a9w6xt5b8hG2/aRjUUHzDL
ZcdX+XP5kAUTanhW4g+GTh53odf/E/RiITvV45HHdY4oL/i9hlfJdL3qU2abjPpQ
aduQvYbP4Gw=
=V7cn
-----END PGP SIGNATURE-----


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

Date: 14 Jan 1998 22:36:17 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Speaking of Looping through hashes...
Message-Id: <69jel1$5o1$1@lyra.csx.cam.ac.uk>

Kenneth Herron <kherron@campus.mci.net> wrote:
>It'd be nice to have a way to iterate over the keys without reading
>values as well.

And because Perl likes to be nice, it's already provided.

perldoc -f each


Mike Guy


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

Date: Wed, 14 Jan 1998 16:52:03 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Syntax coloring for POD format
Message-Id: <pudge-1401981652030001@ppp-10.ts-1.kin.idt.net>

In article <82n2gyj0vx.fsf@shell2.shore.net>, Jay Rogers <jay@rgrs.com> wrote:

# ken@forum.swarthmore.edu (Ken) writes:
# > The change, I guess, amounts to this - anytime BBEdit saw one of
# > these pod directives, it would color the following text as a
# > fill-style comment:
# 
# Well, since you asked for our opinion - I'd argue against coloring POD
# text as a comment.  Since POD is just plain ole documentation, I'd say
# it should be "colored" like plain text.
# 
# My own opinion is that too much hi-lighting is hideous.

Hm.  BBEdit 4.5.1 is colored as normal code.  In fact, =pod stuff is
included in the function list, too (as are "subs" in here-docs, I think).

Regardless, I think =pod should look like commented text, and currently it
is not.  They also do stuff wrong with lots of quoting facilties.  But I
gave them a list of Perl 5 words, and they got all those in, so I am
happy.  :-)

--
Chris Nandor               pudge@pobox.com           http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10  1FF7 7F13 8180 B6B6'])
#==                    MacPerl: Power and Ease                     ==#
#==    Publishing Date: Early 1998. http://www.ptf.com/macperl/    ==#


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

Date: 14 Jan 1998 22:42:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: unlink () doesn't work under NT
Message-Id: <69jevs$69g$1@comdyn.comdyn.com.au>

In article <ubtxetamk.fsf@donal.kintailrd>,
	Bruce Cook <BC3-AU@bigfoot.com> writes:
> Koos Pol <koos_pol@bigfoot.com> writes:
> 
>> > unlink ("$jukebox[$i]\\$date\\*") || warn ("cannot delete files\n");
>> 
>> Try 
>>   unlink ("$jukebox[$i]\\$date\\*") || warn ("cannot delete files$!\n");
>> 
>> This should produce a diagnostic. BTW, unlink works on my NT 3.51
>> install.
> 
> An interesting aside tot his is that "$jukebox[$i]/$date/*" is valid also
> on the NT machine, and will remove some of the confusion with '\' in the
> name.  (Also makes the script portable)


As another aside:

It looks like you are trying to unlink a list of files, unless you are
actually trying to unlink a file with the name '*'. If you want this
to happen, you'll have to do the glob yourself..

perldoc -f unlink

Deletes a list of files.  Returns the number of files successfully
deleted.

    $cnt = unlink 'a', 'b', 'c';
    unlink @goners;
    unlink <*.bak>;

See the last entry? That's a glob.

	unlink glob *.bak;

Should do the same, and in my opinion is better. So, I think the line
above should read:

unlink glob "$jukebox[$i]/$date/*" or die "Cannot unlink files: $!";

BTW. I don't know how exactly the globbing is implemented on NT, is it
DOS style or sh style? '*' will expand to something different in both
cases. You might want to test.

Martien
--
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: Wed, 14 Jan 1998 15:46:16 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ko Kin <ckko@cse.cuhk.edu.hk>
Subject: Re: unlink () doesn't work under NT
Message-Id: <Pine.GSO.3.96.980114154228.2093H-100000@user2.teleport.com>

On 14 Jan 1998, Ko Kin wrote:

> Jeremy D. Zawodny <jzawodn@wcnet.org> wrote:
> > What error did it issue?
> 
> But it says nothing.

Perl says nothing?

> I wrote:
> 
> unlink ("$jukebox[$i]\\$date\\*") || warn ("cannot delete files\n");
> ($jukebox[$i] - a:, $date - 19980114)
> and it just says cannot delete files.

Perl says it cannot delete files? What does it really do: Does it say
nothing or does it say that it cannot delete files?

Your warning would be even better if it contained the magical $! variable,
perhaps like this.

    $goner = "$jukebox[$i]\\$date\\*";
    unlink $goner
	or warn "Couldn't unlink file '$goner': $!";

That variable will have a human-readable error message such as "no such
file or directory" that may help with debugging. Also, since we're not
ending the parameter to warn() with a newline, perl will know to add its
on information telling (among other things) where in your code the
warning occurred. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: 14 Jan 1998 22:06:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why would stat return 12/31/69
Message-Id: <69jctm$61g$2@comdyn.comdyn.com.au>

[This has nothing to do with modules. removed c.l.p.modules]

In article <34BCE282.65715E9A@sam.on-net.net>,
	"David J. Boyd" <djboyd@sam.on-net.net> writes:
> Anyone know why the stat function would return a date of 12/31/69 with a
> time
> of 19:00 on a file or directory.

You're getting back a time of 0, which often is midnight, jan 1, 1970.
Add the time zone offset, and I bet you you'll end up with that date.

> checkfiles("c:\apps","c:\apps");

Don't. Use "c:/apps", or better 'c:/apps', or if you MUST use
backslashes "c:\\apps" or better 'c:\apps';

>     $fullFilename = "$path\\$_";

See? here you know that you need to use a double backslash

You might want to add in a check to see if the file exists at all
here (-e). 

>     $count++;
>     $perm = (stat($fullFilename))[2];
>     $size = (stat($fullFilename))[7];
>     $mtime= (stat($fullFilename))[9];

What's the value of $mtime here?

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.       | make a better idiot.
NSW, Australia                      | 


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

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

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