[13635] in Perl-Users-Digest
Perl-Users Digest, Issue: 1045 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 11 22:05:40 1999
Date: Mon, 11 Oct 1999 19:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <939693907-v9-i1045@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 11 Oct 1999 Volume: 9 Number: 1045
Today's topics:
Re: Advanced text substitution in FILEHANDLES <pb@decoteka.com>
Re: Advanced text substitution in FILEHANDLES <laurensmith@sprynet.com>
Re: Advanced text substitution in FILEHANDLES <22pb22@excite.com>
Re: Case Question. <r28629@email.sps.mot.com>
Re: CGI Form interaction question <jeff@vpservices.com>
Re: help re perl scripts to submit urls to engines <cw@dwc.ch>
parsing words rk27@my-deja.com
Re: parsing words (Sam Holden)
Re: parsing words (Larry Rosler)
Re: parsing words <rootbeer@redcat.com>
Re: Passing unknown filenames as arguments to another p (Randal L. Schwartz)
Re: Passing unknown filenames as arguments to another p <rra@stanford.edu>
Re: Perl Interview Question: (d.k. henderson)
Re: Perl Interview Question: (Larry Rosler)
Re: Perl lite (Larry Rosler)
Re: sprintf help <makkulka@cisco.com>
Re: sprintf help <scott_beck@my-deja.com>
Use Perl to Close File In Use on NT? <smontgomery@digitalblaze.net>
Use Perl to Close File In Use on NT? <smontgomery@digitalblaze.net>
Use Perl to Close File In Use on NT? <smontgomery@digitalblaze.net>
Use Perl to Close File In Use on NT? <smontgomery@digitalblaze.net>
Use Perl to Close File In Use on NT? <smontgomery@digitalblaze.net>
use strict problem <frankhale@trespass.net>
Re: use strict <jeff@vpservices.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Oct 1999 15:55:11 -0700
From: "PB" <pb@decoteka.com>
Subject: Re: Advanced text substitution in FILEHANDLES
Message-Id: <7ttpvf$fhu$1@fir.prod.itd.earthlink.net>
Thanks for the info. I am trying to plug this into an existing 'while' loop
that performs cleaning of the text file, such as:
open (LISTING, "$path\\$list.txt") || die "Can't open $list.txt: $!";
open (CLEANED, ">$path\\cleaned.txt") || die "Can't create cleaned.txt: $!";
while (<LISTING>) {
s/Above user is in group\n//ig; # Get rid of 'Above user
...' text line
s/^\n//ig; # Get rid
of Blank lines
s/(\w+)\s(\w+)\n//ig; # Get rid of
"word + space + word"
$_ =~ tr/a-z/A-Z/; # Uppercase all
print CLEANED $_; # Write output to
cleaned.txt
}
close (LISTING);
close (CLEANED);
print ("Done ...\n\n\n");
Now this would write the output such as:
--------- start cleaned.txt ----------------
john
doe
blow
mike
Above name is not in group
susan
peter
gerry
Above name is not in group
james
----------- end cleaned.txt -------------
I've tried including the code that you provided but to no avail. How would
you insert it into the existing 'while' loop?
Thanks for your patience !!!
pb
<SNIP>
> #!/usr/bin/perl -w
> use strict;
> my $lastline = '';
> while (<DATA>) {
> if ($_ eq "Above name is not in group\n") {
> $lastline = '';
> } else {
> print $lastline;
> $lastline = $_;
> }
> }
> print $lastline;
------------------------------
Date: Mon, 11 Oct 1999 17:05:41 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: Advanced text substitution in FILEHANDLES
Message-Id: <7ttu0o$rpa$1@brokaw.wa.com>
Either you don't fully understand the problem that you are presenting to
the newsgroup, or you are not adequately explaining what the problem is.
PB wrote in message <7ttpvf$fhu$1@fir.prod.itd.earthlink.net>...
>I am trying to plug this into an existing 'while' loop
>that performs cleaning of the text file, such as:
>
>open (LISTING, "$path\\$list.txt") || die "Can't open $list.txt: $!";
>open (CLEANED, ">$path\\cleaned.txt") || die "Can't create cleaned.txt:
$!";
>while (<LISTING>) {
> s/Above user is in group\n//ig;
> s/^\n//ig;
> s/(\w+)\s(\w+)\n//ig;
> $_ =~ tr/a-z/A-Z/;
> print CLEANED $_;
> }
>close (LISTING);
>close (CLEANED);
>print ("Done ...\n\n\n");
Your explanation of the problem indicated that you wanted to remove
certain names that were followed by a certain string. The above code
looks nothing like either of the responses that have so far filtered
into my news server. It 'cleans' $list.txt by tearing out your sentinel
string, removing blank lines, removing lines with two words, and forcing
everything left over to uppercase. At no point did you remove the thing
which you initially indicated you wanted removed.
>> #!/usr/bin/perl -w
>> use strict;
>> my $lastline = '';
>> while (<DATA>) {
>> if ($_ eq "Above name is not in group\n") {
>> $lastline = '';
>> } else {
>> print $lastline;
>> $lastline = $_;
>> }
>> }
>> print $lastline;
> I've tried including the code that you provided but to no avail. How
would
> you insert it into the existing 'while' loop?
If you want to incorporate this code into your program, you have to know
what it's doing. What part of it is giving you trouble? What have you
tried so far?
Also, Larry Rosler posted a really slick solution to your problem, but
it may be sufficiently Perlish to be incomprehensible to you at this
stage of your learning. The perlvar: $/ documentation explains his
solution.
>Thanks for your patience !!!
Sure.
Lauren
--
Patience is not one of the three virtues, but a soft tone and a little
understanding can fake it. :-)
------------------------------
Date: Mon, 11 Oct 1999 18:36:55 -0700
From: "PB" <22pb22@excite.com>
Subject: Re: Advanced text substitution in FILEHANDLES
Message-Id: <7tu3eo$68n$1@fir.prod.itd.earthlink.net>
Lauren Smith <laurensmith@sprynet.com> wrote in message
news:7ttu0o$rpa$1@brokaw.wa.com...
> Either you don't fully understand the problem that you are presenting to
> the newsgroup, or you are not adequately explaining what the problem is.
>
> If you want to incorporate this code into your program, you have to know
> what it's doing. What part of it is giving you trouble? What have you
> tried so far?
>
I obviously didn't give enough information nor do I understand enough Perl
yet. I actually tried Kragen's solution first, which is the one that didn't
work or I probably didn't implement correctly.
This is the original LIST.TXT that I want to clean, and the CLEANED.TXT
output that I am looking for:
--- list.txt --------
user is john
Dept is TEST
Above user is in group
user is doe
Dept is TEST
Above use is not in group
user is blow
Dept is TEST
Above use is in group
user is mike
Dept is TEST
Above name is not in group
user is mike doe
Dept is TEST
Above name is in group
------ end list.txt --------------
------- cleaned.txt ---------
JOHN
BLOW
----- end cleaned.txt ----------
And this is the original script I wrote, but that is lacking the feature of
getting rid of the line above "Above name is not in group". Note that first
I'm taking out "user is " and the entire "Dept is TEST" line, and then
what's left is:
mike
Above name is not in group
Then I just took the entire "Above .. not .." line out but I also need
"mike" out of the cleaned list. My script is not ready to be able to take
the above name out, and that's why I asked.
open (LIST, "$path\\$list.txt") || die "Can't open $list.txt: $!";
open (CLEANED, ">$path\\cleaned.txt") || die "Can't create cleaned.txt: $!";
while (<LIST>) {
s/user is file://ig;
s/Dept is (\w+)\n//ig;
s/Above name is in group\n)//ig;
s/Above name is not in group\n)//ig;
s/^\n//ig; # Blank lines
s/(\w+)\s(\w+)\n//ig; # delete usernames with spaces
$_ =~ tr/a-z/A-Z/; # Uppercase all
print CLEANED $_;
}
close (LIST);
close (CLEANED);
> Also, Larry Rosler posted a really slick solution to your problem, but
> it may be sufficiently Perlish to be incomprehensible to you at this
> stage of your learning. The perlvar: $/ documentation explains his
> solution.
>
Yes. I looked up $/ after you mentioned it but obviously I'm not familiar
enough with Perl to start using $/. I'm still studying the docs. I didn't
understand Larry's solution either so I tried a few times to "plug it" into
my above code but I didn't know how to correctly.
Cheers,
pb
------------------------------
Date: Mon, 11 Oct 1999 13:32:42 -0500
From: TK Soh <r28629@email.sps.mot.com>
Subject: Re: Case Question.
Message-Id: <38022D49.22583372@email.sps.mot.com>
Kevin McCluskey wrote:
>
> I am trying to check a variable against an array of keywords and cannot
> get it to ignore the case.
> This is what I have:
Just that nobody seemed to mention it.
I have a _slight_ doubt that regex match may not be what you need, since
you are checking against a list of keywords. Perhaps you should check
out this FAQ, just in case:
perldoc perlfaq4:
How can I tell whether a list or array contains a certain
element?
Of 'cos you still need to build a 'case-insensitive hash' for your
purpose
HTH.
-TK
------------------------------
Date: 11 Oct 1999 23:40:37 GMT
From: Jeff Zucker <jeff@vpservices.com>
To: trailness@hotmail.com
Subject: Re: CGI Form interaction question
Message-Id: <3802752B.444C94C@vpservices.com>
Trail-Rider wrote:
> Please send a private e-mail to me; don't
> just reply to this in the newsgroup, as I don't have much time on my
> hands and it will take less time to check mail than it would to check
> the group.
I am replying to your email address this first time just to let you know
that you are unlikely to ever get good advice through email rather than
the newsgroup. It is called a group for a good reason - so that we *as
a group* can help answer questions. If I give you an answer, what is to
say that my answer is not itself wrong? The group is to say. So I post
something and if it needs correcting, someone in the group will correct
it. Also that way if there is any back and forth because you need
clarification of the answer, that back and forth becomes part of the
group record to help other newbies who might benefit from your learning
process.
My first major comment on your script is: USE ERROR-CHECKING! Perl has
lots of built-in ways to help you find out why things don't work but
they can only help you if you call on them. So, Instead of
#!/usr/local/bin/perl, try:
#!/usr/local/bin/perl -wT
use strict;
The "-w" turns on warnings; the "-T" turns on taint checking which is
important in a program such as this that gets information from outside;
and the "use strict" prevents you from making mistakes you might not
otherwise see. The "use strict" will mean you will have to put the word
"my" in front of all your variables the first time you use each one, but
that is a small price to pay for lots of valuable warnings.
Also, whenever you do something that might fail, put in an "or die $!"
to let you know what failed and why it failed. So, you have
> open Mail,"|mail tralridr@worldnet.att.net";
If that line fails, you'll never know it. Change it to:
open( Mail, "|mail tralridr@worldnet.att.net" )
or die "Couldn't open Mail: $!";
My second piece of advice is, do not use cgi-lib.pl. There is a much
better module to use that has many helpful features, rich documentation,
and is continually updated. So, try "use CGI". And you can read up on
it with "perldoc CGI".
My third piece of advice is use a module like Mail::Sendmail for sending
mail, not a direct use of your system's mailing program the way you
appear to be doing.
I may have missed some other things in your script, but the one big
error is this line:
> print_tag;
The ending tag for that kind of "here document" printing can not have a
semicolon or anything else on the line, it should just be print_tag and
a carriage return.
As for adding the form input into the body of your mail message. In
your current setup, you could do that by looping through the %input hash
and printing out the keys and values. If you were using CGI.pm as
suggested above, you could accomplish it with just two words: print
dump();
Hope this all helps!
--
Jeff
------------------------------
Date: Tue, 12 Oct 1999 02:15:11 +0200
From: Christoph Wernli <cw@dwc.ch>
Subject: Re: help re perl scripts to submit urls to engines
Message-Id: <38027D8F.462E1527@dwc.ch>
Roger Jacques wrote:
>
> I am fairly experienced with
> Perl and have used to extract pages from the
> Internet on a periodic basis but have not yet used
> Perl scripts to write to online forms.
>
> I need instructions and directions to available
> scripts that I could use as an examples ...
perldoc LWP::UserAgent
> anything
> that might help me get started. I intend to use
> mod-perl since we have an Apache server.
That's a totally different issue. You might want to have a look at http://perl.apache.org
> Please reply to -- channel@metalab.unc.edu, as
> well as to this posting.
Oh my...
-w
------------------------------
Date: Tue, 12 Oct 1999 00:17:23 GMT
From: rk27@my-deja.com
Subject: parsing words
Message-Id: <7ttum8$nlq$1@nnrp1.deja.com>
hi,
I have created a guest book using perl. I would like to know of a way of
detecting bad words. I currently have the program search for bad words
but some clever users started using spaces, symbols to prevent the
program from catching the bad words. For example assume DUCK is a bad
word. Normally, the guest book will replace it with blank spaces but if
the user types in
D U C K or D*U*C*K or D-U-C-K or D__U__C__K, the program will not catch
it. Is there anyway I can prevent this from happening.
Thanks a lot.
-rahul
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Oct 1999 00:43:24 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: parsing words
Message-Id: <slrn80511c.he.sholden@pgrad.cs.usyd.edu.au>
On Tue, 12 Oct 1999 00:17:23 GMT, rk27@my-deja.com <rk27@my-deja.com> wrote:
>
>
>hi,
>
>I have created a guest book using perl. I would like to know of a way of
>detecting bad words. I currently have the program search for bad words
>but some clever users started using spaces, symbols to prevent the
>program from catching the bad words. For example assume DUCK is a bad
>word. Normally, the guest book will replace it with blank spaces but if
>the user types in
>D U C K or D*U*C*K or D-U-C-K or D__U__C__K, the program will not catch
>it. Is there anyway I can prevent this from happening.
You could disallow all text, so that all posts would be blank.
That's about all you can do...
People tend to be better at recognising words masked like this than computers.
Consider :
DUK DLICK DU(K DVCK KCUD.
Adding a human to the loop is probably the only way. Even if all that person
does is add new regexes to match bad words based on the ones which are
slipping through.
There is also the problem of false positives.
Foreign words (or English words) which contain 'duck' in them somewhere.
Place names, People's names, etc.
If you much censor things, then bulk deletion of messages with 'bad' words
will probably convince people not to bother.
Such a policy would make it hard to talk about wonderful things like
South Park though.
--
Sam
About the only thing most people know about black holes is they are
black, and now we have stuffed that up
-- Dr Paul Francis (after reporting finding 'pink' holes)
------------------------------
Date: Mon, 11 Oct 1999 18:13:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: parsing words
Message-Id: <MPG.126c2b0094c3cea798a07b@nntp.hpl.hp.com>
In article <7ttum8$nlq$1@nnrp1.deja.com> on Tue, 12 Oct 1999 00:17:23
GMT, rk27@my-deja.com <rk27@my-deja.com> says...
> I have created a guest book using perl. I would like to know of a way of
> detecting bad words. I currently have the program search for bad words
> but some clever users started using spaces, symbols to prevent the
> program from catching the bad words. For example assume DUCK is a bad
> word. Normally, the guest book will replace it with blank spaces but if
> the user types in
> D U C K or D*U*C*K or D-U-C-K or D__U__C__K, the program will not catch
> it. Is there anyway I can prevent this from happening.
Sam Holden has given you an extended philosophical answer about why this
approach probably won't work. But if you want to pursue it, a regex
like this:
/\bD\W*U\W*C\W*\K\b/i
would match those occurrences and many others, regardless of the cases
of the letters. It is a nice little exercise to generate a list of
regexes like that, or a compound regex, from a list of words
automatically. (map, split, join, eval)
I presume that tr/D/F/ would give a more realistic example. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Oct 1999 18:27:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: parsing words
Message-Id: <Pine.GSO.4.10.9910111816520.19155-100000@user2.teleport.com>
On Tue, 12 Oct 1999 rk27@my-deja.com wrote:
> I have created a guest book using perl. I would like to know of a way
> of detecting bad words. I currently have the program search for bad
> words but some clever users started using spaces, symbols to prevent
> the program from catching the bad words. For example assume DUCK is a
> bad word. Normally, the guest book will replace it with blank spaces
> but if the user types in D U C K or D*U*C*K or D-U-C-K or D__U__C__K,
> the program will not catch it. Is there anyway I can prevent this from
> happening.
You need a program that's at least as smart as the people who are trying
to outsmart it. That's not a simple matter.
One system I heard of did a good job of suppressing bad words until the
dog breeders needed to talk about their bitches. Another wouldn't let
anyone discuss the region of Scunthorpe in Great Britain. Overkill.
I heard that someone made a closed caption decoder which tried to
substitute nicer words for the bad ones. It sanitized "Dick Van Dyke" into
"Jerk Van Lesbian".
Sure, you could make a program which would strip the punctuation and scan
the rest, but the vandals will still find a way to sneak past with a few
_ _ _ _
__| (_)_ __| |_ _ _ __ _____ _ __ __| |___
/ _` | | '__| __| | | | \ \ /\ / / _ \| '__/ _` / __|
| (_| | | | | |_| |_| | \ V V / (_) | | | (_| \__ \
\__,_|_|_| \__|\__, | \_/\_/ \___/|_| \__,_|___/
|___/
I suggest that you simply save each day's additions to a file for a human
being to check before appending. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 11 Oct 1999 18:39:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Passing unknown filenames as arguments to another program
Message-Id: <m1yad9s6gu.fsf@halfdome.holdit.com>
>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
A> Nope. He said "hundreds of files". Which would mean `blastcl3 *.seq'
A> might very well run into shell buffer limits. That's why I used the xargs.
Uri> randal's point about ls and dirs is valid. so you use echo *.seq
Uri> instead. xargs is needed if the number of files will blow up the shell's
Uri> line buffer or max command line args.
Well, no, echo will have that problem too.
ls -f | grep '^[^.].*\.seq$' | xargs blastcl3
will probably be about the fastest you can get. Without resorting to
Perl. In Perl, this would be simply:
#!/usr/bin/perl
opendir DOT, "." or die;
exec "blastcl3", sort grep /^[^.].*\.seq$/, readdir DOT;
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 11 Oct 1999 18:46:51 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Passing unknown filenames as arguments to another program
Message-Id: <yld7ultkok.fsf@windlord.stanford.edu>
Randal L Schwartz <merlyn@stonehenge.com> writes:
>>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
> Uri> randal's point about ls and dirs is valid. so you use echo *.seq
> Uri> instead. xargs is needed if the number of files will blow up the
> Uri> shell's line buffer or max command line args.
> Well, no, echo will have that problem too.
Depends on your shell. Since it's a shell builtin, some shells are smart
enough to be able to handle much larger globs that way.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Tue, 12 Oct 1999 00:22:38 GMT
From: dalekh@hotmail.com (d.k. henderson)
Subject: Re: Perl Interview Question:
Message-Id: <8E5BCFB11dkhenderson@207.14.236.70>
10
------------------------------
Date: Mon, 11 Oct 1999 17:57:20 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl Interview Question:
Message-Id: <MPG.126c274d80e79f2798a07a@nntp.hpl.hp.com>
In article <8E5BCFB11dkhenderson@207.14.236.70> on Tue, 12 Oct 1999
00:22:38 GMT, d.k. henderson <dalekh@hotmail.com> says...
>
> 10
My, my. That couldn't be right, for two reasons.
1. If it were right, the question wouldn't have been asked. :-)
2. That's not what the program does when you try it. You did try it,
didn't you? I guess not. :-(
From perlsyn:
The foreach loop iterates over a normal list value and sets the variable
VAR to be each element of the list in turn. If the variable is preceded
with the keyword my, then it is lexically scoped, and is therefore
visible only within the loop. Otherwise, the variable is implicitly
local to the loop and regains its former value upon exiting the loop.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Oct 1999 17:06:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl lite
Message-Id: <MPG.126c1b4df680ad3298a079@nntp.hpl.hp.com>
In article <slrn804gi9.gep.abigail@alexandra.delanet.com> on 11 Oct 1999
15:02:31 -0500, Abigail <abigail@delanet.com> says...
> John Kristian (kristian@netscape.com) wrote on MMCCXXXII September
> MCMXCIII in <URL:news:38022B7C.2B2C790F@netscape.com>:
> ^^ How can I make Perl occupy less disk space?
> ^^ I mean without making it useless, of course.
> ^^
> ^^ The HTML documentation uses a lot of disk space;
> ^^ eliminating it would yield a smaller footprint.
> ^^ I thought I might replace it with links to the Web.
> ^^ Have you tried something similar?
>
> No. du -k /opt/perl yields 25Mb, and that's including the gzipped
> tar file and site_perl. Only about 10% of that is taken by
> /opt/perl/man/man1.
The HTML documentation in the ActiveState distribution is about 8 MB.
> I wouldn't want to delete any of it. Disk space isn't that expensive
> nowadays. I'm sure you have other junk you can delete. ;-)
Agreed!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 11 Oct 1999 16:14:56 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: sprintf help
Message-Id: <38026F70.EA78BE63@cisco.com>
Scott Beck wrote:
> Can someone point in the write direction to learn more
> about the sprintf command. I have read the perldocs on it
> and none of them seem to get into much detail.
man sprintf should suffice.
--
------------------------------
Date: Mon, 11 Oct 1999 23:23:48 GMT
From: Scott Beck <scott_beck@my-deja.com>
Subject: Re: sprintf help
Message-Id: <7ttrho$l95$1@nnrp1.deja.com>
In article <7ttht5$e7t$1@nnrp1.deja.com>,
The Glauber <theglauber@my-deja.com> wrote:
> In article <7ttgsr$dbo$1@nnrp1.deja.com>,
> Scott Beck <scott_beck@my-deja.com> wrote:
> > Can someone point in the write direction to learn more
> > about the sprintf command. I have read the perldocs on it
> > and none of them seem to get into much detail.
>
> perldoc -f sprintf, in my system, showed all the documentation. The
> problem is, this whole printf/sprintf stuff is based on C, and if you
> don't know C you may be baffled by it. Look for a C textbook, or a
> friendly C programmer.
>
> Keep in mind that in C you pass the buffer to be populated by sprintf
> as the first parameter; in Perl, you don't pass a buffer, you just use
> the return value from sprintf directly to populate a variable:
>
> in C: sprintf( buffer, "%09d", myint );
>
> in Perl: $buffer = sprintf "%09d", $myint;
>
> HTH...
>
Yes it certainly did. I guess I was looking in the wrong place
for the detailed explanation I wanted.
I asked my C++ programmer friend and he faxed me the info.
> glauber
>
> --
> Glauber Ribeiro
> theglauber@my-deja.com
> "Opinions stated are my own and not representative of Experian"
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
--
Thanks
Scott Beck
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 11 Oct 1999 19:32:08 -0600
From: "Sean Montgomery" <smontgomery@digitalblaze.net>
Subject: Use Perl to Close File In Use on NT?
Message-Id: <k9wM3.147$BG2.450@newsfeed.slurp.net>
I need to be able to write a Perl script that allows closing a file on a
remote NT server (NT4). In other words, I am on server A and somebody has
the file 'somefile.exe' open on server B. Is it possible that Perl can
close this file handle? The problem is that we are attempting to replace
'somefile.exe' with an updated version, and it fails because the file is in
use. I can manually close the file through File Manager or Server Manager,
but we'd like to automate this process.
Any help is appreciated.
Sean Montgomery
------------------------------
Date: Mon, 11 Oct 1999 19:32:08 -0600
From: "Sean Montgomery" <smontgomery@digitalblaze.net>
Subject: Use Perl to Close File In Use on NT?
Message-Id: <%awM3.150$BG2.95@newsfeed.slurp.net>
I need to be able to write a Perl script that allows closing a file on a
remote NT server (NT4). In other words, I am on server A and somebody has
the file 'somefile.exe' open on server B. Is it possible that Perl can
close this file handle? The problem is that we are attempting to replace
'somefile.exe' with an updated version, and it fails because the file is in
use. I can manually close the file through File Manager or Server Manager,
but we'd like to automate this process.
Any help is appreciated.
Sean Montgomery
------------------------------
Date: Mon, 11 Oct 1999 19:32:08 -0600
From: "Sean Montgomery" <smontgomery@digitalblaze.net>
Subject: Use Perl to Close File In Use on NT?
Message-Id: <MawM3.149$BG2.1345@newsfeed.slurp.net>
I need to be able to write a Perl script that allows closing a file on a
remote NT server (NT4). In other words, I am on server A and somebody has
the file 'somefile.exe' open on server B. Is it possible that Perl can
close this file handle? The problem is that we are attempting to replace
'somefile.exe' with an updated version, and it fails because the file is in
use. I can manually close the file through File Manager or Server Manager,
but we'd like to automate this process.
Any help is appreciated.
Sean Montgomery
------------------------------
Date: Mon, 11 Oct 1999 19:32:08 -0600
From: "Sean Montgomery" <smontgomery@digitalblaze.net>
Subject: Use Perl to Close File In Use on NT?
Message-Id: <dbwM3.152$BG2.891@newsfeed.slurp.net>
I need to be able to write a Perl script that allows closing a file on a
remote NT server (NT4). In other words, I am on server A and somebody has
the file 'somefile.exe' open on server B. Is it possible that Perl can
close this file handle? The problem is that we are attempting to replace
'somefile.exe' with an updated version, and it fails because the file is in
use. I can manually close the file through File Manager or Server Manager,
but we'd like to automate this process.
Any help is appreciated.
Sean Montgomery
------------------------------
Date: Mon, 11 Oct 1999 19:32:08 -0600
From: "Sean Montgomery" <smontgomery@digitalblaze.net>
Subject: Use Perl to Close File In Use on NT?
Message-Id: <9ewM3.156$BG2.537@newsfeed.slurp.net>
I need to be able to write a Perl script that allows closing a file on a
remote NT server (NT4). In other words, I am on server A and somebody has
the file 'somefile.exe' open on server B. Is it possible that Perl can
close this file handle? The problem is that we are attempting to replace
'somefile.exe' with an updated version, and it fails because the file is in
use. I can manually close the file through File Manager or Server Manager,
but we'd like to automate this process.
Any help is appreciated.
Sean Montgomery
------------------------------
Date: Mon, 11 Oct 1999 21:17:31 -0500
From: Frank Hale <frankhale@trespass.net>
Subject: use strict problem
Message-Id: <38029A3B.8A27C8A1@trespass.net>
Say I have the following 2 files.
-- config.pl
#!/usr/bin/perl -w
#
use strict;
my $name = "frank";
require "main.pl";
-- main.pl
#!/usr/bin/perl -w
#
use strict;
print $name;
howcome when I run config.pl I get the following error
Global symbol "$name" requires explicit package name at main.pl line 6.
Compilation failed in require at ./config.pl line 8.
Please forgive me if this is trivial, I am fairly new to Perl.
--
From: Frank Hale
Email: frankhale@yahoo.com
ICQ: 7205161
------------------------------
Date: 11 Oct 1999 23:50:32 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: use strict
Message-Id: <3802777A.6071BBE7@vpservices.com>
Frank Hale wrote:
>
> I am in the process of writing a cgi application. I am relatively new to
> perl and would like to know if I should use the "-w" option and "use
> strict;" in all my scripts?
Yes.
> Is it bad practice to not use these?
Yes.
Also you might want "use diagnostics" although it is less important. If
your script reads things from outside (like most CGI scripts do) and
then sends them potentially dangerous places, you should also use -T to
turn on taint checking. Also put in "or die $!" statements all over
your scripts, especially when you do things with files like opening,
writing to, or reading them.
--
Jeff
------------------------------
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 V9 Issue 1045
**************************************