[17959] in Perl-Users-Digest
Perl-Users Digest, Issue: 119 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 22 14:10:35 2001
Date: Mon, 22 Jan 2001 11:10:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980190618-v10-i119@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 22 Jan 2001 Volume: 10 Number: 119
Today's topics:
Re: input_record_separator error (Tad McClellan)
Re: input_record_separator error (Tad McClellan)
Re: input_record_separator error (Tad McClellan)
Re: Inserting fields in place (Abigail)
Re: Java <fty@mediapulse.com>
Lint for perl? (Stan Brown)
Re: Lint for perl? <arthur.haas@westgeo.com>
Re: Lint for perl? (Rafael Garcia-Suarez)
Re: Lint for perl? (Tad McClellan)
Re: Lint for perl? (Stan Brown)
Re: matching "*"? <mischief@velma.motion.net>
Re: matrix jdf@pobox.com
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: Newbie Perl Problem <ren.maddox@tivoli.com>
Non Unix user needs help with File::Find sjamiso@my-deja.com
Re: Non Unix user needs help with File::Find (Martien Verbruggen)
Re: Non Unix user needs help with File::Find <jdf@pobox.com>
Re: Non Unix user needs help with File::Find sjamiso@my-deja.com
Perl & C <ediril@ece.wpi.edu>
Re: Perl & C <jdf@pobox.com>
Re: Perl Crashes on my Win2k Box <someguyREMOVE@REMOVEsunflower.com>
Re: perlxs: How do I map C char[]? (Ilya Zakharevich)
Re: perlxs: How do I map C char[]? (Ilya Zakharevich)
Re: Posting email from PERL to Outlook (Exchange)??? <jdf@pobox.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Jan 2001 16:27:37 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: input_record_separator error
Message-Id: <slrn96oeps.17f.tadmc@tadmc26.august.net>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>>Perl was recently upgraded here to V5.6 using the version from
>>www.perl.com. Since that upgrade, I have had several scripts return
>>the following error:
>>
>>input_record_separator is not supported on a per-handle basis
>>at /opt/perl-5.6.0/site_lib/QIP.pl line 110
>>The code it's complaining about is below.
>>
>> input_record_separator $fh ": ";
>> chomp($_ = ReadLine(1, $fh));
>> input_record_separator $fh "\n";
>
>The function (or method) input_record_separator is not a standard
>Perl function.
I didn't think so either, until I did:
grep input_record_separator perlvar.pod
and saw this, which I hadn't noticed before:
-------------------
=item input_record_separator HANDLE EXPR
=item $INPUT_RECORD_SEPARATOR
=item $RS
=item $/
The input record separator, newline by default...
-------------------
Guess I haven't read perlvar top to bottom in the last year or so.
Another item for my To Do list...
>It must be part of one of the modules you're using,
Must be IO::Handle.
>probably QIP itself. Consult its documentation, its source and
>its author.
perldoc IO::Handle
-------------------
...
See the perlvar manpage for complete descriptions of each
of the following supported `IO::Handle' methods. All of
them return the previous value of the attribute and takes
an optional single argument that when given will set the
value. If no argument is given the previous value is
unchanged (except for $io->autoflush will actually turn ON
autoflush by default).
$io->autoflush ( [BOOL] ) $|
$io->format_page_number( [NUM] ) $%
$io->format_lines_per_page( [NUM] ) $=
$io->format_lines_left( [NUM] ) $-
$io->format_name( [STR] ) $~
$io->format_top_name( [STR] ) $^
$io->input_line_number( [NUM]) $.
The following methods are not supported on a per-
filehandle basis.
IO::Handle->format_line_break_characters( [STR] ) $:
IO::Handle->format_formfeed( [STR]) $^L
IO::Handle->output_field_separator( [STR] ) $,
IO::Handle->output_record_separator( [STR] ) $\
IO::Handle->input_record_separator( [STR] ) $/
-------------------
Note that input_record_separator() is a _class_ method, not an
object method (which is why it issues the warning I expect).
So you call it like this instead:
IO::Handle->input_record_separator(": ");
... # all input done here (or in functions called from here)
# will be using the new separator
IO::Handle->input_record_separator("\n"); # return to the default setting
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Jan 2001 16:27:41 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: input_record_separator error
Message-Id: <slrn96ogjp.17f.tadmc@tadmc26.august.net>
Bill Smith <apobull@my-deja.com> wrote:
>Perl was recently upgraded here to V5.6 using the version from
>www.perl.com. Since that upgrade, I have had several scripts return
>the following error:
^^^^^
I think that is a _warning_ not an error.
Does your program execute? Errors stop execution, warnings do not.
>input_record_separator is not supported on a per-handle basis
>at /opt/perl-5.6.0/site_lib/QIP.pl line 110
>The code it's complaining about is below.
>
> input_record_separator $fh ": ";
> chomp($_ = ReadLine(1, $fh));
> input_record_separator $fh "\n";
>
>
>We consulted with a Perl person here who recommended the following code
>instead of what's above:
>
>$/ = ":"; and$/ = "\n"; The first bit of code to replace line 110's
>contents and the other part for line 112.
That should work (except line 110 uses the 2-char sequence ": "
instead of the 1-char ":").
>I made this change but still continued to get the error.
The exact same message? I don't see how that can be.
Got a short and complete program that we can run that duplicates
the "error" (sic) using $/ instead of input_record_separator() ?
>If necessary, I can post the
>remaining contents of the offending script.
No, don't do that.
Post a short (less than 30 lines or so) and complete program that
duplicates the message, not a big ol' real program.
The exercise of making such a program very often reveals the
problem to you before you get a chance to post it :-)
If not, then show it to us and we'll help you fix it.
perldoc IO::Handle
may be helpful to you as well.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Jan 2001 16:27:43 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: input_record_separator error
Message-Id: <slrn96oh1s.17f.tadmc@tadmc26.august.net>
Bill Smith <apobull@my-deja.com> wrote:
>In article <94h1p2$a4d$1@mamenchi.zrz.TU-Berlin.DE>,
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>> Bill Smith <apobull@my-deja.com> wrote in comp.lang.perl.misc:
>> >input_record_separator is not supported on a per-handle basis
>> >at /opt/perl-5.6.0/site_lib/QIP.pl line 110
>> > input_record_separator $fh ": ";
>> The function (or method) input_record_separator is not a standard
>> Perl function.
>input_record_separator is not a QIP module. It is in fact part of Perl.
It is a method on a core module, I guess that makes it "part of Perl"...
>Consult O'Reilly's Programming Perl, 3rd Edition, page 666. What is
>listed there is what my colleague here suggested but still isn't
>working.
I do not see any reference to that method on pp666-667.
I see reference to an $INPUT_RECORD_SEPARATOR _variable_.
I _do_ however, see a reference to that method in perlvar.pod.
Perl's standard docs are more authoritative than even the Camel book.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Jan 2001 16:16:53 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Inserting fields in place
Message-Id: <slrn96on7l.qn2.abigail@tsathoggua.rlyeh.net>
Brian E. Seppanen (seppy@chartermi.net) wrote on MMDCCI September
MCMXCIII in <URL:news:3A6C55C9.562CB28A@chartermi.net>:
)) Hello:
))
)) I have several existing mrtg configs that monitor routers and whatnot.
)) I have a lot of them. I want to begin adding threshold monitoring into
)) these configurations, and that would entail adding several fields with
)) additional information. There will need to be some hand modifications
)) necessary, but I'd like to get the majority taken care of it I can.
))
))
)) What I need to do is search for a specified line, and once I find that I
)) need to insert the text. In this situation the config files will
)) sometimes contain multiple occurrences of options, so I need to match
)) each one and insert.
))
)) Is this possible? here's what I've got obviously it doesn't do what I
)) need.
))
)) #!/usr/bin/perl -w
)) use Cwd 'chdir';
)) use strict 'vars';
))
)) chdir '/home/mrtg/templates/test';
)) my @files = `ls -1 /home/mrtg/templates/test | tr -d / `;
)) foreach (@files) {
)) print "Opening File: $_\n";
)) open (FILE,">>$_");
)) my $line = m/Options/;
This of course matches against the current file name, storing the
result in $line - which isn't used anymore.
)) print FILE "\nI AM A TEST\n";
)) close FILE;
)) }
))
)) The test text simply get's appended to the end of the file. Is it
)) possible to do what I'm asking?
Yes. But it's easier to not do it in situ. Open two files, one for reading
(the original file) and a new one (the modified file). Read from the first
file, copying the lines to the second one; now, if you read an interesting
line, add whatever you want to add to the second file.
Lather. Rinse. Repeat.
Of course, you might be better off using something else for monitoring
(mon, for instance). And when you open files, you ought to check the
return value of open.
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20010122
------------------------------
Date: Mon, 22 Jan 2001 16:37:38 GMT
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: Java
Message-Id: <mlZa6.6774$pM4.657599@news5.aus1.giganews.com>
look at Inline.pm
"Jane Millson" <jane__millson@hotmail.com> wrote in message
news:94djfu$55r$3@slb1.atl.mindspring.net...
> Is there a way to embed Java into Perl, and if so does it work seamlessly?
>
>
------------------------------
Date: 22 Jan 2001 11:17:10 -0500
From: stanb@panix.com (Stan Brown)
Subject: Lint for perl?
Message-Id: <94hme6$bo3$1@panix6.panix.com>
I find lint very useful when writing C code (even if it is showing it's
agae a bit).
Is there a similar tool for perl?
I'm interested in, for instance, variables that are declared, but not
used.
------------------------------
Date: 22 Jan 2001 10:18:30 -0600
From: Art Haas <arthur.haas@westgeo.com>
Subject: Re: Lint for perl?
Message-Id: <lrhf2rzhk9.fsf@h130p254.wg.waii.com>
stanb@panix.com (Stan Brown) writes:
> I find lint very useful when writing C code (even if it is showing it's
> agae a bit).
>
> Is there a similar tool for perl?
>
> I'm interested in, for instance, variables that are declared, but not
> used.
>
At a prompt ...
$ perl -cw your_perl_script.pl
That's a good check.
--
###############################
# Art Haas
# (713) 689-2417
###############################
------------------------------
Date: Mon, 22 Jan 2001 16:49:49 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Lint for perl?
Message-Id: <slrn96op68.3ke.rgarciasuarez@rafael.kazibao.net>
Art Haas wrote in comp.lang.perl.misc:
> stanb@panix.com (Stan Brown) writes:
>
> > I find lint very useful when writing C code (even if it is showing it's
> > agae a bit).
> >
> > Is there a similar tool for perl?
> >
> > I'm interested in, for instance, variables that are declared, but not
> > used.
> >
>
> At a prompt ...
>
> $ perl -cw your_perl_script.pl
or, for more verbosity:
perl -cw -Mdiagnostics your_perl_script.pl
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
~
~
:wq
------------------------------
Date: Mon, 22 Jan 2001 16:53:18 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Lint for perl?
Message-Id: <slrn96oi85.1gd.tadmc@tadmc26.august.net>
Art Haas <arthur.haas@westgeo.com> wrote:
>stanb@panix.com (Stan Brown) writes:
>
>> I find lint very useful when writing C code (even if it is showing it's
>> agae a bit).
>>
>> Is there a similar tool for perl?
>
>At a prompt ...
>
>$ perl -cw your_perl_script.pl
>
>That's a good check.
perl -Mstrict -cw your_perl_script.pl
That's an even better check ;-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Jan 2001 13:44:08 -0500
From: stanb@panix.com (Stan Brown)
Subject: Re: Lint for perl?
Message-Id: <94hv1o$f0f$1@panix2.panix.com>
In <94hme6$bo3$1@panix6.panix.com> stanb@panix.com (Stan Brown) writes:
> I find lint very useful when writing C code (even if it is showing it's
> agae a bit).
> Is there a similar tool for perl?
> I'm interested in, for instance, variables that are declared, but not
> used.
I recived several helpful replies to this, but none of the really
addresses my primary requirement.
If I add a new variable dcleration as in:
my $foo;
and don't use it in the function it is declared in, I get no comlaints
from any of the sugestiosn I have recieved so far.
How can I check for this type of error?
------------------------------
Date: Mon, 22 Jan 2001 18:10:58 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: matching "*"?
Message-Id: <t6otti16i3fmb6@corp.supernews.com>
I promise to write out 100 times (on paper, longhand) after this
"I will not feed the troll."
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Jim Monty wrote:
>
>> Godzilla! wrote:
>> > Johannes Graumann wrote:
>> > > I'm trying to match a "*" at the end of a line.
>> > > Since * is a multiplier, something like /*^/ won't work.
>> > You will discover either method shown in my test
>> > script below, to be quicker and more efficient.
> (snipped code)
>> Now demonstrate for our benefit how much "quicker and
>> more efficient" it is to adapt your script to a simple
>> change of specification. For example:
> (snipped code)
> Irrelevant. Your code does not comply with
> stated parameters. Adding to the irrelevance
> of your comments, invoking a regex engine is
> almost always slower and more memory intensive
> than is chop or substring.
The post to which the troll responds here did show code
that matched the specifications - twice. The troll snipped
it, though. That code is:
/\*$/
Also, maintenance time is often as important as runnning time.
According to Kernighan and Pike, you should write your code clearly,
profile it, and only take the extra time spent optimizing if the
time saved over the life of the program is greater than the time
spent in optimization. You can find that in
_The_Practice_of_Programming_.
> Changing parameters to fit code, rather than
> writing code to fit parameters, is a clear
> poor programming practice and a reflection
> of a programmer incapable of dealing with
> clearly stated parameters effectively.
Does q(/\*$/) not match an asterisk at the end of a line?
> Godzilla!
I always though Godzilla was a giant lizard, not a troll.
Chris
--
Christopher E. Stith
For the pleasure of others, please adhere to the following
rules when visiting your park:
No swimming. No fishing. No flying kites. No frisbees.
No audio equipment. Stay off grass. No pets. No running.
------------------------------
Date: 22 Jan 2001 12:16:05 -0500
From: jdf@pobox.com
Subject: Re: matrix
Message-Id: <1ytv33u2.fsf@pobox.com>
Bob Walton <bwalton@rochester.rr.com> writes:
> smittod@auburn.edu wrote:
> > I need a module that can build and display a matrix for me.
> ...
> You'll have to be much more descriptive and explicit about what you want
> -- nobody can decipher from the above what you want. Maybe some
> examples of what you mean by a "matrix" and its "display" would help.
What *is* the matrix?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 22 Jan 2001 16:38:34 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <t6ooga8lpich78@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 15 Jan 2001 16:24:09 GMT and ending at
22 Jan 2001 14:42:26 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2001 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 170 (41.5% of all posters)
Articles: 294 (23.7% of all articles)
Volume generated: 529.1 kb (22.0% of total volume)
- headers: 231.6 kb (4,609 lines)
- bodies: 296.3 kb (10,154 lines)
- original: 212.3 kb (7,622 lines)
- signatures: 0.9 kb (26 lines)
Original Content Rating: 0.717
Averages
========
Posts per poster: 1.7
median: 1.0 post
mode: 1 post - 114 posters
s: 1.8 posts
Message size: 1842.8 bytes
- header: 806.5 bytes (15.7 lines)
- body: 1032.1 bytes (34.5 lines)
- original: 739.5 bytes (25.9 lines)
- signature: 3.2 bytes (0.1 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
16 37.1 ( 15.2/ 21.9/ 12.0) "Jeffrey Grace" <gracenews@optusnet.com.au>
11 22.6 ( 8.3/ 14.3/ 11.7) Rand Simberg <simberg.interglobal@trash.org>
10 22.9 ( 8.9/ 14.1/ 10.0) "James Kauzlarich" <nospam-abuse@[127.0.0.1]>
8 19.7 ( 7.1/ 12.6/ 6.9) Sterling <smullett@omeninc.com>
5 8.5 ( 3.6/ 4.9/ 2.9) vupt@yahoo.com
5 9.8 ( 4.7/ 5.1/ 2.2) Jamie O'Shaughnessy <jamie.oshaughnessy@ntlworld.com>
5 8.8 ( 4.5/ 4.3/ 3.3) "Anson Parker" <ans@_nospam_x64.net>
4 19.4 ( 3.2/ 16.2/ 16.0) "bigdawg" <ewsr1@home.com>
4 7.6 ( 3.1/ 4.5/ 1.8) hmug@my-deja.com
4 5.0 ( 3.8/ 1.2/ 0.6) "Chris W" <chrisw.NOSPAM@dynamite.com.au>
These posters accounted for 5.8% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
37.1 ( 15.2/ 21.9/ 12.0) 16 "Jeffrey Grace" <gracenews@optusnet.com.au>
23.2 ( 0.8/ 22.4/ 22.0) 1 "Steve Baldwin" <steven.baldwin@hancorp.com.au>
22.9 ( 8.9/ 14.1/ 10.0) 10 "James Kauzlarich" <nospam-abuse@[127.0.0.1]>
22.6 ( 8.3/ 14.3/ 11.7) 11 Rand Simberg <simberg.interglobal@trash.org>
19.7 ( 7.1/ 12.6/ 6.9) 8 Sterling <smullett@omeninc.com>
19.4 ( 3.2/ 16.2/ 16.0) 4 "bigdawg" <ewsr1@home.com>
10.4 ( 2.4/ 8.0/ 3.2) 3 shiloam@pacbell.net
9.8 ( 4.7/ 5.1/ 2.2) 5 Jamie O'Shaughnessy <jamie.oshaughnessy@ntlworld.com>
8.8 ( 4.5/ 4.3/ 3.3) 5 "Anson Parker" <ans@_nospam_x64.net>
8.5 ( 3.6/ 4.9/ 2.9) 5 vupt@yahoo.com
These posters accounted for 7.6% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
1.000 ( 0.9 / 0.9) 3 Emrah Diril <ediril@ece.wpi.edu>
0.993 ( 16.0 / 16.2) 4 "bigdawg" <ewsr1@home.com>
0.836 ( 1.2 / 1.4) 3 "Peter" <peter@cgi-shop.dk>
0.819 ( 11.7 / 14.3) 11 Rand Simberg <simberg.interglobal@trash.org>
0.778 ( 3.3 / 4.3) 5 "Anson Parker" <ans@_nospam_x64.net>
0.776 ( 1.8 / 2.3) 3 someone of export <lashawn@rice.edu>
0.755 ( 3.6 / 4.8) 3 "Dennis Fortin" <dfortin@eftia.com>
0.721 ( 2.2 / 3.1) 3 tzehua_tung@my-deja.com
0.711 ( 10.0 / 14.1) 10 "James Kauzlarich" <nospam-abuse@[127.0.0.1]>
0.596 ( 2.9 / 4.9) 5 vupt@yahoo.com
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.535 ( 1.0 / 2.0) 3 pyro3k@my-deja.com
0.519 ( 0.6 / 1.2) 4 "Chris W" <chrisw.NOSPAM@dynamite.com.au>
0.456 ( 1.6 / 3.5) 3 Michael Benson <mbenson@mediaone.net>
0.441 ( 1.5 / 3.4) 3 Paul Cody Johnston <pcj@Stanford.EDU>
0.422 ( 2.2 / 5.1) 5 Jamie O'Shaughnessy <jamie.oshaughnessy@ntlworld.com>
0.407 ( 1.0 / 2.4) 3 Lee Webb <lwebbee@britcomtele.comnotreal>
0.404 ( 3.2 / 8.0) 3 shiloam@pacbell.net
0.395 ( 1.2 / 3.1) 3 "Chris Rogers" <xchris.rogers@xvifanusa.com>
0.395 ( 1.8 / 4.5) 4 hmug@my-deja.com
0.381 ( 1.2 / 3.3) 3 Jing Zhou <jing@research.att.com>
24 posters (14%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
9 comp.lang.perl.modules
4 comp.lang.perl
4 alt.perl
3 comp.infosystems.www.servers.unix
2 comp.answers
2 news.answers
2 comp.lang.perl.moderated
2 comp.infosystems.www.cgi
2 comp.lang.perl.tk
1 comp.infosystems.www.servers.ms-windows
Top 10 Crossposters
===================
Articles Address
-------- -------
2 mine <ball@merck.com>
1 "Brian E. Seppanen" <seppanen@chartermi.net>
1 "Steve Baldwin" <steven.baldwin@hancorp.com.au>
1 Drew Dowling <drewhead.nospam@drewhead.org>
0 Dave Paris <dparis@w3works.com>
0 Emrah Diril <ediril@ece.wpi.edu>
0 mastertivoli@my-deja.com
0 "Srdjan Sobajic" <srdjans@digitalpersona.com>
0 Johannes Graumann <j_graumann@hotmail.com>
0 Marc Spitzer <marc@oscar.eng.cv.net>
------------------------------
Date: 22 Jan 2001 10:06:21 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Newbie Perl Problem
Message-Id: <m3snmbfu6a.fsf@dhcp11-177.support.tivoli.com>
mintcake@my-deja.com writes:
> OK, you can use split (and then join) but what I think badass was
> really after was:
>
> $text1 =~ s/\s*\ \sg;
Except that this will insert a space at every opportunity -- and since
you used "*" that means between every character. Plus you got your
slashes mixed up....
$text1 =~ s/\s+/ /sg;
Also, tr should be faster, though it does require you to list the
characters:
$text1 =~ tr/ \t\b\n\r/ /s;
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Mon, 22 Jan 2001 16:49:44 GMT
From: sjamiso@my-deja.com
Subject: Non Unix user needs help with File::Find
Message-Id: <94hob3$prn$1@nnrp1.deja.com>
I am trying to use File:Find to traverse a LARGE directory structure
and return files with the following crietera
1. do not want directories in list ( This works)
2. Files must be writable ( This works)
3. skip a directory structure (Can't figure out File::Find::prune)
Here's the wanted that I have.
sub wanted {
if ( $_ =~ /$opt_filespec/i )
{
@bad_files = (@bad_files,"$File::Find::name\n");
}
elsif ( !(-d) && !($opt_filespec) && -w )
{
@bad_files = (@bad_files,"$File::Find::name\n");
}
} #End of wanted
Any suggestions and help is appreciated.
Thanks
ShawnJ
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 04:53:54 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <slrn96osti.bgr.mgjv@martien.heliotrope.home>
On Mon, 22 Jan 2001 16:49:44 GMT,
sjamiso@my-deja.com <sjamiso@my-deja.com> wrote:
> I am trying to use File:Find to traverse a LARGE directory structure
> and return files with the following crietera
>
> 1. do not want directories in list ( This works)
is this really what you want? You want everything that is not a
directory? Or do you really mean that you want all _plain_ files? You
say you are a 'non unix user' in the Subject, but that doesn't mean you
are on an OS where a non-directory is always a plain file.
> 2. Files must be writable ( This works)
> 3. skip a directory structure (Can't figure out File::Find::prune)
The following prints out all the files in /usr/local/share except when
they are located in any subdirectory of any directory with the nae
'vim':
#!/usr/local/bin/perl -wl
use strict;
use File::Find;
find(\&wanted, '/usr/local/share');
sub wanted
{
$File::Find::prune = 1, return if -d $_ && $_ eq 'vim';
print $File::Find::name;
}
> Here's the wanted that I have.
>
> sub wanted {
> if ( $_ =~ /$opt_filespec/i )
You don't show us what's in $opt_spec, so we can't comment on that. The
binding to $_ is optional. If it isn't specified, $_ will be bound.
> {
> @bad_files = (@bad_files,"$File::Find::name\n");
> }
Unnecessary copying of a LARGE array (your emphasis). I also think it's
a bad idea to store a newline in the file name. If you need a newline
for output, add it when outputting. Not here.
push @bad_files, $File::Find::name;
> elsif ( !(-d) && !($opt_filespec) && -w )
This is odd... You use $file_spec above, without checking, and here you
suggest that it may be undefined, 0 or ""? You also don't need any of
those brackets. And.. if you use multiple -X operators, it's cheaper to
use the special file handle _ on the second and subsequent ones:
elsif ( ! -d && ! $opt_spec && -w _ )
> {
> @bad_files = (@bad_files,"$File::Find::name\n");
see above.
> }
> } #End of wanted
If you want to use all that, then I suggest you rewrite it. You are
looking for all writeable files that are not directories, but only IF
there is no $opt_spec given. If there is one given, you want all files,
including directories, that match that regular expression.
At least, that is what you wrote. This is slightly clearer:
if ($opt_spec)
{
push @bad_files, $File::Find::name
if /$opt_spec/i;
}
else
{
push @bad_files, $File::Find::name
if ! -d && -w _;
}
but still duplicates code. The following does it all in one go, but has
to test $opt_spec twice:
push @bad_files, $File::Find::name if
($opt_spec && /$opt_spec/i) || (!$opt_spec && ! -d && -w _);
This may be better:
push @bad_files, $File::Find::name if
$opt_spec ? /$opt_spec/i : ! -d && -w _;
Or, if you really meant to say 'plain files' instead of 'non-directory':
push @bad_files, $File::Find::name if
$opt_spec ? /$opt_spec/i : -f && -w _;
Luckily, File::Find changes cwd for you.
Whichever of the above suits your style best...
Martien
--
Martien Verbruggen |
Interactive Media Division | life ain't fair, but the root
Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
NSW, Australia |
------------------------------
Date: 22 Jan 2001 13:04:49 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <k87njwe6.fsf@pobox.com>
sjamiso@my-deja.com writes:
> 1. do not want directories in list ( This works)
> 2. Files must be writable ( This works)
> 3. skip a directory structure (Can't figure out File::Find::prune)
As for prune, as the documentation suggests, you *set*
$File::Find::prune if you want to skip the directory you're given. To
"set" it means to give it a true value, as in
$File::Find::prune = 1 if -d && /some_regex/;
I don't know what you mean by "skip a directory structure". Do you
mean that you do not wish to recur into any directories at all, or
that you wish to avoid certain directories?
> if ( $_ =~ /$opt_filespec/i )
...
> elsif ( !(-d) && !($opt_filespec) && -w )
I don't understand how you're using $opt_filepsec in that second line.
Do you really mean that you're checking whether $opt_filespec has a
defined and true value?
> @bad_files = (@bad_files,"$File::Find::name\n");
push @bad_files, $File::Find::name;
Why are you including a newline?
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 22 Jan 2001 18:47:38 GMT
From: sjamiso@my-deja.com
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <94hv86$i3$1@nnrp1.deja.com>
Some explanation seem necessary.
I have a huge directory structure under source control. 10,000 files
The users current working set of files may contain 100 or more files
from all over the directory structure.
A working set of files is checked out of source control and is
writeable.
Everything else is read only.
I am trying to search for everything that is writeable and/or of a
certain file extension.
I want to skip the directory where all the binaries are placed after a
build. (it's different for each user)
I don't want a bare directory in the list returned. Just a listing of
plain files.
This will make the check-in process easier.
Now you know what I'm trying to do, take a second look at the code and
make suggestions.
Thanks
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 12:45:49 -0500
From: Emrah Diril <ediril@ece.wpi.edu>
Subject: Perl & C
Message-Id: <Pine.OSF.4.21.0101221242570.27719-100000@ece.wpi.edu>
Hi,
I am trying to incorporate some Perl functions wrote into my C program. I
looked at the Perl.com webpage, but the information there is for gcc. I am
using Microsoft Visual C++ 6.0.
How do I do it? Has anyone done this sort of thing before? Please write to
me. Please reply via e-mail.
Thanks a lot.
Emrah
------------------------------
Date: 22 Jan 2001 13:07:03 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Perl & C
Message-Id: <d7dfjwag.fsf@pobox.com>
Emrah Diril <ediril@ece.wpi.edu> writes:
> How do I do it? Has anyone done this sort of thing before? Please write to
> me.
perldoc perlembed
> Please reply via e-mail.
No.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 22 Jan 2001 12:03:11 -0600
From: "Hawk" <someguyREMOVE@REMOVEsunflower.com>
Subject: Re: Perl Crashes on my Win2k Box
Message-Id: <t6oti4tdgjkf28@corp.supernews.com>
This forum is to help people. If you can not do that without your
condescending remarks, I'd like to be the first to suggest that you take an
extended leave of absence. Perhaps the ones that need to be "beaten off with
a spoon" are the regulars with a god complex.
Cheers
-Tony
P.S. Oh, sorry. Didn't see you were an AOL user. The fact that you use AOL
speaks volumes about your intellect and character.
Tarael200 <tarael200@aol.com> wrote in message
news:20010121094642.10290.00000429@ng-mf1.aol.com...
> Jeez, seems like we're beating the newbies off with a spoon lately..
>
> Try posting your code next time.
>
> And telling us what version of perl you're using.
>
> And just being a bit more verbose in describing your problem, in general.
>
> -Malander
>
------------------------------
Date: 22 Jan 2001 16:35:25 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perlxs: How do I map C char[]?
Message-Id: <94hngd$hc6$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jens M. Felderhoff
<j.m.f.@gmx.net>],
who wrote in article <pbae8jahdx.fsf@srv-deu-cos11.baan.com>:
> I have some C sources that define character arrays, like
>
> typedef char firstname[FIRSTNAMELEN];
>
> When I define firstname as T_PTRREF in the typemap, the resulting code
> produces the (wrong) C statement:
>
> arg0 = (firstname) tmp;
>
> and the C compiler thus correctly complains:
>
> cast specifies array type
>
> because arg0 is a character array, not a pointer.
>
> What's the proper way to handle character arrays from within XSUBS?
Why not make a T_PV_CHARARRAY typemap entry which does a copy (out of T_PV)?
You can even check that the length is bounded
#define firstname_BOUND__ FIRSTNAMELEN
But the simplest thing may be to
#define firstname char_pointer
typedef char *char_pointer;
at the beginning of your XSUB...
Ilya
------------------------------
Date: 22 Jan 2001 16:38:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perlxs: How do I map C char[]?
Message-Id: <94hnlh$hdg$1@charm.magnus.acs.ohio-state.edu>
I wrote in article <94hngd$hc6$1@charm.magnus.acs.ohio-state.edu>:
> But the simplest thing may be to
>
> #define firstname char_pointer
> typedef char *char_pointer;
>
> at the beginning of your XSUB...
Oups, I meant "after including your header file" in your XS file.
Ilya
------------------------------
Date: 22 Jan 2001 12:43:03 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Posting email from PERL to Outlook (Exchange)???
Message-Id: <3deblbyw.fsf@pobox.com>
"Daniel (Dan) Rosenzweig" <danr@att.com> writes:
> Having never done OLE programming before - where can I find documentation to
> the objects /commands available to me when talking to Outlook?
You're now leaving the domain of expertise of most of the people who
read and post here. You'll most likely get quicker and better help
from folks at whatever newsgroups are devoted to Win32 programming.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 119
**************************************