[16423] in Perl-Users-Digest
Perl-Users Digest, Issue: 3835 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 28 18:05:40 2000
Date: Fri, 28 Jul 2000 15:05:22 -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: <964821922-v9-i3835@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 28 Jul 2000 Volume: 9 Number: 3835
Today's topics:
Re: -T switch (Bill Feidt)
Re: Advanced Perl Programming -- Dated? <dan@tuatha.sidhe.org>
Apology to perl newsgroup <toyboy@toy.eyep.net>
calling external programs from perl <bd0296@cnsvax.albany.edu>
Can someone tell me why I can't system() an expect scri <fnord@mailroom.com>
Re: Can't find IO::Pager <makarand_kulkarni@my-deja.com>
Re: can't use global $^W in "my"... ()
Re: can't use global $^W in "my"... (Marcel Grunauer)
Re: can't use global $^W in "my"... <lauren_smith13@hotmail.com>
Re: can't use global $^W in "my"... <tina@streetmail.com>
Re: can't use global $^W in "my"... <eaglewing@zensearch.com>
Re: can't use global $^W in "my"... <eaglewing@zensearch.com>
Re: can't use global $^W in "my"... <eaglewing@zensearch.com>
CGI Perl script on NT for netscape enterprise server <jqyuanNOjqSPAM@excite.com.invalid>
Re: difference between two times in seconds (Logan Shaw)
Differences between two files? <jcook@strobedata.com>
Re: Differences between two files? <lr@hpl.hp.com>
Re: Differences between two files? <jcook@strobedata.com>
Disconnecting from NT server <mike@cyborg-group.com>
Re: Disconnecting from NT server (Marcel Grunauer)
Re: Disconnecting from NT server <mike@cyborg-group.com>
Re: Disconnecting from NT server <lauren_smith13@hotmail.com>
Re: file extension <danielxx@bart.nl>
Re: how to process all fields on a form <makarand_kulkarni@my-deja.com>
Re: How to trim strings? <lr@hpl.hp.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Jul 2000 20:41:01 GMT
From: wfeidt@cpcug.org (Bill Feidt)
Subject: Re: -T switch
Message-Id: <8F7FA9DA1wfeidthiscom@207.126.101.97>
vicki@kr8.com (Vicki Youll) wrote in <8ls9cv$7sd$1@duke.telepac.pt>:
>I have no experience with perls "taint" - however am trying to use
>taint mode via the -T switch on the #! perl interpreter line
> (e.g #! /usr/bin/perl -w -T) . I however receive this message back
> when
>i execute my script on the perl command line " Too late for -T option"
>. What does this mean ? and how can i run my cgi scripts under taint
>mode? I would appreciate any suggestions. Thanks.
>
>This is the first few lines of my code - if this helps.
>
>
>#! /usr/bin/perl -w -T
>
>use CGI qw(:standard);
>use CGI::Carp qw(fatalsToBrowser);
>use diagnostics;
>use strict;
The -T flag must be invoked at the time perl runs. If you
call your program from the command line like this:
/usr/bin/perl -w -T [program name]
that's fine. Taint is now in effect.
But, now, perl looks inside your [program name] and finds:
#! /usr/bin/perl -w -T
Because perl is already running (you invoked it from the command
line), it now sees a second "-T" flag and, in effect, says,
"whoa, I'm alreading running; it's too late to invoke -T now".
If you're going to be calling the program from the command line
for testing like this:
perl -w -T [program name],
don't even include the shebang line in the program file. That
way you'll avoid invoking perl and -T twice, and the resulting
warnings. Of course, you'll want to change things back before
you put it into "cgi production".
I beat my head against the wall over the same problem for a day
and a half a couple of weeks ago.
HTH,
Bill
wfeidt@cpcug.org
------------------------------
Date: Fri, 28 Jul 2000 20:52:01 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Advanced Perl Programming -- Dated?
Message-Id: <Rnmg5.8306$f_5.34629@news1.rdc1.ct.home.com>
Steffen Beyer <sb@muccpu1.muc.sdm.de> wrote:
> In article <6lt2oscppblhkrvaal78i3p72ucko1da93@4ax.com>, Bart Lateur <bart.lateur@skynet.be> wrote:
>>>a) you would break loads of programs
>>>c) such a fundamental change might be pretty confusing for existing
>>>Perl programmers
>> But they plan on dumping support for typeglobs, and maybe even stashes.
>> Won't that break a lot of programs, too?
>> I think my proposal (from the top of my head, really) is pretty much in
>> line with that.
> And just think about it: Without typeglobs, no aliases for subroutines
> or variables anymore, no import of symbols in "use Module qw(...)" anymore,
> no "use English;" anymore, etc.!
Huh? How does one follow from the other? Just because typeglobs doesn't
exist doesn't mean any of the other things don't exist. Heck, you can do
all that stuff now without using typeglobs.
Dan
------------------------------
Date: Fri, 28 Jul 2000 17:42:18 -0400
From: jtoy <toyboy@toy.eyep.net>
Subject: Apology to perl newsgroup
Message-Id: <3981FE3A.D2807E3B@toy.eyep.net>
I recently posted an article callled "help newb Q perl guy just left"
. The thread got out of hand because of the way I asked my question and
then after people answered, I talked back rudely. I am sorry for
causing trouble in here. If possible, I would like to join this
newsgroup in hopes of learning and understanding perl and its
community. If I am not welcome, I understand. Once again sorry, and I
won't make any trouble anymore. Also, could anyone please tell me what
a killfile is? I heard the name many times in hear, but have never
heard of it before. And finally, what specific material would you
recommend for me to read to get a dip into perl? Thanks.
Jason Toy
toyboy@toy.eyep.net
------------------------------
Date: Fri, 28 Jul 2000 19:41:20 GMT
From: neurologic <bd0296@cnsvax.albany.edu>
Subject: calling external programs from perl
Message-Id: <8lsnkv$fd$1@nnrp1.deja.com>
Hi everyone,
i am developing a curses-based application which allows non-technical
helpdesk staff to kill and restart a troublesome java app. we are using
Sun boxes with Solaris 2.6.
The problem i run into is when I attempt to start this application from
perl, with the following line:
system( '/u/cli/bin/java -cs -ss450k -mx300m com.cube.db.broker
.AppBroker INTG> /u/cli/log/console.log;' );
when i execute this code, nothing happens whatsoever. is it possible to
run an external program a redirect it's output like i would like to do?
Any assistance here would be appreciated.
neurologic
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Jul 2000 18:59:42 GMT
From: Christopher Robert Woods <fnord@mailroom.com>
Subject: Can someone tell me why I can't system() an expect script?
Message-Id: <8lsl6r$ucu$1@nnrp1.deja.com>
Trying to make an interface to userman on my Solaris boxes, the end
result being that the user account is created and the password set to
their username, and then expired. However, in order to set the
password, I am using an expect script. That doesn't appear to be
working. userman.pl is the perl script, which just prompts for
settings. chgpass is the expect script, which takes 2 parameters,
username and password. They are posted below, if anyone has any ideas,
I would be most grateful. Thanks!
Anyways, I don't get any response back as far as whether or not the
password is changed or if there was an error, or anything.
Also, chgpass works from the command line, but not from this script.
Thanks!
#!/usr/local/bin/perl
# userman
###################################################
## Usermanager script to make user additions easier
###################################################
print "-" x 80 . "\n";
print "--";
print " "x 23.5;
print "User Manager - by Chris Woods";
print " "x 23.5;
print " ";
print "--\n";
print "-" x 80 . "\n";
###################################################
##
## Change system wide defaults here
##
###################################################
$defshell="/bin/csh";
$defgroup="10";
$defdir="/export/home/$username";
##################################################
## First get the user variables
##################################################
if (@ARGV[0] eq "") {
print "Enter username: ";
$username=<STDIN>;
chomp($username);
while ($username eq "") { print "You must enter a username: ";
$username=<STDIN>;
chomp($username);}
###################################################
## Here we could look for the next logical one w/ passwd
## file
###################################################
print "Enter UID: ";
$uid=<STDIN>;
chomp($uid);
while ($uid eq "") { print "You must enter an uid: ";
$uid=<STDIN>;
chomp($uid);}
print "Enter GUID (Default=$defgroup): ";
$dupe=<STDIN>;
chomp($dupe);
if ($dupe ne "") {$defgroup=$dupe;
chomp($defgroup);}
print "Enter Shell (Default=$defshell): ";
$dupe=<STDIN>;
chomp($dupe);
if ($dupe ne "") {$defshell=$dupe;
chomp($defshell);}
print "Enter home directory (Default=$defdir): ";
$dupe=<STDIN>;
chomp($dupe);
if ($dupe ne "") {$defdir=$dupe;
chomp($defdir);}
print "(Optional) Enter a comment for this user: ";
$comment=<STDIN>;
chomp($comment);
if ($comment eq "") { $comment="System User";}
####################################################
## Now we have everything all set, lets add the user
####################################################
exec "useradd -u $uid -g $defgroup -d $defdir -s $defshell -c "
. '"' . $comment .'"' . " $username";
system("/export/home/woodsch/src/chgpass", $username,
$username);
exec "passwd -f $username";
}
###CUT HERE#########
#chgpass
#!/usr/local/bin/expect -f
set password [lindex $argv 1]
spawn passwd [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
###CUT HERE
You can make fun of my lack of skillz, but don't make fun of my code, I
try to keep it vewy vewy neat. ;)
--
Christopher Robert Woods - MCSE, CCNA
fnord@mailroom.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 28 Jul 2000 13:29:25 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: "Kelly F. Hickel" <kfh@mqsoftware.com>
Subject: Re: Can't find IO::Pager
Message-Id: <3981ED25.9B609FB5@my-deja.com>
"Kelly F. Hickel" wrote:
>
> I'm using the packager Getopt::Declare, and it says that if the module
> IO::Pager is present, it will use that to page output to STDOUT. The
> problem is that I can't seem to find IO::Pager on CPAN.
>
> Does anyone know where to get IO::Pager, or what I'm doing wrong?
I found IO::Pager in the source
code given with the book
Object Oriented Perl --Conway.
see:
http://www.manning.com/Conway/source.html
------------------------------
Date: Fri, 28 Jul 2000 18:12:32 GMT
From: sjs@yorku.ca ()
Subject: Re: can't use global $^W in "my"...
Message-Id: <slrn8o3j82.8ep.sjs@john.sympatico.ca>
eaglewing <eaglewing@zensearch.com> wrote:
>If someone could help me with this before I am unable to resist putting my
>fist through my screen I'd be very much obliged.
That is the sign that a Mountain Dew and a walk around the block are
in order.
>On a linux/apache setup, I have a relatively simple script which seems throw
>this error 50% of the time (a refresh on the browser will make it go away,
>refresh again it will come back):
>
>[Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
>/home/gavin/codebase/v1/scripts/lucia2 line 1
You should check man perldiag if you get an error or warning you don't
immediately understand. From perldiag:
Can't use global %s in """"my""""
(F) You tried to declare a magical variable as a
lexical variable. This is not allowed, because the
magic can be tied to only one location (namely the
global variable) and it would be incredibly confusing
to have variables in your program that looked like
magical variables but weren't.
So, don't try to make $^W into a lexical.
Steve
------------------------------
Date: Fri, 28 Jul 2000 18:09:03 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: can't use global $^W in "my"...
Message-Id: <slrn8o3jcq.bru.marcel@gandalf.local>
On Fri, 28 Jul 2000 11:03:14 -0700, eaglewing <eaglewing@zensearch.com> wrote:
>[Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
>/home/gavin/codebase/v1/scripts/lucia2 line 1
Well, to ask the obvious, you didn't do something like 'my $^W = 1' ?
Because perlvars like $^W, $_ etc. can't be declated as lexicals.
Just use '$^W = 1' and it'll be ok.
But that was too obvious...
--
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Fri, 28 Jul 2000 11:11:42 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: can't use global $^W in "my"...
Message-Id: <8lsib6$qm0$1@brokaw.wa.com>
eaglewing <eaglewing@zensearch.com> wrote in message
news:8lshu6$56vab$1@ID-41717.news.cis.dfn.de...
>
> On a linux/apache setup, I have a relatively simple script which seems
throw
> this error 50% of the time (a refresh on the browser will make it go away,
> refresh again it will come back):
>
> [Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
> /home/gavin/codebase/v1/scripts/lucia2 line 1
Maybe you could post some code?
In the meantime, see what perldiag has to say about that particular warning.
Lauren
------------------------------
Date: 28 Jul 2000 18:30:45 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: can't use global $^W in "my"...
Message-Id: <8lsjgl$562ev$2@ID-24002.news.cis.dfn.de>
hi,
Marcel Grunauer <marcel@codewerk.com> wrote:
> On Fri, 28 Jul 2000 11:03:14 -0700, eaglewing <eaglewing@zensearch.com> wrote:
>>[Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
>>/home/gavin/codebase/v1/scripts/lucia2 line 1
> Well, to ask the obvious, you didn't do something like 'my $^W = 1' ?
> Because perlvars like $^W, $_ etc. can't be declated as lexicals.
> Just use '$^W = 1' and it'll be ok.
well, if he was trying to localize $^W, he should use
local $^W = 1;
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Fri, 28 Jul 2000 12:06:58 -0700
From: "eaglewing" <eaglewing@zensearch.com>
Subject: Re: can't use global $^W in "my"...
Message-Id: <8lslm1$57hje$1@ID-41717.news.cis.dfn.de>
"Marcel Grunauer" <marcel@codewerk.com> wrote in message
news:slrn8o3jcq.bru.marcel@gandalf.local...
> On Fri, 28 Jul 2000 11:03:14 -0700, eaglewing <eaglewing@zensearch.com>
wrote:
>
> >[Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
> >/home/gavin/codebase/v1/scripts/lucia2 line 1
>
>
> Well, to ask the obvious, you didn't do something like 'my $^W = 1' ?
> Because perlvars like $^W, $_ etc. can't be declated as lexicals.
>
> Just use '$^W = 1' and it'll be ok.
>
> But that was too obvious..
thanks for the mail, but I should have made myself more clear, I haven't
used $^W anywhere...heres my code
#!/usr/local/bin/perl -w
use strict;
require CGI;
use DBI;
$ENV{ORACLE_BASE}='/usr/local/oracle';
$ENV{ORACLE_HOME}='/usr/local/oracle';
$ENV{LD_LIBRARY_PATH}="/usr/local/oracle/lib";
use vars qw(@dblist @mainparam @yusers);
@dblist=qw(first second third);
@mainparam=qw(userid email);
@yusers=qw(gavin);
MAIN:
{
my ($r) = new CGI;
if ($r->param('dodb')) {
bldquery($r);
} else {
my $user = $r->param('user');
my $pass = $r->param('pass');
$main::ivalid = 0;
if ($user eq "gavin" ||
$user eq "firstusr" ||
$user eq "secondusr" ||
$user eq "thirdusr" ) {
$main::ivalid = 1;
} else {
$main::ivalid = 0;
}
if (!$main::ivalid) {
usrerr($r);
} else {
input($r);
}
}
}
sub input
{
my ($r) = @_;
$input::ifulldisp = 0;
my $url = $r->url;
$r->print($r->header());
$r->print($r->start_html(-title =>"Accounts"));
$r->print( $r->startform(-action=>$url) );
foreach $input::pers (@yusers)
{
if ($r->param('user') eq $input::pers) {
$input::ifulldisp = 1;
}
}
if ($input::ifulldisp) {
$r->print( $r->h2("Database") );
$r->print(
$r->popup_menu(-name=>'pdb', -values=>\@dblist, -default=>'first') );
}
$r->print( $r->h2("Account identifier") );
$r->print(
$r->popup_menu(-name=>'puid', -values=>\@mainparam, -default=>'userid') );
$r->print("<TABLE cellpadding=10>
<TR> <TD>value: </TD><TD> " .
$r->textfield(-name=>'sid') . "</TD></TR>
</TABLE>");
$r->print( $r->h2("Function") );
@input::funclist=('func', 'list', 'move');
$r->print(
$r->popup_menu(-name=>'pfunc', -values=>\@input::funclist, -default=>'func')
);
$r->print("<TABLE cellpadding=10>
<TR> <TD>value: </TD><TD> " .
$r->textfield(-name=>'dispnam') . "</TD></TR>
</TABLE>");
$r->print( $r->submit(-name=>'dodb', -value=>'submit') );
$r->print( $r->endform());
}
sub usrerr
{
my ($r) = @_;
my $url = $r->url;
$r->print($r->header());
$r->print($r->start_html(-title =>'Error!'));
$r->print( $r->startform(-action=>$url));
$r->print( $r->h1( " Username invalid "));
$r->print( "<TABLE cellpadding=10>
<TR> <TD>Username: </TD><TD> " .
$r->textfield(-name=>'user') . "</TD></TR>
<TR> <TD>Password: </TD><TD> " .
$r->textfield(-name=>'pass') . "</TD></TR>
</TABLE>");
$r->print( $r->submit(-name=>'ssubmit', -value=>'submit') );
$r->print($r->endform());
}
sub bldquery
{
my ($r) = @_;
$bldquery::dbusr = "gavin";
$bldquery::dbpass = "gavin";
$bldquery::wrkdb = $r->param( 'pdb');
if ($r->param('puid') eq 'userid') {
$bldquery::wherestat = "WHERE mem.id = item.id AND
user_nam " . " = " . uc($r->param('sid')) . " AND
item_name like " . ($r->param('dispname'));
} elsif ($r->param('puid') eq 'email') {
$bldquery::wherestat = "WHERE email_add " . " = " . $r->param('sid');
}
$bldquery::dbh = DBI->connect("dbi:Oracle:dasb", $bldquery::dbusr,
$bldquery::dbpass);
if ($r->param('pfunc') eq 'func') {
$bldquery::sth = $bldquery::dbh->prepare( " SELECT mem_item_id
FROM mem_table " .
$bldquery::wherestat
);
$bldquery::sth->execute();
$r->print($r->header());
$r->print($r->start_html(-title =>'Results'));
$r->print($r->h1("Results:"));
while ( @bldquery::out = $bldquery::sth->fetchrow_array) {
$r->print( " <TABLE cellpadding=10>
<TR> <TD>First: </TD> " . "
<TD>$bldquery::out</TD></TR>
</TABLE>");
}
}
$bldquery::dbh->disconnect;
}
------------------------------
Date: Fri, 28 Jul 2000 12:08:25 -0700
From: "eaglewing" <eaglewing@zensearch.com>
Subject: Re: can't use global $^W in "my"...
Message-Id: <8lsloe$5aouf$1@ID-41717.news.cis.dfn.de>
"Lauren Smith" <lauren_smith13@hotmail.com> wrote in message
news:8lsib6$qm0$1@brokaw.wa.com...
>
> eaglewing <eaglewing@zensearch.com> wrote in message
> news:8lshu6$56vab$1@ID-41717.news.cis.dfn.de...
> >
> > On a linux/apache setup, I have a relatively simple script which seems
> throw
> > this error 50% of the time (a refresh on the browser will make it go
away,
> > refresh again it will come back):
> >
> > [Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
> > /home/gavin/codebase/v1/scripts/lucia2 line 1
>
> Maybe you could post some code?
>
> In the meantime, see what perldiag has to say about that particular
warning.
I understand the error, but I don't see why its being generated as I'm not
using $^W, I've posted my code in my above response
------------------------------
Date: Fri, 28 Jul 2000 12:10:26 -0700
From: "eaglewing" <eaglewing@zensearch.com>
Subject: Re: can't use global $^W in "my"...
Message-Id: <8lsls7$589e1$1@ID-41717.news.cis.dfn.de>
<sjs@yorku.ca> wrote in message news:slrn8o3j82.8ep.sjs@john.sympatico.ca...
> eaglewing <eaglewing@zensearch.com> wrote:
> >If someone could help me with this before I am unable to resist putting
my
> >fist through my screen I'd be very much obliged.
>
> That is the sign that a Mountain Dew and a walk around the block are
> in order.
ugh...mountain dew would make it worse :) a vodka and a walk around the
block would be preferable
> >On a linux/apache setup, I have a relatively simple script which seems
throw
> >this error 50% of the time (a refresh on the browser will make it go
away,
> >refresh again it will come back):
> >
> >[Thu Jul 27 22:13:06 2000] [error] Can't use global $^W in "my" at
> >/home/gavin/codebase/v1/scripts/lucia2 line 1
>
> You should check man perldiag if you get an error or warning you don't
> immediately understand. From perldiag:
>
> Can't use global %s in """"my""""
> (F) You tried to declare a magical variable as a
> lexical variable. This is not allowed, because the
> magic can be tied to only one location (namely the
> global variable) and it would be incredibly confusing
> to have variables in your program that looked like
> magical variables but weren't.
>
> So, don't try to make $^W into a lexical.
I'm not explicitly using $^W...it seems to be 'sneaking' in somehow, if you
want my code is listed in my reply to Marcel
------------------------------
Date: Fri, 28 Jul 2000 13:50:45 -0700
From: matt899 <jqyuanNOjqSPAM@excite.com.invalid>
Subject: CGI Perl script on NT for netscape enterprise server
Message-Id: <0a0ec104.6cb31815@usw-ex0103-018.remarq.com>
I'm new to perl and need help! I wrote a simple perl script and
intended to use it as a CGI.
print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<TITLE>hello</TITLE>\n</HEAD>\n";
print "<BODY>\n";
print "<p>hello!\n</p>";
print "</BODY>\n</HTML>";
When I tested it under DOS, it prints...But when used with URL,
it says:
Not Found
The requested object does not exist on this server. The link you
followed is either outdated, inaccurate, or the server has
been instructed not to let you have it.
I know with unix I need to add the header #!/usr/bin/perl but I
am on NT. Can somebody tell me what's wrong with my code?
thanks!
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 28 Jul 2000 16:42:55 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: difference between two times in seconds
Message-Id: <8lsuov$sir$1@provolone.cs.utexas.edu>
In article <slrn8o1c1u.vcg.abigail@alexandra.foad.org>,
Abigail <abigail@foad.org> wrote:
>Logan Shaw (logan@cs.utexas.edu) wrote on MMDXXII September MCMXCIII in
><URL:news:8lq8n1$pso$1@provolone.cs.utexas.edu>:
>'' The "for" loop does a loop with a condition, which I'd say is a very
>'' important part of the computation.
>
>So... what does the "for" compute?
Nothing. Likewise, the regular expression itself computes nothing. It
is only the properly arranged combination of the two that computes
anything.
Computers are state machines. They have a state, and they have logic
which takes them from one state to the next. Computation happens when
the proper logic and initial state come together so that you can make a
progression through any intermediate states and reach the desired final
state.
If the logic you supply (in the form of a regular expression) is not
enough logic to make that progression of states, then the logic you
have supplied is not enough to solve the problem. Therefore, it can't
be said to be computing the solution.
>But I see your point. Nothing can be calculated with a regex alone.
>After all, you'd need Perl, an OS, hardware, electricity and fingers.
And that copy of perl has to implement both regular expressions and a
for loop for your solution to work.
- Logan
------------------------------
Date: Fri, 28 Jul 2000 12:11:53 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: Differences between two files?
Message-Id: <3981DAF9.33B33665@strobedata.com>
I have two files, read into $a and $b that I test for equality with $a
eq $b. However, because of the nature of the files, a few differences
are OK. What I'm interested in is how many different bytes there are
within $a and $b (assuming same length here).
Is there an easy way that doesn't involve something horrid like "foreach
(split(//, $a))"?
(I have looked for a "diff" program, but that seems like it might be
overkill for this project. If two files are different sizes, that's an
entirely different category than a file that stayed the same size but
had minor differences inside.)
My real problem is that I have two directories of release software
(different versions). The software is serial number stamped to make a
matched set. Some files are stamped and some are not.
I want to see what's been created for the new release, what's been
removed, what's been maintained with or without a stamp, and what's been
updated completely.
So, I want to generate a report, something like the stuff below. Right
now, I'm detecting the "branded file" with a special case, and it works
passably. There are other files that would be good to be able to say "10
bytes differ" or something like that.
Files exclusively in .\
502 Nov 3,1997 13:27:12 example.cnf
8,934 Dec 23,1999 09:39:52 example.pdp
199 Jul 14,2000 15:51:12 hwdiag.x86
481,280 Jul 27,2000 13:47:04 osprey.exe
----------------------------------------------------------------------
Files exclusively in t:\dx\nt\
30,656 Jul 14,2000 15:30:42 osdxdriv.sys
----------------------------------------------------------------------
Files in both .\ and t:\dx\nt\
8,232 Nov 14,1997 17:21:32 branded file .\1123.iot
8,232 Nov 14,1997 17:21:32 branded file t:\dx\nt\1123.iot
93,212 Jul 14,2000 15:51:10 new different data .\hwdiag.exe
127,488 Jul 14,2000 15:32:30 old different data
t:\dx\nt\hwdiag.exe
8,232 Nov 1,1996 15:24:04 .\coredata.ram
8,232 Nov 1,1996 15:24:04
t:\dx\nt\coredata.ram
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Fri, 28 Jul 2000 13:11:35 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Differences between two files?
Message-Id: <MPG.13eb88d56ffa8b6798ac05@nntp.hpl.hp.com>
[Removed alt.perl.]
In article <3981DAF9.33B33665@strobedata.com> on Fri, 28 Jul 2000
12:11:53 -0700, Jim Cook <jcook@strobedata.com> says...
> I have two files, read into $a and $b that I test for equality with $a
> eq $b. However, because of the nature of the files, a few differences
> are OK. What I'm interested in is how many different bytes there are
> within $a and $b (assuming same length here).
>
> Is there an easy way that doesn't involve something horrid like "foreach
> (split(//, $a))"?
>
> (I have looked for a "diff" program, but that seems like it might be
> overkill for this project. If two files are different sizes, that's an
> entirely different category than a file that stayed the same size but
> had minor differences inside.)
This has been discussed here recently. The number of differing bytes is
given by:
my $count = (my $x = $a ^ $b) =~ tr/\0//c;
The intermediate variable is needed because of a perl bug.
BTW, $a and $b aren't good names for variables, because of their special
association with the sort() function.
> My real problem is that I have two directories of release software
> (different versions). The software is serial number stamped to make a
> matched set. Some files are stamped and some are not.
I don't understand what follows, or understand why that is your 'real
problem'. Is the above your fake problem?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 28 Jul 2000 13:40:35 -0700
From: Jim Cook <jcook@strobedata.com>
Subject: Re: Differences between two files?
Message-Id: <3981EFC3.52C6B676@strobedata.com>
> This has been discussed here recently. The number of differing bytes is
> given by:
>
> my $count = (my $x = $a ^ $b) =~ tr/\0//c;
Thank you very much. As it turns out, I'm not actually using $a and $b,
but I admit they are bad choices for the example. Next time I'll use
$foo, $bar.
> > My real problem is that I have two directories of release software
> > (different versions). The software is serial number stamped to make a
> > matched set. Some files are stamped and some are not.
>
> I don't understand what follows, or understand why that is your 'real
> problem'. Is the above your fake problem?
I have a job to solve. I need to produce a report of how the files in
two directories compare. That's the task at hand. I have a script that
does everything except saying how many different bytes there are in two
files.
I thought that somebody might have a better idea of how to accomplish
what I was trying to do than to compare two $foo and $bar for
differences. Otherwise, I could use the solution (that you so kindly
provided) so solve my big picture problem.
I work in tech support and often find a customer asking "how do I do
this," which I can answer, but in fact if I find out what they are
really trying to solve I can provide a better solution than giving them
what they were asking for.
I bet there was a better way to say it in the first place.
--
jcook@strobedata.com Live Honourably 4/1 - 4/3 + 4/5 - 4/7 + . . .
2000 Tuesdays: Feb/last 4/4 6/6 8/8/ 10/10 12/12 9/5 5/9 7/11 11/7 3/14
Strobe Data Inc. home page http://www.strobedata.com
My home page O- http://jcook.net
------------------------------
Date: Fri, 28 Jul 2000 19:43:24 +0000
From: Mike <mike@cyborg-group.com>
Subject: Disconnecting from NT server
Message-Id: <964809826.14187.0.nnrp-02.9e986064@news.demon.co.uk>
Currently I connect to my NT server using this simple script
#! /bin/bash
smbmount "//FTEX/Data" "/net/data" -W "dommain" -U "mike%password" -I
192.168.10.1 smbmount "//FTEX/Delta5" "/net/delta" -W "dommain" -U
"mike%password" -I 192.168.10.1 smbmount "//FTEX/Apps" "/net/apps" -W
"dommain" -U "mike%password" -I 192.168.10.1 smbmount "//PSIONSQL"
"/net/sqls" -W "dommain" -U "mike%password" -I 192.168.10.1
It connects fine but then after a while it disconnects and the only way to
reconnect is to reboot.
Also where is the smb.conf file for 2.0.5a
There is one in/etc and in /usr/lib
Both are nearly all coimmented out and bear no resemblance to my setup
------------------------------
Date: Fri, 28 Jul 2000 18:43:01 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Disconnecting from NT server
Message-Id: <slrn8o3lbr.bru.marcel@gandalf.local>
On Fri, 28 Jul 2000 19:43:24 +0000, Mike <mike@cyborg-group.com> wrote:
>Currently I connect to my NT server using this simple script
[blah]
>Both are nearly all coimmented out and bear no resemblance to my setup
They also bear no resemblance to the topic of this newsgroup.
Neither do your 'test' posts.
Bye bye, Mike
--
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Fri, 28 Jul 2000 19:53:45 +0000
From: Mike <mike@cyborg-group.com>
Subject: Re: Disconnecting from NT server
Message-Id: <964810433.14324.0.nnrp-02.9e986064@news.demon.co.uk>
Sorry I was trying to post to samba and it went to the wrong one
In article <slrn8o3lbr.bru.marcel@gandalf.local>, marcel@codewerk.com
(Marcel Grunauer) wrote:
> On Fri, 28 Jul 2000 19:43:24 +0000, Mike <mike@cyborg-group.com> wrote:
>
>>Currently I connect to my NT server using this simple script
>
> [blah]
>
>>Both are nearly all coimmented out and bear no resemblance to my setup
>
> They also bear no resemblance to the topic of this newsgroup.
>
> Neither do your 'test' posts.
>
> Bye bye, Mike
>
------------------------------
Date: Fri, 28 Jul 2000 11:55:04 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Disconnecting from NT server
Message-Id: <8lsksd$sbt$1@brokaw.wa.com>
Mike <mike@cyborg-group.com> wrote in message
news:964809826.14187.0.nnrp-02.9e986064@news.demon.co.uk...
> Currently I connect to my NT server using this simple script
>
> #! /bin/bash
> smbmount "file://FTEX/Data" "/net/data" -W "dommain" -U "mike%password" -I
> 192.168.10.1 smbmount "file://FTEX/Delta5" "/net/delta" -W "dommain" -U
> "mike%password" -I 192.168.10.1 smbmount "file://FTEX/Apps"
"/net/apps" -W
> "dommain" -U "mike%password" -I 192.168.10.1 smbmount "file://PSIONSQL"
> "/net/sqls" -W "dommain" -U "mike%password" -I 192.168.10.1
>
> It connects fine but then after a while it disconnects and the only way to
> reconnect is to reboot.
>
> Also where is the smb.conf file for 2.0.5a
>
> There is one in/etc and in /usr/lib
>
> Both are nearly all coimmented out and bear no resemblance to my setup
bash, NT, smb.conf...
What's the question? Try to relate your question to anything having to do
with Perl.
Lauren
------------------------------
Date: Fri, 28 Jul 2000 19:14:55 GMT
From: "Daniel van den Oord" <danielxx@bart.nl>
Subject: Re: file extension
Message-Id: <PYkg5.5088$Gd1.41290@Typhoon.bART.nl>
Is there a way to prevent people to use .\..\.\..\ or something like that
????
|
| On Mon, 24 Jul 2000, Daniel van den Oord wrote:
|
| > I made a simpel script to view a directory list with an index and
security
| > so it can't get out of that directory !!
| > http://195.38.226.149/cgi-bin/filer.pl
|
|
| http://195.38.226.149/cgi-bin/filer.pl?direct=.\..\.\..\
|
| !!
|
| Steve
| ---
|
------------------------------
Date: Fri, 28 Jul 2000 12:25:40 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Philip Taylor <phil.taylor@bigfoot.com>
Subject: Re: how to process all fields on a form
Message-Id: <3981DE34.5B909268@my-deja.com>
> I considered naming the textfields in an identifiable way but it's not
> ideal.
label all text fields starting with text_
then you can do
$page=new CGI ;
@names= $page->param ();
@names = grep { /^text_/ } @names;
Now use the parameter names in @names only
------------------------------
Date: Fri, 28 Jul 2000 12:10:03 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How to trim strings?
Message-Id: <MPG.13eb7a6ba3586b1498ac04@nntp.hpl.hp.com>
[The content of your post is OK, but you shouldn't post Jeopardy-style.
Rearranged for logical flow.]
In article <1qig5.527$fS5.113161@news.uswest.net> on Fri, 28 Jul 2000
10:17:27 -0600, Dan Manion <news@webneeds.com> says...
> "Alex Kneller" <akneller@gothambroadband.com> wrote in message
> news:8ls472$g73$1@nnrp1.deja.com...
> > I need to trim a string of the last quote. Please, help.
>
> This answer like most things can depend on what works best for your specific
> case. If you are positive that the last character of your string is
> unwanted then you can use chop.
>
> perldoc -f chop
>
> If you want to remove the last " regardless of where it is in the string
> something like this will work:
>
> $str =~ s/^(.*)"(.*)$/$1$2/;
Fails on embedded newlines. Use the /s modifier. Why bother with the
stuff after the double-quote at all?
Here is a more compact and efficient way (negative lookahead -- no
succeeding double-quotes):
$str =~ s/"(?!.*")//s;
> If you only want to remove a " if its the last character at the end of a
> line then something like this will work:
> $str =~ s/^(.*)"\s*$/$1/;
Too much heavy lifting.
$str =~ s/"\s*$//;
> You might also want to check out substr.
>
> perldoc -f substr
The fastest general solution uses rindex and substr.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
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 3835
**************************************