[17672] in Perl-Users-Digest
Perl-Users Digest, Issue: 5092 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 12 18:06:26 2000
Date: Tue, 12 Dec 2000 15:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976662318-v9-i5092@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Dec 2000 Volume: 9 Number: 5092
Today's topics:
404 - Location Header spcman@my-deja.com
Re: 404 - Location Header <jeff@vpservices.com>
=~ operator <mcs2@pitt.edu>
Re: =~ operator <mothra@nowhereatall.com>
Re: =~ operator guthrie_linck@my-deja.com
Re: =~ operator <uri@sysarch.com>
Re: =~ operator <mjcarman@home.com>
Re: Algorithms and PERL <jschauma@netmeister.org>
Re: Algorithms and PERL <joe+usenet@sunstarsys.com>
Re: Algorithms and PERL (Abigail)
Re: Algorithms and PERL <russ_jones@rac.ray.com>
Attempt to free unreferenced scalar? <eric.kort@vai.org>
Better way to remove lines from output? Odd_Carnivals@yahoo.com
Re: Better way to remove lines from output? guthrie_linck@my-deja.com
DBI prepare method <mcdonabNO@SPAMyahoo.com>
Re: DBI prepare method <jeff@vpservices.com>
Re: DBI prepare method <mcdonabNO@SPAMyahoo.com>
FTP.pm (J. K.)
Re: FTP.pm <mothra@nowhereatall.com>
Re: how do i kill a process created like this in win98 (Tad McClellan)
Re: huh ?? <mischief@velma.motion.net>
Re: huh ?? (Tad McClellan)
Re: huh ?? guthrie_linck@my-deja.com
implicit creation of array? <brianr72@my-deja.com>
Re: local functions <mjcarman@home.com>
Re: local functions <uri@sysarch.com>
Looking for GREP examples <azby10@hotmail.com>
Re: Need help to replace passwd - New at this ! (Alan Barclay)
Re: need help with split <iltzu@sci.invalid>
Re: need help with split <jeffp@crusoe.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Dec 2000 21:17:48 GMT
From: spcman@my-deja.com
Subject: 404 - Location Header
Message-Id: <9164ll$3p5$1@nnrp1.deja.com>
Hello. Ill cut this down and make it simple in hope of getting an
answer...
Quick overview of whats going on on my server....
- All 404 Errors are passed to "error.cgi" from the .htaccess file
- .htaccess consists of "ErrorDocument 404 /cgi-bin/error.cgi"
- Error.cgi is now executed when a document is not found
Now... if i add this to error.cgi...
#####################################
#!/usr/local/bin/perl
print "Content-Type: text/html\n\n";
print "ERROR. PAGE NOT FOUND!";
#####################################
Any unretrievable document returns "ERROR. PAGE NOT FOUND!"
The above code is tested and works...
Now... if i add this to error.cgi...
################################################
#!/usr/local/bin/perl
print "location:http://www.someaddress.com\n\n";
################################################
I am expecting the browser to read the location header and go on to the
http://www.someadress.com, but it does not work.
Im thinking its because along with the location headers, its also
returning a 404 error.
Now my question:
Is their any way i can change it so the webserver outputs a (200??)
header so the browser reads the location header?
This might be a browser specific problem (im using MSIE 5.0)
Thanks for any and all responses! This forum is full of very wonderful
people. Al
http://www.rateadate.com
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 13:43:36 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: 404 - Location Header
Message-Id: <3A369C08.B0916F63@vpservices.com>
spcman@my-deja.com wrote:
>
> ... if i add this to error.cgi...
> ################################################
> #!/usr/local/bin/perl
> print "location:http://www.someaddress.com\n\n";
> ################################################
> I am expecting the browser to read the location header and go on to the
> http://www.someadress.com, but it does not work.
>
> Im thinking its because along with the location headers, its also
> returning a 404 error.
>
> Now my question:
> Is their any way i can change it so the webserver outputs a (200??)
> header so the browser reads the location header?
This code:
-- start of script--
#!/usr/local/bin/perl -w
use CGI qw(:standard);
print redirect("http://foo.edu/");
-- end of script --
Produces this:
-- start of output --
Status: 302 Moved
location: http://foo.edu/
-- end of output --
Get the idea?
--
Jeff
------------------------------
Date: Tue, 12 Dec 2000 15:19:18 -0500
From: Martin Schmidt <mcs2@pitt.edu>
Subject: =~ operator
Message-Id: <3A368845.4C0395F4@pitt.edu>
Newbie question...
What is the =~ operator called?
I'm reading 'Learning Perl' and they just call it the
=~ operator.
Thanks,
martin
mcs2@pitt.edu
------------------------------
Date: Tue, 12 Dec 2000 12:31:57 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: =~ operator
Message-Id: <3A368B3D.F52BBBD2@nowhereatall.com>
Martin Schmidt wrote:
> Newbie question...
> What is the =~ operator called?
> I'm reading 'Learning Perl' and they just call it the
> =~ operator.
>
> Thanks,
> martin
> mcs2@pitt.edu
selecting other than with =~ operator
------------------------------
Date: Tue, 12 Dec 2000 21:21:04 GMT
From: guthrie_linck@my-deja.com
Subject: Re: =~ operator
Message-Id: <9164rp$3u4$1@nnrp1.deja.com>
it is the pattern match operator.
In article <3A368B3D.F52BBBD2@nowhereatall.com>,
mothra <mothra@nowhereatall.com> wrote:
>
>
> Martin Schmidt wrote:
>
> > Newbie question...
> > What is the =~ operator called?
> > I'm reading 'Learning Perl' and they just call it the
> > =~ operator.
> >
> > Thanks,
> > martin
> > mcs2@pitt.edu
>
> selecting other than with =~ operator
>
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 21:41:20 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: =~ operator
Message-Id: <x78zpljp1b.fsf@home.sysarch.com>
>>>>> "gl" == guthrie linck <guthrie_linck@my-deja.com> writes:
gl> it is the pattern match operator.
more the bind operator. it works with m//, s/// AND tr/// and the latter
is not a pattern and s/// is not only a pattern as it also has a
replacement part.
so =~ binds the expression on the left (in place of the default $_) to
the operation on the right.
note, that this is not to be confused with the bind function which is
used with sockets.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 12 Dec 2000 15:38:50 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: =~ operator
Message-Id: <3A369AEA.99724BB3@home.com>
Martin Schmidt wrote:
>
> What is the =~ operator called?
> I'm reading 'Learning Perl' and they just call it the
> =~ operator.
I generally refer to it as the 'binding' operator, as it binds an
variable to a regexp.
-mjc
------------------------------
Date: Tue, 12 Dec 2000 19:36:45 GMT
From: "Jan Schaumann" <jschauma@netmeister.org>
Subject: Re: Algorithms and PERL
Message-Id: <h7vZ5.77113$IP1.2572684@news1.giganews.com>
* aldenave@hotmail.com wrote:
> I'm currently taking an algorithims class at school, and my prof.
> assigned us this problem;
>
> Has anyone developed a new algorithm that can solve the traveling
> salesman problem in polynomial time, using Perl or another command line
> programming language.
What the heck is a "command line programming language"?
Well, if you have the algorithm working, you can post code and we can
help you implement it ;-)
Otherwise, you should better investigate the problem itself and see if
you can come up with an algorithm in pseudo-code. You could investigate
in comp.programming or on the web.
Maybe you wanna start at http://www.keck.caam.rice.edu/tsp/
-Jan
--
Jan Schaumann <http://www.netmeister.org>
"Don't take this the wrong way, Fry, but you don't seem like the educated
type." -Leela
------------------------------
Date: 12 Dec 2000 14:48:45 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Algorithms and PERL
Message-Id: <m37l55fmjm.fsf@mumonkan.sunstarsys.com>
aldenave@hotmail.com writes:
> I'm currently taking an algorithims class at school, and my prof.
> assigned us this problem;
>
> Has anyone developed a new algorithm that can solve
> the traveling salesman problem in polynomial time,
> using Perl or another command line programming language.
>
> Does anyone have any suggestions on code or where to find more data on
> the subject.
>
Try google( quantum computer NP ). I believe perl6 will be
ported to one developed by NSA, in which case you'd be all
set :)
--
Joe Schaefer
------------------------------
Date: 12 Dec 2000 20:18:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Algorithms and PERL
Message-Id: <slrn93d1vv.6jj.abigail@tsathoggua.rlyeh.net>
aldenave@hotmail.com wrote:
++
++ I'm currently taking an algorithims class at school, and my prof.
++ assigned us this problem;
++
++ Has anyone developed a new algorithm that can solve the traveling
++ salesman problem in polynomial time, using Perl or another command line
++ programming language.
use Quantum::Superpositions;
Abigail
------------------------------
Date: Tue, 12 Dec 2000 15:44:27 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Algorithms and PERL
Message-Id: <3A369C3B.5CAB48D6@rac.ray.com>
aldenave@hotmail.com wrote:
>
> I'm currently taking an algorithims class at school, and my prof.
> assigned us this problem;
>
> Has anyone developed a new algorithm that can solve
> the traveling salesman problem in polynomial time,
> using Perl or another command line programming language.
>
Your prof is a mean sumbitch, huh? This is kind of like a math
professor telling you to prove Goldbach's Conjecture. Good luck.
--
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747
Quae narravi, nullo modo negabo. - Catullus
------------------------------
Date: Tue, 12 Dec 2000 15:05:27 -0500
From: "Eric" <eric.kort@vai.org>
Subject: Attempt to free unreferenced scalar?
Message-Id: <916203$2egb$1@msunews.cl.msu.edu>
I am experiencing some very strange (to me) behavior in my perl script
(which I can't reproduce in a snippet small enough to post here). My script
works fine, until I add the line:
filteredPixel = 0;
to my Inline::C XSUB, in an attempt to reset a previously incremented
counter. Then, the script still runs fine until the SECOND time the
subroutine is called. Then I get "Attempt to free unreferenced scalar at
tiff.pm line 331". The really weird part is that tiff.pm is a separate
module that is not even being called by the XSUB that causes the error.
Any ideas?
Eric
------------------------------
Date: Tue, 12 Dec 2000 20:55:39 GMT
From: Odd_Carnivals@yahoo.com
Subject: Better way to remove lines from output?
Message-Id: <9163c7$2e9$1@nnrp1.deja.com>
Hi Perl gurus,
Any suggestions for how the following could be improved?
What I'm doing is creating an output file that is identical
to the input file minus the second, third and last lines,
and with the linebreak removed from the next-to-last line
(i.e. the last line of the output file).
The following works, but I suspect there are better ways
to do it (I'm new to Perl).
$prev_line = <IN>; # Keep line 1.
while($. < 3) {<IN>}; # Skip lines 2 & 3.
while($line = <IN>) {
print OUT ($prev_prev_line);
$prev_prev_line = $prev_line;
$prev_line = $line;
}
$prev_prev_line =~ s/\n//; #remove linebreak
print OUT ($prev_prev_line);
Thanks!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 21:29:57 GMT
From: guthrie_linck@my-deja.com
Subject: Re: Better way to remove lines from output?
Message-Id: <9165cc$4cg$1@nnrp1.deja.com>
print OUT scalar(<IN>);
<IN>;
<IN>;
while (<IN>) {
chop if eof IN;
print OUT;
}
# how good is that?????
In article <9163c7$2e9$1@nnrp1.deja.com>,
Odd_Carnivals@yahoo.com wrote:
> Hi Perl gurus,
>
> Any suggestions for how the following could be improved?
> What I'm doing is creating an output file that is identical
> to the input file minus the second, third and last lines,
> and with the linebreak removed from the next-to-last line
> (i.e. the last line of the output file).
>
> The following works, but I suspect there are better ways
> to do it (I'm new to Perl).
>
> $prev_line = <IN>; # Keep line 1.
> while($. < 3) {<IN>}; # Skip lines 2 & 3.
> while($line = <IN>) {
> print OUT ($prev_prev_line);
> $prev_prev_line = $prev_line;
> $prev_line = $line;
> }
> $prev_prev_line =~ s/\n//; #remove linebreak
> print OUT ($prev_prev_line);
>
> Thanks!
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 12:47:17 -0800
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: DBI prepare method
Message-Id: <kawZ5.39$Sd6.56332@news.pacbell.net>
Hi. I have a question about the Perl 5 DBI 'prepare' method. Is it true that
one cannot prepare the following SQL statement
my $sth = $dbh->prepare(q{
INSERT INTO PathEnum
SELECT P1.assemblyno, B1.subassemblyno, (P1.pathlength + 1)
FROM PathEnum AS P1, Blueprint AS B1
WHERE EXISTS (SELECT *
FROM PathEnum AS P2
WHERE B1.assemblyno = P2.subassemblyno)
AND NOT EXISTS (SELECT *
FROM PathEnum AS P3
WHERE B1.assemblyno = P3.assemblyno
AND B1.subassemblyno = P3.subassemblyno)
}) || die $dbh->errstr;
because it contains two subqueries -- i.e. the two SELECT statements in the
EXISTS clauses? I realize that the documentation says that the 'prepare'
method prepares a single statement for later execution... but this _is_ a
single statement that should just be passed through to the database
back-end, isn't it?
(Some of you may recognize that this query comes out of Joe Celko's "SQL for
Smarties" 1st edition, Chapter 27, page 365-366. ...I am trying to
understand graph theory.)
The problem I am facing is this: if I have to break this statement up into
its component queries how do I preserve the overall logic?
Thanks,
brian
------------------------------
Date: Tue, 12 Dec 2000 13:09:41 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI prepare method
Message-Id: <3A369415.93866E8@vpservices.com>
Brian McDonald wrote:
>
> Hi. I have a question about the Perl 5 DBI 'prepare' method. Is it true that
> one cannot prepare the following SQL statement
That question is like asking "How comfortable is a chair?" The question
makes no sense in the abstract and can only be applied to a specific
case. There are prepare() methods for each driver (DBD) that DBI
supports. Whether or not a given DBD's prepare() method supports a
given SQL statement depends on 1) the capabilitities of the underlying
database and 2) the capabilities of the DBD. In neither case are the
capabilities of DBI part of the question.
So, if you want to know if subselects are supported you need to find out
1) are they supported in the underlying database you are using -- e.g.
Oracle, MySQL, etc. and 2) are they supported by the DBD for that
database -- e.g. DBD::Oracle, DBD::mysql, etc.
> The problem I am facing is this: if I have to break this statement up into
> its component queries how do I preserve the overall logic?
If subselects are not supported in your case, then create a temporary
table, insert the results of the two selects into it and then do a
select on that table.
--
Jeff
------------------------------
Date: Tue, 12 Dec 2000 14:20:50 -0800
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: Re: DBI prepare method
Message-Id: <1yxZ5.55$Sd6.77140@news.pacbell.net>
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3A369415.93866E8@vpservices.com...
> Brian McDonald wrote:
> >
> > Hi. I have a question about the Perl 5 DBI 'prepare' method. Is it true
that
> > one cannot prepare the following SQL statement
>
> That question is like asking "How comfortable is a chair?" The question
> makes no sense in the abstract and can only be applied to a specific
> case. There are prepare() methods for each driver (DBD) that DBI
> supports. Whether or not a given DBD's prepare() method supports a
> given SQL statement depends on 1) the capabilitities of the underlying
> database and 2) the capabilities of the DBD. In neither case are the
> capabilities of DBI part of the question.
>
You are right, of course. I didn't realize that I was asking such a
disembodied question.
The database I'm using is SQL Server 7 and the driver is DBD::ODBC.
I think I am wrong about the driver's prepare method not supporting
sub-select queries. I ran a test yesterday, in which I prepared the full
query, and got an error. That led me to believe that the statement was too
complex. I just now re-ran the test and -- surprise -- no error was given.
So I must have been doing something else wrong at the time and since fixed
it.
Now I have another issue in that the PathEnum table that is being generated
is not correct even though the query and algorithm is right out of Celko's
book. But... that's another problem and another question better placed
somewhere else.
Brian
------------------------------
Date: 12 Dec 2000 20:13:23 GMT
From: cljlk@hotmail.com (J. K.)
Subject: FTP.pm
Message-Id: <9160t3$o49@news.or.intel.com>
Hi,
I am looking for FTP.pm, where could I get the file?
Is it freeware?
Thanks
------------------------------
Date: Tue, 12 Dec 2000 12:28:16 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: FTP.pm
Message-Id: <3A368A60.B4BE499E@nowhereatall.com>
"J. K." wrote:
> Hi,
>
> I am looking for FTP.pm, where could I get the file?
> Is it freeware?
>
> Thanks
try CPAN it is part of the libnet package
------------------------------
Date: Tue, 12 Dec 2000 14:57:24 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how do i kill a process created like this in win98
Message-Id: <slrn93d49k.p9.tadmc@maxim.metronet.com>
nobody@nowhere.net <nobody@nowhere.net> wrote:
>like `notepad`
perl -e 'like `notepad`'
Backticks found where operator expected at -e line 1, near "like `notepad`"
(Do you need to predeclare like?)
syntax error at -e line 1, near "like `notepad`"
Execution of -e aborted due to compilation errors.
That does not look like Perl. There is no "like" keyword.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 12 Dec 2000 22:31:56 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: huh ??
Message-Id: <t3d9qse01tal01@corp.supernews.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> Chris Stith wrote:
>>but my background in other languages always leads me toward
>>a loop. This is as much simpler than a loop as a loop would be than
>>the original.
> map() is a loop.
This is understood, but it's an implicit loop. There's about as much
in common between map() and for() as there is between
elsif() {
}
and
if{
}else{
if {
}
}
or maybe this:
$x = $y + $z + $zz;
vs.
; this is pseudocode for a very simple stack machine
push zz ; put value of zz on the stack
push z ; put value of z on the stack
add ; add top two values, implicitly popping
; them and pushing the result onto the stack
push y ; push another value onto the stack
add ; add top two values
pop x ; pop the top value into a memory location
As you can see, the implemenation details are the same for many,
many different languages, adjusted for level of abstraction.
What I was pointing out as important was that the level of
abstraction offered by some of the Perl builtins makes things
much simpler and more concise.
Besides, if you want to get really technical, I can say that
gotos are bad and that subroutines are good, and many people
will agree. This is despite the fact that at some level a
subroutine includes an implicit goto, so comparing map to
an explicit loop and getting derided for it seems silly to me.
Chris
--
Christopher E. Stith - mischief@motion.net
> --
> Bart.
------------------------------
Date: Tue, 12 Dec 2000 09:54:34 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: huh ??
Message-Id: <slrn93cihq.p9.tadmc@maxim.metronet.com>
Doran Barton <fozz@xmission.com> wrote:
>Waarddebon wrote:
>>
>> Well this is the actual code, I really hope you can help me...
>>
>> $temp=$a1.$a2;
>> $string = "temp=" . $temp . "&a1=" . $a1 . "&a2=" . $a2 . "&a3=" . $a3 .
>> "&a4=" . $a4 . "&a5=" . $a5 . "&b1=" . $b1 . "&b2=" . $b2 . "&b3=" . $b3 .
>> "&c1=" . $c1 . "&c2=" . $c2 . "&d1=" . $d1 . "&e1=" . $e1 . "&e2=" . $e2 .
>> "&e3=" . $e3 . "&f1=" . $f1 . "&f2=" . $f2;
>> dbmopen(%DB, "/data/database/sell", 0664) || die $!;
>> $DB{$temp} = $string;
>> dbmclose(%DB);
>
>Are you aware that the & character is special in Perl?
Are you aware of the difference between code and data?
>It usually
>indicates a function call.
When used in code it can indicate a function call, but it is
not used in code above.
It is used in a string, it is _data_, not code.
>Try this:
>
> $string = 'temp=' . $temp . '&a1=' . $a1 . '&a2=' . $a2 . '&a3=' . $a3
That cannot possibly change anything.
Ampersand is data in double quotes. Ampersand is data in single quotes.
>Your original code works fine in my interpretter, but your interpretter
>may be picky.
There is only one Perl interpreter.
Your interpretter is his interpreter (ignoring bugs).
>Another solution is to use sprintf instead of all these concatenations:
>
> $string = sprintf("temp=%s&a1=%s&a2=%s&a3=%s...",
> $temp,$a1,$a2,...);
You should use (s)printf when you want to apply formatting.
You are not applying any formatting in your sprintf().
$string = "temp=${temp}&a1=${a1}&a2=${a2}...";
does the same thing.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 12 Dec 2000 22:40:34 GMT
From: guthrie_linck@my-deja.com
Subject: Re: huh ??
Message-Id: <9169h1$880$1@nnrp1.deja.com>
although map is concise, remember, it is much more inefficient than a
foreach() loop.... it doesn't have to build a whole new array and then a
join + copy the whole damn thing.
also, in response to the original post, why would you use a hundred
concatenation operators instead of just a single double quoted
string???????
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 21:50:11 GMT
From: Brian Runck <brianr72@my-deja.com>
Subject: implicit creation of array?
Message-Id: <9166if$5h4$1@nnrp1.deja.com>
Any ideas why this statement:
$self->{'input_data'}{$input_tag}[$i];
doesn't work the way one would expect? 'input_data' is a member of
class $self. It contains an anonymous, empty hash. If $input_tag =
'TERM' and $i = 0, I tried to use this to return the value of what is in
that element in the array stored in the hash stored in 'input_data'.
Since there isn't anything in the array yet (hasn't yet been created),
it should return nothing.
In other words, this is what $self->{'input_data'} looks like first (in
the debugger):
0 HASH(0x1f441b8)
empty hash
Then this statement happens:
$self->{'input_data'}{$input_tag}[$i];
Then this is what $self->{'input_data'} looks like after that statement:
0 HASH(0x1f441b8)
'TERM' => ARRAY(0x1edd9f4)
empty array
I'm assuming it thinks that since $self->{'input_data'} is a reference
to an empty hash, set up the key $input_tag with the anonymous array of
0 elements.
But I just want to check to see if there is a value in location 0 of key
$input_tag, and return that value or return nothing if it does not
exist. How do I do that, without assigning anything?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 14:11:53 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: local functions
Message-Id: <3A368689.A60A3D0@home.com>
Greg Bacon wrote:
>
> In article <3A366BBE.3020700@hivolda.no>,
> Ole Christian Eidheim <eidheim@hivolda.no> wrote:
>
> : Is there a way to create a local function A within a function
> : B that doesn't override an existent function with the same name
> : anywhere but within function B?
>
> You can play games like
>
> #! /usr/bin/perl -w
>
> use strict;
>
> sub foo {
> local *bar = \&baz;
>
> bar();
> }
>
> sub bar {
> print "bar!\n";
> }
>
> sub baz {
> print "baz!\n";
> }
>
> foo();
> bar();
> baz();
>
It's just preference, but if I have a function that I want to be local,
I don't like to have it even show up in the enclosing namespace:
sub foo {
local *bar = sub {
print "baz!\n";
}
bar();
}
-mjc
------------------------------
Date: Tue, 12 Dec 2000 21:45:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: local functions
Message-Id: <x766kpjoud.fsf@home.sysarch.com>
>>>>> "MC" == Michael Carman <mjcarman@home.com> writes:
MC> It's just preference, but if I have a function that I want to be local,
MC> I don't like to have it even show up in the enclosing namespace:
MC> sub foo {
MC> local *bar = sub {
MC> print "baz!\n";
MC> }
MC> bar();
MC> }
why even use the typeglobs? they will be gone (thankfully) in
perl6. just use a simple anon sub and save the code ref and call it. the
extra syntax on the ref call is matched by the lack of a typeglob and
local, both of which are ugly when not needed.
sub foo {
my $bar = sub {
print "baz!\n";
}
$bar->();
}
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 12 Dec 2000 20:38:29 +0100
From: "John Winter" <azby10@hotmail.com>
Subject: Looking for GREP examples
Message-Id: <915uti$26b$1@wanadoo.fr>
Hi,
New to Perl I'm primarily interessed by text searching tools. I'm looking
for GREP examples or tutorials.
I'm asking myself questions like:
- till what extent is it useful to precise GREP patterns (time/length)?
- can I link different greps ?
- is it possible to random grep secondary expressions ?
etc..
I'll be glad if you advise me on some web site or newsgroup dedicated to
this.
Thanks,
John
------------------------------
Date: 12 Dec 2000 22:30:40 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Need help to replace passwd - New at this !
Message-Id: <976660194.647589@elaine.furryape.com>
In article <913ffc$uha$1@nnrp1.deja.com>, <msalerno@my-deja.com> wrote:
>I am working on a script that will allow me to change the password of a
>user. Here is the problem, I cannot use the passwd command. I need to
>edit the /etc/passwd file. What I am looking to do is to change the
>password for a particular user. I do not need to encrypt the password
>since I will be using a default pre-encrypted password.
Stop.
You do not have the necessary skills to know the security implications of
your program.
Read lots of books, webpages etc, on security. In particular, read the
archives of the Risk Digest about the dangers of default passwords.
Then redesign your process to reflect what you've learned.
------------------------------
Date: 12 Dec 2000 20:03:49 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: need help with split
Message-Id: <976650884.13660@itz.pp.sci.fi>
In article <3A3631EB.61C94473@home.com>, Michael Carman wrote:
>
>data has something wrong with it. If it's okay to have empty fields,
>then you probably just want to default them to something (after the
>match) to shut up the warning:
>
>$callnum ||= '';
>
>Unless $callnum can have a value like 0 which would be read as false.
>Then you'll want to use defined instead:
>
>$callnum = '' unless defined $callnum;
Actually, while this is fairly good general advice, in this case more
specific advice would be better. In the regexp given, the pattern for
this paricular field couldn't match the empty string, but the match
itself was made optional:
(something that can't match 0 chars)?
So if the match for this particular field failed, the regexp engine
would skip it and return an undefined value for it. In this case,
however, it would make much more sense to consider an empty string a
valid match, which could be accomplished by changing that part of the
regexp to:
(something that can't match 0 chars|)
There. The question mark been removed, so something _must_ be
captured, but now the last alternative, between the bar and the
closing parenthesis, is an empty string.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 12 Dec 2000 15:41:30 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: need help with split
Message-Id: <Pine.GSO.4.21.0012121539570.19179-100000@crusoe.crusoe.net>
On Dec 12, Ilmari Karonen said:
> (something that can't match 0 chars)?
>
>So if the match for this particular field failed, the regexp engine
>would skip it and return an undefined value for it. In this case,
>however, it would make much more sense to consider an empty string a
>valid match, which could be accomplished by changing that part of the
>regexp to:
>
> (something that can't match 0 chars|)
The solution I usually use is
((?:something)?)
It's slightly noiser, but hey.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
PerlMonks - An Online Perl Community http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.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 5092
**************************************