[19651] in Perl-Users-Digest
Perl-Users Digest, Issue: 1846 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 30 18:06:44 2001
Date: Sun, 30 Sep 2001 15:05:08 -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: <1001887508-v10-i1846@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 30 Sep 2001 Volume: 10 Number: 1846
Today's topics:
Cookies - dont work on win2000 clients after upgrades f (Tony)
Re: Cookies - dont work on win2000 clients after upgrad (Randal L. Schwartz)
Re: Cookies - dont work on win2000 clients after upgrad (Tony)
Re: current dir. <ivank@2xtreme.net>
Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work? (David Efflandt)
Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work? (Mark Jason Dominus)
Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work? (Bruno Boettcher)
Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work? (Bruno Boettcher)
Installing a Module in my own directory?? (E J)
Re: Making A Windows Program from Perl <novastar@novastar.dtdns.net>
Re: open EXPR, EXPR and strict 'refs' <bwalton@rochester.rr.com>
Re: open EXPR, EXPR and strict 'refs' <joe+usenet@sunstarsys.com>
Parsing problem <gortona@cs.man.ac.uk>
Re: Parsing problem (Mark Jason Dominus)
Re: Passing arguments to subs <mbudash@sonic.net>
Re: Passing arguments to subs (Randal L. Schwartz)
Re: Passing arguments to subs <darkon@one.net>
Re: Pattern Matching (shaz)
Re: Pattern Matching (F. Xavier Noria)
Re: Perl Inside Shell Script <bwalton@rochester.rr.com>
Perl semaphore IPC package real world stability (Dr. Laurence Leff)
Re: quick question <ivank@2xtreme.net>
Re: Sorting multidimensional arrays and MIN/MAX (Randal L. Schwartz)
Re: Sorting multidimensional arrays and MIN/MAX <bigusAT@btinternetDOT.com>
Re: Win/UNIX Perl CGI incompatibility (David Efflandt)
Re: Win/UNIX Perl CGI incompatibility <darkon@one.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Sep 2001 11:16:16 -0700
From: ts@relson.net (Tony)
Subject: Cookies - dont work on win2000 clients after upgrades from win98
Message-Id: <63073ce9.0109301016.6c2a6e66@posting.google.com>
Hi,
I wrote some login modules in perl which have woked fine with win98
clients. The web server is an rs6k , aix 4.3 and apache 1.3.9 with
perl 5.6.
my problem is that some of the clients have been upgraded to win200
and now the cookies dont work on them , the perl scripts work fine ,
but they dont save the cookies on the client. I have visted sites like
ibm and microsoft and their cookies work on the win2000 machines.
this is a test script i have been using to test this, and this works
fine with win98 clients but writes nothing to win2000 clients
#!/usr/local/bin/perl -w
use CGI qw(:standard); # load cgi libs
# SETTING A COOKIE
my $cookie = cookie( -name => 'login_ais',
-value => 'testuser,172.16.1.43,200109251543',
-expires => '+1h',
-path => "/",
-domain => '172.16.1.4' );
print header(-cookie=>$cookie) || die;
$login_ais = cookie('login_ais');
print "<h1> cookie = -$login_ais- </h1>";
Thanks
Tony
------------------------------
Date: 30 Sep 2001 11:47:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Cookies - dont work on win2000 clients after upgrades from win98
Message-Id: <m1r8soecsb.fsf@halfdome.holdit.com>
>>>>> "Tony" == Tony <ts@relson.net> writes:
Tony> my problem is that some of the clients have been upgraded to win200
Tony> and now the cookies dont work on them , the perl scripts work fine ,
Tony> but they dont save the cookies on the client. I have visted sites like
Tony> ibm and microsoft and their cookies work on the win2000 machines.
[...]
Tony> -domain => '172.16.1.4' );
There's nothing in the spec that permits cookies to IP addresses
rather than host names. If it worked before, it was a fluke. Get
a real domain name, update this value, and try again.
--
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: 30 Sep 2001 15:01:06 -0700
From: ts@relson.net (Tony)
Subject: Re: Cookies - dont work on win2000 clients after upgrades from win98
Message-Id: <63073ce9.0109301401.549622c5@posting.google.com>
merlyn@stonehenge.com (Randal L. Schwartz) wrote in message news:<m1r8soecsb.fsf@halfdome.holdit.com>...
> >>>>> "Tony" == Tony <ts@relson.net> writes:
>
> Tony> my problem is that some of the clients have been upgraded to win200
> Tony> and now the cookies dont work on them , the perl scripts work fine ,
> Tony> but they dont save the cookies on the client. I have visted sites like
> Tony> ibm and microsoft and their cookies work on the win2000 machines.
>
> [...]
>
> Tony> -domain => '172.16.1.4' );
>
> There's nothing in the spec that permits cookies to IP addresses
> rather than host names. If it worked before, it was a fluke. Get
> a real domain name, update this value, and try again.
I just tried that and it did'nt seem to have any effect, i have even
tried running it with out specifiying a domain or path, to let it try
to auto generate them still no good.
Tony
------------------------------
Date: Sun, 30 Sep 2001 12:56:53 -0700
From: Ivan <ivank@2xtreme.net>
Subject: Re: current dir.
Message-Id: <3BB77905.1080609@2xtreme.net>
Jeffrey Porter wrote:
>
> I'm trying to write a perl program to go through each directory and list
> the files in it & the path to that file.
>
> I've managed to write the code to list/change directories & list the
> files in them.
>
> What I can't work out is how to get the full path of the current
> directory I am in.
>
>
> Can some one please help.
>
> Thanks
> JP.
>
>
> -- it builds, quick ship it!
>
>
>
the command "pwd" gets the full current directory path. you can use it
with perl like this:
$currentdir=`pwd`; chomp $currentdir;
Ivan
------------------------------
Date: Sun, 30 Sep 2001 16:22:07 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work?
Message-Id: <slrn9rehle.q5p.efflandt@typhoon.xnet.com>
On Sun, 30 Sep 2001, Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
> hello, i am modifying a script, and have the following scema:
> $pattern = "stuff(\d+)";
> $pattern .= "|oth(\d+)";
> ... (a whole list...)
> and then i try:
Temporarily insert the following here to see error of your ways:
print $pattern,"\n";
> $line =~ /$pattern/;
> $num=$1;
>
> thinking naively that the submatch would be stored as usual in the $1-$N
> vars... but alas the var is empty... so where my error, and what would
> be the best to perform the above mentioned task? (its kinda speed
> critical, thus i didn't use a while loop and a stack for the pattern,
> feeled much slower..)
Whenever you have a problem, it helps to temporarily insert print
statements to see if variables are what you think they are.
For example your regex is trying to match /stuff(d+)|oth(d+)/ which comes
up empty. Hint, maybe you either want to use single quotes when assigning
$pattern, or if you need double quotes, escape the escapes.
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 30 Sep 2001 17:01:11 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work?
Message-Id: <3bb74fd7.4f6d$2d3@news.op.net>
In article <9p6rka$lp2$1@neon.noos.net>,
Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
>hello, i am modifying a script, and have the following scema:
>$pattern = "stuff(\d+)";
>$pattern .= "|oth(\d+)";
>... (a whole list...)
>and then i try:
>$line =~ /$pattern/;
>$num=$1;
If $line looks like "stuff42", the 42 will be in $1.
But if $line looks like "oth42", the 42 will be in $2.
If you use $num=$+ instead of $num = $1, it may do what you want here.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 30 Sep 2001 21:11:58 +0000 (UTC)
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work?
Message-Id: <9p81qu$gs6$1@quark.noos.net>
In article <slrn9rehle.q5p.efflandt@typhoon.xnet.com>,
David Efflandt <efflandt@xnet.com> wrote:
>On Sun, 30 Sep 2001, Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
>> hello, i am modifying a script, and have the following scema:
>> $pattern = 'stuff(\d+)';
>> $pattern .= '|oth(\d+)';
>> $line =~ /$pattern/;
>> $num=$1;
>Whenever you have a problem, it helps to temporarily insert print
>statements to see if variables are what you think they are.
ok, true, changed the double quotes to simple quotes, now the pattern
prints out correctly, but the thing still doesn't work.... there's
nothing in $1....
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Sun, 30 Sep 2001 21:42:47 +0000 (UTC)
From: bboett@bboett.dyndns.org (Bruno Boettcher)
Subject: Re: HELP: /stuff(\d+)|oth(\d+)/;$num=$1 doesn't work?
Message-Id: <9p83kn$13n$1@neon.noos.net>
In article <3bb74fd7.4f6d$2d3@news.op.net>,
Mark Jason Dominus <mjd@plover.com> wrote:
>In article <9p6rka$lp2$1@neon.noos.net>,
>Bruno Boettcher <bboett@bboett.dyndns.org> wrote:
>>hello, i am modifying a script, and have the following scema:
>>$pattern = "stuff(\d+)";
>>$pattern .= "|oth(\d+)";
>>... (a whole list...)
>>and then i try:
>>$line =~ /$pattern/;
>>$num=$1;
>
>If $line looks like "stuff42", the 42 will be in $1.
>But if $line looks like "oth42", the 42 will be in $2.
argh??? but why?
>If you use $num=$+ instead of $num = $1, it may do what you want here.
ok.... but if i want to fetch several submatches? i changed the script
to the follwoing:
#!/usr/bin/perl -w
$line="stuff24.24";
#$line="oth25.25";
$pattern = 'stuff(\d+)\.(\d+)';
$pattern .= '|oth(\d+)\.(\d+)';
$line =~ /$pattern/;
$num=$1;
$frac=$2;
$num2 = $+;
print "pattern was:'$pattern'\n";
print "result is:'$num.$frac' and '$num2'\n";
./reg.pl
pattern was:'stuff(\d+)\.(\d+)|oth(\d+)\.(\d+)'
result is:'24.24' and '24'
in the first case and:
./reg.pl
pattern was:'stuff(\d+)\.(\d+)|oth(\d+)\.(\d+)'
Use of uninitialized value in concatenation (.) or string at ./reg.pl line 11.
Use of uninitialized value in concatenation (.) or string at ./reg.pl line 11.
result is:'.' and '25'
for the second.....
clearly not exactly what i need :D i didn't found an other access to those
submatches, $+ seeming to access only the very latest one....
--
ciao bboett
==============================================================
bboett@earthling.net
http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
------------------------------
Date: Sun, 30 Sep 2001 13:48:18 -0400 (EDT)
From: itsej@hotmail.com (E J)
Subject: Installing a Module in my own directory??
Message-Id: <22778-3BB75AE2-29@storefull-613.iap.bryant.webtv.net>
i tried to install -
SimpleLinkChecker
now - how can i tell if i installed it or if t was installed -
i unpacked it -
typed: Makefile.PL in the new directory
and got a response - everything looks OK
==
in the new directory
There already existed a - Makefile.PL there as well as
SimpleLinkChecker.pm
==
then i typed
make, then make install, and got this:
make: no system rules (sys.mk).
was it installed correctly?
How can check if it is installed, And Correctly?
now how do i call it?
use SimpleLinkChecker;
or do i specify the path to it ? No its not in then root directory - i
put it i my own directory.
need info,
Thanks
EJ
------------------------------
Date: Sun, 30 Sep 2001 21:11:52 +0200
From: "novastar" <novastar@novastar.dtdns.net>
Subject: Re: Making A Windows Program from Perl
Message-Id: <9p7n93$98g$1@usenet.otenet.gr>
Sorry Larry but perl is very weak at gui interfaces and very poor on 2d
graphics. Better not talk about 3d graphics !
"larry steinbeck" <larrysteinbeck@webtv.net> wrote in message
news:1158-3BB4CB05-230@storefull-243.iap.bryant.webtv.net...
> Status quo, Perl is the only programming language that I know. Is it
> possible to write a marketable game or business application for Windows
> 98 in Perl (like the packaged PC programs you see for sale at computer
> stores such as Media Play)?
>
> Is it worth learning C++ in order to write a marketable Windows program?
> Or, is it almost as good to write the application in Perl, and convert
> it to an .exe file?
>
> If so, what is the best way, or best perl module to use to accomplish
> this? perl2exe? xs? inline C?
>
> Best to all!
> Lar
>
>
------------------------------
Date: Sun, 30 Sep 2001 20:25:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: open EXPR, EXPR and strict 'refs'
Message-Id: <3BB77E2E.5C3A5FDE@rochester.rr.com>
Joe Schaefer wrote:
>
> % perldoc -f open
> open FILEHANDLE,MODE,LIST
> open FILEHANDLE,EXPR
> open FILEHANDLE
> Opens the file whose filename is given by EXPR,
> and associates it with FILEHANDLE. If FILEHANDLE
> is an expression, its value is used as the name of
> the real filehandle wanted. (This is considered a
> symbolic reference, so "use strict 'refs'" should
> not be in effect.)
> ...
>
> The parenthetical remark looks flat-out wrong to me
> wrt strictures and symrefs:
>
> % perl -Mstrict -wle 'open "mydata", ">&STDOUT"; print mydata "foo"'
> Unquoted string "mydata" may clash with future reserved word at -e line 1.
> foo
> % perl -Mstrict -wle 'open "x", ">&STDOUT"; print x "foo"'
> Unquoted string "x" may clash with future reserved word at -e line 1.
> foo
> % perl -Mstrict -wle 'open "if", ">&STDOUT"; print if "foo"'
> Name "main::if" used only once: possible typo at -e line 1.
> Use of uninitialized value in print at -e line 1.
>
> Perhaps the parenthetical should read something like:
>
> ... (Although not enforced by
> "use strict 'refs'", this value is considered a
> symbolic reference- see the perlreftut and perlref
> manpages for details.)
>
> Joe Schaefer
...
A couple of things:
1. The message you are getting is not coming from strict. It is coming
from -w, as can be verified by removing the -w switch. The other clue
to this is that the program runs and prints foo anyway. If strict was
involved, it wouldn't have compiled. To avoid this warning, start your
filehandle with an uppercase letter, like MYDATA or even Mydata. Future
reserved words will not start with uppercase letters.
2. The message you are getting is not coming from the open, it is
coming from the print, as can be verified by putting your program in a
file with one line per statement and observing the statement number of
the error.
3. The expression "mydata" isn't counted as a symbolic reference by
strict, probably because the compiler simply evaluates it and
substitutes mydata for it transparently. The same will happen for
anything else the compiler can fully evaluate at compile time, like
"myd"."ata", for example.
The following will cause strict to jump into action:
use strict;
my $mydata='mydata';
open $mydata,">&STDOUT" or die "Oops, $!";
print $mydata "foo";
So, in my opinion, both the documentation and what Perl does is fine.
--
Bob Walton
------------------------------
Date: 30 Sep 2001 17:36:47 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: open EXPR, EXPR and strict 'refs'
Message-Id: <m3y9mwmkcw.fsf@mumonkan.sunstarsys.com>
Bob Walton <bwalton@rochester.rr.com> writes:
[...]
> 3. The expression "mydata" isn't counted as a symbolic reference by
> strict, probably because the compiler simply evaluates it and
> substitutes mydata for it transparently. The same will happen for
> anything else the compiler can fully evaluate at compile time, like
> "myd"."ata", for example.
[...]
> So, in my opinion, both the documentation and what Perl does is fine.
Interesting- thanks for the fine explanation.
--
Joe Schaefer And today the great Yertle, that Marvelous he, Is King of the
Mud. That is all he can see.
-- Dr. Seuss
------------------------------
Date: Sun, 30 Sep 2001 20:23:27 +0100
From: Andrew Paul Gorton <gortona@cs.man.ac.uk>
Subject: Parsing problem
Message-Id: <3BB7712F.2A9ED28B@cs.man.ac.uk>
Hi everyone,
quick question
I need to parse the output of the top command, which is stored in a
file. How do I get the %CPU and %MEM values. I can get the line
starting 11869, but not parse it for the values.
PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME
COMMAND
11869 gortona 13 0 968 968 740 R 0 5.6 1.4 0:00 top
Any help much appreciated
------------------------------
Date: Sun, 30 Sep 2001 19:32:32 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Parsing problem
Message-Id: <3bb7734e.438$1b0@news.op.net>
In article <3BB7712F.2A9ED28B@cs.man.ac.uk>,
Andrew Paul Gorton <gortona@cs.man.ac.uk> wrote:
>How do I get the %CPU and %MEM values. I can get the line
>starting 11869, but not parse it for the values.
>
> PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME
>COMMAND
>11869 gortona 13 0 968 968 740 R 0 5.6 1.4 0:00 top
my @values = split /\s+/, $LINE;
my ($cpu, $mem) = @values[9,10];
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 30 Sep 2001 15:48:01 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Passing arguments to subs
Message-Id: <mbudash-0A860A.08480530092001@news.sonic.net>
In article <ziGt7.2968$qi.455117@news2-win.server.ntlworld.com>, "Scott
Bell" <scott.bell1@ntlworld.com> wrote:
> I'm making a webpage in cgi, it's devided into sections. To go to the
> pictures section you could follow a link to ?content=pictures, if you
> wanted
> to go to the help section you would follow a link to ?content=help, this
> works fine but I want to put all the code that outputs html code in a
> seperate procedure, but how do I tell this procedure what page to
> display, I
> can't make it figure out from $query->param(content) because I might want
> to
> jump to a page they havn't linked to. I know I could do something like
>
> $content = "pictures";
> &showpage;
>
> then depend on the $content variable, but is this the correct way to do
> it?
> could I do something like
>
> &showpage "pictures";
>
one way:
showpage('pictures');
then in the subroutine:
sub showpage {
my $content = shift;
# the rest of the subroutine...
if you're using CGI.pm (if not, why not??), then you could use this:
showpage(param('content'));
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 30 Sep 2001 08:54:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Passing arguments to subs
Message-Id: <m166a0fzcs.fsf@halfdome.holdit.com>
>>>>> "Michael" == Michael Budash <mbudash@sonic.net> writes:
Michael> sub showpage {
Michael> my $content = shift;
Michael> # the rest of the subroutine...
Michael> if you're using CGI.pm (if not, why not??), then you could use this:
Michael> showpage(param('content'));
Be careful when you do that. param('content') in a list context
returns zero or more items. In this case, you'd get undef for $content
if there were none, but only the first item if there were two. No biggy
in this case, but imagine this:
showpage( param('content'), 'red' ); # passing 'red' as second item
The second item will sometimes be the first item, and sometimes
the third (or 27th!).
You want
showpage( scalar param('content'), 'red' );
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: Sun, 30 Sep 2001 20:38:55 -0000
From: "David K. Wall" <darkon@one.net>
Subject: Re: Passing arguments to subs
Message-Id: <Xns912CA98FD8C2Edarkononenet@207.126.101.100>
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>>>>>> "Michael" == Michael Budash <mbudash@sonic.net> writes:
>
> Michael> sub showpage {
> Michael> my $content = shift;
> Michael> # the rest of the subroutine...
>
> Michael> if you're using CGI.pm (if not, why not??), then you could use
> this:
>
> Michael> showpage(param('content'));
>
> Be careful when you do that. param('content') in a list context
> returns zero or more items. In this case, you'd get undef for $content
> if there were none, but only the first item if there were two. No
> biggy in this case, but imagine this:
>
> showpage( param('content'), 'red' ); # passing 'red' as second item
>
> The second item will sometimes be the first item, and sometimes
> the third (or 27th!).
>
> You want
>
> showpage( scalar param('content'), 'red' );
Isn't a standard way to do this is to use a dispatch table, using a hash
where the keys are what you expect the browser to send, and the values are
subroutine references? (Uri Guttman recommended this to someone a few days
ago, IIRC)
For example:
use strict;
use warnings;
use CGI qw(param header start_html end_html h1 p);
my %dispatch = (
dothis => \&dothis,
dothat => \&dothat,
);
my $action = param('action');
if ( defined $dispatch{$action} ) {
&{ $dispatch{$action} }(); # maybe other params here?
}
else {
print header, start_html, h1("Error"),
p("This action is not supported"),
end_html;
}
# subroutine definitions...
This way, the program should work as expected when it gets proper input,
and if someone is trying to break it all they'll get is an error message.
Am I misunderstanding you, or am I just going at it differently than the
OP? (I'm just curious about different techniques, being what I consider an
apprentice programmer, or at most a very junior journeyman. I think I
presently fit somewhere on the low end of Intermediate on TC's scale of
Perl classes.)
--
David Wall - darkon@one.net - http://www.cincinnatiskeptics.org/
"There was nothing good about the Challenger disaster, but it did happen on
the day that L. Ron Hubbard died and it blew that useless, evil, rat
bastard's obituary off the front page, and that, at least, wasn't bad."
-- Penn and Teller
------------------------------
Date: 30 Sep 2001 11:48:37 -0700
From: ssa1701@yahoo.co.uk (shaz)
Subject: Re: Pattern Matching
Message-Id: <23e71812.0109301048.2c1f7193@posting.google.com>
Thanks, for the help.
I also want to be able to display the longer string. The solution that
you have provided returns a value (0 or 1).
$small = 'foo';
$y_or_n = grep { index($_, $small) != -1 } keys %strings;
This will try to find the small string within a longer string.
I want to be able to display both the small string and the longer
string.
The small string is easy (ie $small) but how could I display the
longer string?
------------------------------
Date: 30 Sep 2001 19:59:42 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: Pattern Matching
Message-Id: <9p7tje$4tf843@news1s.iddeo2.es>
On 30 Sep 2001 11:48:37 -0700, shaz <ssa1701@yahoo.co.uk> wrote:
: I also want to be able to display the longer string. The solution that
: you have provided returns a value (0 or 1).
Actually counts how many keys in %strings contain the substring
$small, so the returned value may be greater than 1.
: $small = 'foo';
: $y_or_n = grep { index($_, $small) != -1 } keys %strings;
:
: This will try to find the small string within a longer string.
:
: I want to be able to display both the small string and the longer
: string.
: The small string is easy (ie $small) but how could I display the
: longer string?
In that case I'd use an explicit loop:
$small = 'FindMe';
$longer = undef;
foreach my $key (keys %strings) {
$longer = $key, last if index($key, $small) != -1;
}
print "$longer contains $small.\n" if defined $longer;
Note that if $small was found $longer would hold the first key that
contained it according to the order in which keys are given by keys().
-- fxn
------------------------------
Date: Sun, 30 Sep 2001 21:16:46 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl Inside Shell Script
Message-Id: <3BB78A1B.5B4F77A3@rochester.rr.com>
"Jürgen Exner" wrote:
>
...
> $env{ARGS}="job=mike analysis cpus=123"; #normally set outside of the script
>
> if ($env{ARGS} =~/cpus=(\d+)/) {
> print "The number of cpus is 'cpus=$1'";
> } else {
> print "There is no 'cpus=' in \$ARGS\n";
> }
That should be $ENV{ARGS}.
--
Bob Walton
------------------------------
Date: 30 Sep 2001 13:23:57 -0500
From: mflll@wiu.edu (Dr. Laurence Leff)
Subject: Perl semaphore IPC package real world stability
Message-Id: <9p7nvt$jmg$1@ecom1.wiu.edu>
Now, our department teaches UNIX including such features as semaphores,
sockets, and shared memory using the C language.
There is a suggestion to teach semaphores, sockets, binary file manipulation,
etc. using the Perl packages. We already teach Perl in our Unix class.
This would allow us to make the UNIX programming material accessible to
those who have not taken our courses on C programming.
My question for this group is whether this Perl functionality is real-world
stable. Is anyone using Perl instead of C programming in the "real world"
that involves these kinds of tasks.
Dr. Laurence Leff Western Illinois University, Macomb IL 61455 ||(309) 298-1315
Stipes 447 Assoc. Prof. of Computer Sci.
Pagers: 309-367-0787 OR 800-512 0787 (Illinois only)OR 800 946 4646 PIN 1488110
Co-moderator alt.binaries.pictures.fine-art hierarchy || FAX: 309-298-2302
------------------------------
Date: Sun, 30 Sep 2001 12:54:26 -0700
From: Ivan <ivank@2xtreme.net>
Subject: Re: quick question
Message-Id: <3BB77872.9000705@2xtreme.net>
NEWS wrote:
> im very new to perl and programming.
>
> i want to enter a number using standard input, assign that to a scalar and
> then another figure entered by standard input and multiply the scalars
> together,
>
> my script goes something like
>
> print "type a number?\t";
> $a = <STDIN>;
> chomp $a;
>
> print "type another number\t";
> $b = <STDIN>;
> chomp $b;
>
>
> $a*$b = $c;
>
> print $c;
>
>
> BUT it wont work, why ???
>
>
>
instead of:
$a*$b = $c;
use:
$c = $a * $b;
you always have to define the variable you want to modify first.
------------------------------
Date: 30 Sep 2001 08:24:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Sorting multidimensional arrays and MIN/MAX
Message-Id: <m1hetkg0ru.fsf@halfdome.holdit.com>
>>>>> "S" == S Warhurst <bigusAT@btinternetDOT.com> writes:
>> @array = sort { $a->[1] <=> $b->[1] } @array;
>> # ^ ^
>> # second element!
S> That works very nicely :) I wish I understood HOW it works, but I guess one
S> can't have everything ;-)
We could help, but we need to know what piece you are missing.
Do you know what @list = sort { $a <=> $b } @numbers does?
Do you know what $a->[1] does if $a is an arrayref?
--
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: Sun, 30 Sep 2001 22:01:17 +0100
From: "S Warhurst" <bigusAT@btinternetDOT.com>
Subject: Re: Sorting multidimensional arrays and MIN/MAX
Message-Id: <9p814a$90v$1@uranium.btinternet.com>
Well to be honest, the first thing I don't understand is about multi-d
arrays themselves.. specifically, why one uses a $ instead of a @.. eg:
$array[x][y] instead of @array[x][y]. It would just seem simpler to stick
to the @.
With regard to that useful sorting line:
@array = sort { $a->[1] <=> $b->[1] } @array;
I don't understand why the sort uses curly brackets instead of rounded ones
like it does if you just sort a standard 1D array. What do the -> symbols
do?.. I've seen and used them when parsing form data with cgi.pm but don't
actually know what they do.. the term "deref" seems to get used but not sure
what that means.
In the Rex Swain concise ref guide the <=> is a numerical compare, and I
remember reading somewhere that $a & $b have a special meanings in this
context, but that's as far as it goes, and I also don't know what bit of the
above line tells Perl to sort the items in ascending fashion (perhaps that's
just a default?) and to keep the other column in the multi-d array in sync
(again, I guess that's the default when dealing with a multi-d array).. is
"multidimensional" the correct term to use for these types of array?
So basically it's pretty much everything I don't understand about that ;)
Thanks
¦ ¦--¦
¦--¦- Bigus -¦--¦
¦--¦
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1hetkg0ru.fsf@halfdome.holdit.com...
> >>>>> "S" == S Warhurst <bigusAT@btinternetDOT.com> writes:
>
> >> @array = sort { $a->[1] <=> $b->[1] } @array;
> >> # ^ ^
> >> # second element!
>
> S> That works very nicely :) I wish I understood HOW it works, but I
guess one
> S> can't have everything ;-)
>
> We could help, but we need to know what piece you are missing.
> Do you know what @list = sort { $a <=> $b } @numbers does?
> Do you know what $a->[1] does if $a is an arrayref?
>
> --
> 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: Sun, 30 Sep 2001 17:11:14 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Win/UNIX Perl CGI incompatibility
Message-Id: <slrn9rekhh.q5p.efflandt@typhoon.xnet.com>
On Sun, 30 Sep 2001, Philip Taylor <philip@zaynar.demon.co.uk> wrote:
> I'm writing some Perl CGI programs to run on a Linux Apache web server,
> but am testing them offline with OmniHTTPD on Windows (and ActivePerl
> 5.6.1 build 628). The problem is that scripts such as
> #!/usr/bin/perl -wT
> use strict;
> exit;
> work fine on Linux, but on Windows perl complains "Too late for "-T"
> option at something.cgi line 1."
>
> This also happens when I run the script directly from the command line
> ("perl something.cgi"), although it works if I specify -T when running
> perl ("perl -T something.cgi").
Often it is easiest to develop on a system similar to what you are
developing for. I got too fed long ago trying to write Perl scripts in
Windows for my Solaris ISP (different paths, unavailable features and
permissions, etc.). So I have been running Linux on my PC since 1995.
Linux comes with Perl, apache, samba (Win file & printer sharing) and a
boot loader that can multi-boot Win and Linux and whatever. You can set
the same paths and permission you would use on your webhost (even symlink
perl to a different path if needed) so you don't have to change anything
when uploading to a live site.
There is a program (name escapes me) that can run both simultaniously on
virtual machines if you have the resources (speed and RAM). But if I need
Windows, I just boot my networked laptop and control it from Linux using a
free program called VNC.
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Sun, 30 Sep 2001 21:08:05 -0000
From: "David K. Wall" <darkon@one.net>
Subject: Re: Win/UNIX Perl CGI incompatibility
Message-Id: <Xns912CAE814EA04darkononenet@207.126.101.100>
Philip Taylor <philip@zaynar.demon.co.uk> wrote:
> I'm writing some Perl CGI programs to run on a Linux Apache web server,
> but am testing them offline with OmniHTTPD on Windows (and ActivePerl
> 5.6.1 build 628). The problem is that scripts such as
> #!/usr/bin/perl -wT
> use strict;
> exit;
> work fine on Linux, but on Windows perl complains "Too late for "-T"
> option at something.cgi line 1."
>
> This also happens when I run the script directly from the command line
> ("perl something.cgi"), although it works if I specify -T when running
> perl ("perl -T something.cgi").
>
> The web server which I'm using (and which I chose based on the fact that
> I didn't care about features and it was fairly small) isn't able to run
> perl with the necessary extra options, so I've had to create a .bat file
> which executes perl with the correct parameters. But I was wondering if
> there's any way to make perl ignore the #! line, yet still allow it to
> work fine on Linux -- or should I just get a different Windows web
> server?
You could use Apache for win32 for development. Unless I'm mistaken, you
can use the shebang line with it, including -T, and it will work correctly
-- although you'll have the change the path to perl (perl.exe on win32)
before you upload the programs. (The shebang line under win32 will look
something like '#!c:\Perl\bin\perl.exe -Tw') Apache is more complex to
configure than Omnihttpd (I've used both), but it's much nicer, too, IMO.
If you have the space for a Linux partition on your hard drive, or an extra
machine, it might be easier to install Linux and develop your CGI scripts
natively.
But this has little or nothing to do with Perl. :-)
--
David Wall - darkon@one.net
"A real operating system doesn't stop its users from doing stupid things,
because that would also prevent them from doing clever things."
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1846
***************************************