[17875] in Perl-Users-Digest
Perl-Users Digest, Issue: 35 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 11 00:06:48 2001
Date: Wed, 10 Jan 2001 21:05:10 -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: <979189510-v10-i35@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Jan 2001 Volume: 10 Number: 35
Today's topics:
Cache Control Headers in LWP - Answer <wyzelli@yahoo.com>
Re: CGI vs Javascript dropdowns <brondsem@my-deja.com>
Re: counting lines in a file <jhelman@wsb.com>
Re: counting lines in a file (Tad McClellan)
Re: Creating accounts on iis5 advanced server <jhelman@wsb.com>
Re: data structure syntax <stampes@xilinx.com>
How to setup time elapse <zfhuang99@yahoo.com>
Re: HTML stripper <jhelman@wsb.com>
Re: Licensing a program written perl? egwong@netcom.com
Re: Perl guest book script <jhelman@wsb.com>
Piping output to 'passwd' <ssomneb@my-deja.com>
Re: Piping output to 'passwd' (Chris Fedde)
Re: Please Recommed Encryption Module (Damian James)
Re: Please Recommed Encryption Module (Alan Barclay)
Problem with 'split' and decimal points... <yo@yo.yo>
Re: Problem with 'split' and decimal points... <tony_curtis32@yahoo.com>
Re: Problem with 'split' and decimal points... <uri@sysarch.com>
Re: Problem with inserting data (Tad McClellan)
Re: Problem with inserting data (Tad McClellan)
Re: problems perl odbc SQL-Server 7.0: no records with <jhelman@wsb.com>
Re: Recursive Directory Size (Tad McClellan)
Re: replacing spaces with %20 <brondsem@my-deja.com>
Re: replacing spaces with %20 <newsgroups@jhorn.cjb.net>
Re: Untaint the following string. <james@NOSPAM.demon.co.uk>
Re: variable <jhelman@wsb.com>
Re: variable (Chris Fedde)
Re: Variable (Tad McClellan)
Re: variable <uri@sysarch.com>
Re: would a regex be helpful here? <jhelman@wsb.com>
Re: would a regex be helpful here? (Chris Fedde)
Re: would a regex be helpful here? <jhelman@wsb.com>
Re: would a regex be helpful here? <iboreham@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 11 Jan 2001 13:28:16 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Cache Control Headers in LWP - Answer
Message-Id: <%2a76.15$pE3.5853@vic.nntp.telstra.net>
Before Christmas last year I was working on a project where I needed to
force a proxy to reload every time a page was accessed using
LWP::UserAgent.
I posted here asking if anyone knew how to do that. Interestingly
enough there were no responses (and the same to similar questions on
deja).
I have the answer at last and post it for those interested, mainly
because LWP is such a good module.
The information comes partly from rfc2068 and then how that is
implemented in LWP::UserAgent (using HTTP::Headers) to modify the
request header.
In compliance with HTTP 1.0 the request needs to send a 'Pragma:
no-cache' in the request header.
With HTTP 1.1 the preferred method is to include a 'Max-Age = 0' in the
request header, though the 'no-cache [fields]' directive is also
supported.
When using LWP::UserAgent this is implemented by using the headers
function like so:
use HTTP::Request::Common;
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
$ua->proxy('http', "$proxy:$proxy_port");
my $req = new HTTP::Request('GET', "$url");
$req->header('pragma' => 'no-cache', #HTTP 1.0 header
'max-age' => '0'); #HTTP 1.1 header
my $request = $req->as_string(); #contains the full request
my $html = $ua->request($req)->as_string; #contains the returned html
This assumes $proxy, $proxy_port and $url are all defined earlier.
Anyway, my program is now working with always fresh data.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Thu, 11 Jan 2001 02:47:28 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: CGI vs Javascript dropdowns
Message-Id: <93j6ru$2it$1@nnrp1.deja.com>
In article <93fone$2ire$1@msunews.cl.msu.edu>,
"Eric" <eric.kort@vai.org> wrote:
> Ok, I'll take a crack at this, and look to the real experts to
correct my
> mistakes.
>
I'm not an expert, but I did notice one thing that should be clarified.
>
> CGI is the ONLY route for generating interactive web pages on the
fly, but
> CGI may be utilized by perl, C, java, whatever. The result is always
the
> same: html sent to the client's browser.
To an extent, interactive web pages can be generated via client side
scripting like JavaScript. They are limited because they can't read a
database or file, but they can dynamically generate the page. A simple
example is web pages that have a JavaScript popup input window asking
for your name. When the page loads, it says "Welcome, John Doe". And
then JavaScript reads/sets a cookie and the page continues by
displaying: "You have been here 3 times."
>
> hth, and I hope it is not too much of a glossing over the fine points
for
> the experts out there.
>
> Eric
>
>
--
Dave Brondsema
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 11 Jan 2001 02:08:48 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: counting lines in a file
Message-Id: <h45q5tst247l4lsrp8134512dminjo3bcm@4ax.com>
On Wed, 10 Jan 2001 18:21:28 GMT, lpj91100@my-deja.com wrote:
[Reordered the flow of time. Please post your responses BELOW the
appropriate text.]
>In article <slrn95ofm5.4bc.tadmc@tadmc26.august.net>,
> tadmc@augustmail.com wrote:
>> lpj91100@my-deja.com <lpj91100@my-deja.com> wrote:
>> >
>> >Does anybody have a perl script that counts the
>> >numbers of lines of a file,
>>
>> You are expected to check the Perl FAQ *before* posting to
>> the Perl newsgroup:
>>
>> perldoc -q count
>>
>> "How do I count the number of lines in a file?"
>>
>I took a look at the FAQ for counting line numbers, I'm not sure what
>the $buffer variable is coming from. As you can tell, I am very new to
>Perl.
Okay, the FAQ is below. I've described each line above the line.
# Initialize the counter to 0
$lines = 0;
# Opens the file or exits with an error code if it can't be opened.
open(FILE, $filename) or die "Can't open `$filename': $!";
# While the sysread() function can read something from the file
# (up to 4096 bytes per chunk), execute the loop. Store the
# data read to the variable $buffer. When nothing more can be read,
# sysread will return 0, rendering this condition false and exiting
# the loop.
while (sysread FILE, $buffer, 4096) {
# Increment $lines by the number of occurances of the newline
# character encountered in this chunk.
$lines += ($buffer =~ tr/\n//);
# End loop
}
# Close input file
close FILE;
Hope this helps,
JH
------------------------------
Date: Wed, 10 Jan 2001 16:43:44 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: counting lines in a file
Message-Id: <slrn95plsg.57p.tadmc@tadmc26.august.net>
[ Please put your comments *following* the quoted text that
you are commenting on.
Please do not quote an entire article.
Please do not quote .sigs.
Please see: http://www.geocities.com/nnqweb/nquote.html
Thank you.
]
lpj91100@my-deja.com <lpj91100@my-deja.com> wrote:
>
>I took a look at the FAQ for counting line numbers,
Thank you, but you were supposed to do that *before* you posted.
>I'm not sure what
>the $buffer variable is coming from.
perldoc -f sysread
>As you can tell, I am very new to
>Perl.
You seem to be new to 3 things simultaneously.
1) Programming (because programmers read the docs for the
software they are using)
2) Perl (because you don't know how to lookup Perl's sysread()
function)
3) Usenet (because you posted without checking the FAQ first,
AND you quote in reverse time order)
You must learn some minimal amount of Perl before you can
start using Perl to get stuff done. Find a Perl tutorial
somewhere.
[snip Jeopardy quoted text]
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Jan 2001 02:25:49 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Creating accounts on iis5 advanced server
Message-Id: <a96q5tkf25npdpsnbj1i9bl81vd3no27c4@4ax.com>
On Wed, 10 Jan 2001 23:01:01 GMT, jlegay@my-deja.com wrote:
>I have now moved the site and scripts to a Windows 2000 Advanced Server
>box and presto, I can't create user accounts anymore. I have tried
>everything known to man but the script will not create accounts. Perl
>is setup correctly on the server. Some of my other scripts do work on
>the new server. The script to create accounts works if I run it via a
>command prompt.
This isn't a Perl problem, it's a permissions problem. Check the
permission of the user that is running the script when you aren't
running it from the command line (i.e., the web server). Chances are
it isn't running with Administrator privileges (which is probably a
good thing. Are you really sure that you want a CGI script to create
user accounts? Sounds like a security hole a cracker could drive a
truck through.)
JH
------------------------------
Date: Wed, 10 Jan 2001 13:59:36 -0700
From: Jeff Stampes <stampes@xilinx.com>
Subject: Re: data structure syntax
Message-Id: <3A5CCD38.7EDFE7AD@xilinx.com>
Greg Bacon wrote:
> <robr@sitera.com> wrote:
>
> : If I have:
> :
> : my $ref = {
> : "foo" => [ "0", "1" ]
> : };
> :
> : what would be the syntax to push "2" onto the anonymous array?
>
> push @{ $ref{foo} }, 2;
>
> See the perldsc and perllol manpages.
Good advice, but unless my debugger misleads me, wrong answer (and Ala as
well...makes me worry about my debugger!). It will work as:
push @{ $ref->{foo} }, 2;
main::(-e:1): 1
DB<1> $ref = {"foo" => [ "0", "1" ] }
DB<2> push @{ $ref{foo} }, 2;
DB<3> x $ref
0 HASH(0x299840)
'foo' => ARRAY(0xdf5c4)
0 0
1 1
DB<4> push @{ $ref->{foo} },2
DB<5> x $ref
0 HASH(0x299840)
'foo' => ARRAY(0xdf5c4)
0 0
1 1
2 2
------------------------------
Date: Wed, 10 Jan 2001 22:24:00 -0600
From: Cheng Huang <zfhuang99@yahoo.com>
Subject: How to setup time elapse
Message-Id: <3A5D3560.F22F6474@yahoo.com>
I want to get the time, which is a 30 minutes from now,
and turn it into a special formatted string.
Can anybody tell me how to do that?
Thanks,
--Cheng
------------------------------
Date: Thu, 11 Jan 2001 02:17:11 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: HTML stripper
Message-Id: <sh5q5ts5h7kib4hbc3v239pd8vuc9vieou@4ax.com>
On Wed, 10 Jan 2001 17:29:24 GMT, eggie@REMOVE_TO_REPLYsunlink.net
(James Kufrovich) wrote:
>On Wed, 10 Jan 2001 05:31:53 GMT, I <eggie@REMOVE_TO_REPLYsunlink.net>
>wrote:
>> if ($message =~ m!<(.*?)>\s*(.*?)\s*</\1>!i) {
>> #error! contains html.
>> }
>>
>
> Following up my own post, the following regex will work better,
>matching a newline anywhere between the HTML tags:
>
> m!<(.*?)>(?s:.*?)</\1>!i)
Uh, no, it doesn't:
<A HREF="somelink.html">Here's
several
newlines
</A>
This only works for perfectly matched tags (like <B></B>) with no
parameters. That's probably less than half of the tags used in most
documents.
> Basically, the (?s:...) modifier uses single-line mode within that
>cluster only, allowing '.' to match any character, including the newline,
>which '.' doesn't normally match. Hrmm, maybe sticking the /s outside of
>the entire regex would be better in this case? Maybe
>m!<(\w+)>(.*?)</\1>!si would work?
That would work just as well as your original solution, which means it
wouldn't.
> Are there any valid HTML tags that
>don't match (\w+)?
Oh, let's see...<A HREF...>, <A NAME...>, <FORM ACTION...>,
<TABLE...>, <DIV ALIGN...>, ... shall I go on?
Use the standard parsing modules. Unless the HTML you are parsing is
very clean (i.e., you generated it or some other program that you
understand did), parsing HTML using RegExs is not worth wasing your
time on.
JH
------------------------------
Date: Thu, 11 Jan 2001 02:11:33 GMT
From: egwong@netcom.com
Subject: Re: Licensing a program written perl?
Message-Id: <pD876.1664$J%.197281@news.flash.net>
bababozorg@aol.com wrote:
> Hi
> I was wondering if there is a way to actually implement licencing in a
> perl program... what i mean is simply... if a customer buys this
> program written in perl, under one user license... is there anyway to
> stop him if he gives a copy of the program to his friend to use or
> something?
[ cut ]
You put something like this in all of your program files and
documentation:
#
# copyright (c) 2001 by your name, your address.
# All rights reserved. Unauthorized reproduction or
# distribution prohibited by law.
#
Then buy a book on copyrights like the Nolo Press' _Copyright your
Software_ (http://www.nolopress.com/product/CYS/summary_CYS.html?t=02590000803202000SubcategoryID*8)
or talk to a lawyer.
If you want a *technical* way to protect your intellectual property, well
then good luck. If billion dollar companies like oracle and microsoft
can't meaningfully copyprotect their software, what chance do you think
you have?
eg
------------------------------
Date: Thu, 11 Jan 2001 02:38:44 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Perl guest book script
Message-Id: <937q5tsk8k7caihdj2t7gq84ojl1qhbcj0@4ax.com>
On Wed, 10 Jan 2001 15:57:43 -0500, "Kevin Riggs"
<kevinriggs@mindspring.com> wrote:
>I have the following script running at
>
>http://www.fodac.org/gb/guest.htm
>
>and it's getting an internal server error. Any ideas about what might be
>causing the problem would be appreciated.
Well, aside from being hard to read, it's missing a closing bracket on
the final subroutine. If you indented your script to make it more
readable (and debugable), this would have been immediately apparent.
Also, had you run this from the command line, the error would have
appeared immediately. If you don't have perl installed on your
workstation, why not?
JH
------------------------------
Date: Thu, 11 Jan 2001 02:28:44 GMT
From: John Galt <ssomneb@my-deja.com>
Subject: Piping output to 'passwd'
Message-Id: <93j5ol$1li$1@nnrp1.deja.com>
I'm new to Perl, so bear with me here.
I need to write a program that will change the password on my linux
machine. Here's what I have:
#!/usr/bin/perl -w
open PASSWD, "|passwd" or die "Can't open: $!";
print PASSWD "abc123\n"; #it asks for it twice
print PASSWD "abc123\n";
The best I can do is get a "passwd: Conversation error." I've tried
playing around with the pipes, but nothing has worked yet. I haven't
found any tutorials that explain piping really well (or at least to the
point that I can grasp how they work.) Any ideas? Anything simple I'm
doing wrong?
Thanks!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 11 Jan 2001 04:34:36 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Piping output to 'passwd'
Message-Id: <wJa76.855$B9.189051904@news.frii.net>
In article <93j5ol$1li$1@nnrp1.deja.com>,
John Galt <ssomneb@my-deja.com> wrote:
>I'm new to Perl, so bear with me here.
>I need to write a program that will change the password on my linux
>machine. Here's what I have:
>
>#!/usr/bin/perl -w
>
>open PASSWD, "|passwd" or die "Can't open: $!";
>print PASSWD "abc123\n"; #it asks for it twice
>print PASSWD "abc123\n";
>
>
>The best I can do is get a "passwd: Conversation error." I've tried
>playing around with the pipes, but nothing has worked yet. I haven't
>found any tutorials that explain piping really well (or at least to the
>point that I can grasp how they work.) Any ideas? Anything simple I'm
>doing wrong?
>
The technical problem with what you are trying is that passwd does
not read from STDIN, it reads from the terminal device. Back in
the 70's we called that a security measure. Call it what you want
now. If you really want to do it this way you'll want to learn about
pty and ioctl.
The best approach to this kind of problem is to avoid it. Use a one
time password scheme like s/key instead.
Another approach is to interface with the authentication subsystem. You
might be able to get some mileage out of using Authen::PAM since you are on
linux.
Finally if your OS is using the classic unix authentication mechanism or
this is the .htpasswd file for a web server you
can create an updated passwd file entry using crypt.
perl -lpe 's/(cfedde:)[^:]+:/$1.crypt("salt", "password").":"/e'\
/etc/passwd
--
This space intentionally left blank
------------------------------
Date: 11 Jan 2001 02:58:53 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Please Recommed Encryption Module
Message-Id: <slrn95q8dc.2gu.damian@puma.qimr.edu.au>
In article <93iuuu$i06$1@news.service.uci.edu>, Gabe wrote:
>Hi Damian, thanks for responding.
You're welcome.
>
>What is strong encryption versus weak encryption? What makes MySQL weak and
>others strong?
I'm afraid I don't really feel really qualified to answer this in any depth.
I say to use the MySQL built-ins if you don't require strong encryption
because:
(a) This would be easier from your point of view; and
(b) The way that encryption is implemented in MySQL (at least for
the ENCODE() built-in) is not documented (at least, not in
the standard mysql documentation). This suggests that its
best use is where you need to prevent information from being
accidentally or trivially read, but NOT where a knowlegeable
and determined attacker may be in the picture.
This is not to say that the mysql built-in encryption is 'weak', per se,
merely that you don't want to trust an undocumented model with sensitive
data in a public place.
I suggest you spend some time reading the documentation for the various
CPAN modules under the Crypt::* hierarchy, as Joe has indicated in his
follow-up. You probably also want to read up on computer security in
general, and web and cgi security in particular. Note that you probably
don't want to be collecting people's credit card particulars over the web
in clear text, for example.
Check these websites:
http://www.modssl.org/
http://www.openssh.com/
for information about making your web transactions more secure.
These things will lead you off-topic for this newsgroup. For information
about encryption you might want to look at sci.crypt and sci.crypt.research,
though make sure to lurk awhile before posting, and to read the FAQs for those
groups. These would be the best place to find references to cryptography
texts, in any case.
I hope this is of some help,
Cheers,
Damian
------------------------------
Date: 11 Jan 2001 04:48:12 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: Please Recommed Encryption Module
Message-Id: <979188439.508148@elaine.furryape.com>
In article <93iutb$hvr$1@news.service.uci.edu>, Gabe <grichard@uci.edu> wrote:
>Hi Joe, thanks for the response.
>
>I guess the problem is I don't know what the differences between DES, MD5,
>and Blowfish are. What is used for what? They are all encryption
Then you should ask on sci.crypt, which knows all about the
advantages & disadvantages of the various methods.
------------------------------
Date: Thu, 11 Jan 2001 02:13:59 GMT
From: "No Such Luck" <yo@yo.yo>
Subject: Problem with 'split' and decimal points...
Message-Id: <HF876.164323$I5.3920008@news1.rdc1.sdca.home.com>
I have a floating point number string that I need to split into it's integer
and decimal portions. I'm having trouble using 'split' to accomplish this.
For example, the following code:
$test="12345:67890";
@temp=split(/:/,$test);
print "temp[0]<br>";
print "temp[1]<br>";
produces the output:
12345
67890
But as soon as the colon is replaced with a decimal point:
$test="12345.67890";
@temp=split(/'.'/,$test);
print "temp[0]<br>";
print "temp[1]<br>";
The output is:
12345.67890
Does anyone know what I'm doing wrong? Am I using split incorrectly, or is
there another, better way to accomplish this feat?
Thanks in advance.
------------------------------
Date: 10 Jan 2001 20:16:05 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Problem with 'split' and decimal points...
Message-Id: <871yuan89m.fsf@limey.hpcc.uh.edu>
>> On Thu, 11 Jan 2001 02:13:59 GMT,
>> "No Such Luck" <yo@yo.yo> said:
> I have a floating point number string that I need to
> split into it's integer and decimal portions. I'm having
> trouble using 'split' to accomplish this.
> But as soon as the colon is replaced with a decimal
> point:
> $test="12345.67890"; @temp=split(/'.'/,$test); print
> "temp[0]<br>"; print "temp[1]<br>";
perldoc perlre
look for what "." means in regexen.
hth
t
--
Eih bennek, eih blavek.
------------------------------
Date: Thu, 11 Jan 2001 04:28:11 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Problem with 'split' and decimal points...
Message-Id: <x7puhu4srp.fsf@home.sysarch.com>
>>>>> "NSL" == No Such Luck <yo@yo.yo> writes:
NSL> $test="12345:67890";
NSL> @temp=split(/:/,$test);
NSL> But as soon as the colon is replaced with a decimal point:
NSL> $test="12345.67890";
NSL> @temp=split(/'.'/,$test);
hmm, i see quotes that aren't in the : version. why are they here? just
that alone makes this different than 'colon is replaced'.
and tony referred you to the docs to learn what . means in a regex.
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: Wed, 10 Jan 2001 18:59:50 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with inserting data
Message-Id: <slrn95ptrl.5ch.tadmc@tadmc26.august.net>
Edd <edd@texscene.com> wrote:
>I don't quite understand 'while (<>)' what does that do.
^^
^^ that thingie is an operator
perldoc perlop
---------------------------
=head2 I/O Operators
There are several I/O operators you should know about.
...
Ordinarily you must assign the returned value to a variable, but
there is one situation where an automatic assignment happens. If
and only if the input symbol is the only thing inside the conditional
of a C<while> statement (even if disguised as a C<for(;;)> loop),
the value is automatically assigned to the global variable $_,
destroying whatever was there previously...
...
The null filehandle <> is special: it can be used to emulate the
behavior of B<sed> and B<awk>. Input from <> comes either from
standard input, or from each file listed on the command line. Here's
how it works: ...
---------------------------
So, it reads a line from one of the files in @ARGV, and puts it into $_
while ( $_ = <> ) # same thing (almost)
while ( defined($_ = <>) ) # really the same thing
>Another version
>from perldoc is
>'while (<CVS>). What on earth is CVS.
A filehandle. (wasn't it really CSV - Comma Separated Values?)
>There is no explanation about it
>whatsoever.
It is expected that you have an understanding of the basics of
Perl already. If you don't, then you have more research work to do.
"What is CVS" is not related to databases. It is how you do
input in Perl.
In addition to the I/O section above, see
perldoc -f open
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 10 Jan 2001 20:27:33 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with inserting data
Message-Id: <slrn95q305.5hi.tadmc@tadmc26.august.net>
Damian James <damian@puma.qimr.edu.au> wrote:
>In article <3a5621e0@news-uk.onetel.net.uk>, Edd wrote:
>>I am using the below section of a code to insert data into an MySQL table. I
>>copied this from DBI documentation available at www.perldoc.com/DBI
>
>Don't do this. Read it, look up anything you don't understand in the
>documentation, then write your own code to suit _your_ needs. If you
>admit to just copying code from random sources in this newsgroup,
^^^^^^^^^^^^^^^^^^^
>people who might otherwise give you good advice will killfile you.
But the documentation included with a module is not a "random"
source. (unless MW has made some Perl modules...)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Jan 2001 03:21:03 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: problems perl odbc SQL-Server 7.0: no records with tinyint
Message-Id: <qe9q5tgvi97ithr1516nt31rjluhc7psn1@4ax.com>
On Wed, 10 Jan 2001 16:25:17 +0100, "claudio militello"
<claudio.militello@infos.es> wrote:
>Jeff Helman <jhelman@wsb.com> escribió en el mensaje de noticias
>> if ($SGC->Sql($sql)) {
>> my $error = $SGC->Error();
>> print "Error executing query: $error\n";
>> } else {
>> ## PARSE YOUR DATA HERE
>> }
>>
>> Change both of your queries to this format and see if your second
>> query is returning an error.
>>
>> JH
>
>I changed the code to check for error: no error returns from the Sql call
Okay, next question: Are you sure the loop is executing? Do something
like this:
# At top of script kill output buffering
$| = 1;
# Replace your while() loop that reads through the records as follows:
while($SGC->FetchRow()) {
print "Reading a row now\n";
%telefonosHash = $SGC->DataHash;
$teId = sakaIntFromOdbc($telefonosHash{"TE_ID"});
print "tel: $teId \n";
}
By doing this, you'll know if the loop is executing. If it is, then
the problem is with your sakaIntFromOdbc() function. If it isn't,
then you have a SQL problem that is beyond the realm of this
newsgroup.
Incidentally, you haven't posted the code from the sakaIntFromOdbc
function. That may be where your problem is. Code?
JH
------------------------------
Date: Wed, 10 Jan 2001 19:56:58 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Recursive Directory Size
Message-Id: <slrn95q16q.5ch.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>How do I get the size of a directory recursively?
That would depend on how you define "size".
Number of bytes used? Sum of all of the file sizes?
Those can be different in light of "holes" in files for OSes
that support them. Using a program that knows how to do it
on your OS would be a Good Idea.
>This code only gets
>the first level...
Use the File::Find module for recursive directory searching.
>while (glob "$dir*") {
^^^^
Since glob()'s argument is probably (you haven't said what Perl
version you use) destined for a shell, I hope you are taking
appropriate security measures and checking the heck out of
$dir's value before using it like that.
Much safer to use opedir()/readdir() instead of globbing.
I only use globbing in "dirty hack" level programs, not
for "real code".
>I can't get `du -ck $dir` to get the size recursively either.
Why not? What happened when you tried it?
>I just
>finished studying man glob, but didn't see anything in there to help
>this.
Don't use globbing. It is never required.
Get 'du' working, or use File::Find.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Jan 2001 02:41:47 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: replacing spaces with %20
Message-Id: <93j6ha$2f3$1@nnrp1.deja.com>
In article <93imh0$k1q$1@nnrp1.deja.com>,
^Jerry <newsgroups@jhorn.cjb.net> wrote:
> I'm using a perl script to show images from a folder, one at a time..
> it works perfect in Internet Explorer, but in Netscape, if the images
> have a space in their name, it won't work...
>
> how can I replace the name of an image (in $image_name) to something
> like this%20is%20me.jpg ??
I wrote a program just like that.
$image_name =~ s/ /\%20/g;
For more info:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/s.html
>
> any help is greatly appreciated...
>
> Jerry
>
> Sent via Deja.com
> http://www.deja.com/
>
--
Dave Brondsema
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 11 Jan 2001 03:36:55 GMT
From: ^Jerry <newsgroups@jhorn.cjb.net>
Subject: Re: replacing spaces with %20
Message-Id: <93j9on$4tc$1@nnrp1.deja.com>
hehe.. yeah..
I had done a table inside a perl script, and it looked perfect in IE..
I checked it in Netscape, and all I saw was text stuck together..
I only used <tr> and no <td> tags... hehe
Jerry
> This is because whitespace is not legal in a URL. IE is too
> forgiving.
> Cheers,
> Damian
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 11 Jan 2001 02:36:27 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Untaint the following string.
Message-Id: <ant110227d07fNdQ@oakseed.demon.co.uk>
In article <sQV66.1667$jk6.352784@typhoon2.ba-dsg.net>, Alex Hart
<URL:mailto:news@#nospam#althepal.com> wrote:
>
> Arthur Dalessandro wrote:
> >
> > I have to untaint the following string, does anyone have any idea
> > why this is not working?
> > $dn = $1 if ($data =~ /^([ *,-\@\^\w.]+)$/);
>
> try putting the dash (-) at either end of the brackets, instead of
> in the middle
...and you might need an equals sign in there if you want it to match
data containing equals signs. ;-)
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Thu, 11 Jan 2001 02:32:44 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: variable
Message-Id: <go6q5tcros1erfgg6ik1au7j0akd306rem@4ax.com>
On Wed, 10 Jan 2001 22:29:54 GMT, "Waarddebon" <Waarddebon@chello.nl>
wrote:
>I can I make all characters in a string lowercase ??
Get thee to a command prompt and type:
perldoc -f lc
Or, should you not have Perl installed on your machine (and why not?),
go read:
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/lc.html
JH
------------------------------
Date: Thu, 11 Jan 2001 02:34:14 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: variable
Message-Id: <GY876.849$B9.189051904@news.frii.net>
#/usr/bin/perl -w
#
# Please excuse the jeopardy style post.
#
$/ = '';
$a = <DATA>;
$a =~ y/A-Z/a-x/;
__END__
In article <Cn576.570261$%C1.7016808@Flipper>,
Waarddebon <Waarddebon@chello.nl> wrote:
>I can I make all characters in a string lowercase ??
>
>Thanks in advance.
>
>
--
This space intentionally left blank
------------------------------
Date: Wed, 10 Jan 2001 19:57:54 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Variable
Message-Id: <slrn95q18i.5ch.tadmc@tadmc26.august.net>
Waarddebon <Waarddebon@chello.nl> wrote:
>How can you make from all characters in a variable (from which are upercase
>and some lowercase) all lowercase characters ?
perldoc -f lc
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 11 Jan 2001 04:31:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: variable
Message-Id: <x7n1cy4sln.fsf@home.sysarch.com>
>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:
CF> $/ = '';
why the paragraph mode? it doesn't gain anything when you mung single
chars.
CF> $a = <DATA>;
don't use $a for regular vars. they are exempt from strict because of
their use in sort. and again since sort uses them, they can be confused.
CF> $a =~ y/A-Z/a-x/;
^
hmm, do you want to keep Z as it is?
and lc is better on several fronts. it works with locales, it returns
the string, and doesn't require knowing the last letter of the
alphabet. :)
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: Thu, 11 Jan 2001 02:29:34 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: would a regex be helpful here?
Message-Id: <lg6q5t0tm2rbab5rgrt4jn1c5r7l8l6rog@4ax.com>
On Thu, 11 Jan 2001 00:02:43 GMT, Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:
>
> CF> webqueen, queen of the web <webqueen@my-deja.com> wrote:
>
> >> 1,2,4,6-9,12,15-16,20
> >>
> >> which I want to explode into:
> >> 1,2,3,6,7,8,9,12,15,16,20
>
> CF> $a = "1,2,4,6-9,12,15-16,20";
> CF> $a =~ s/-/../g;
> CF> @a = eval"($a)";
> CF> print "@a\n"
>
>feh. you return a list and i think she wanted a string.
>
> $a =~ s/(\d+)-(\d+)/join ',', $1 .. $2/ge ;
>
>BTW the /e eval is very different than the string eval chris used. s///e
>compiles the replacement code once at compile time. eval string compiles
>the string every time at runtime.
Not to mention that if your input was:
1,2,3;
system('rm -f *');
4,5,6;
This would be a really bad thing to eval() unless you are running
under taint mode.
JH
------------------------------
Date: Thu, 11 Jan 2001 02:51:22 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: would a regex be helpful here?
Message-Id: <Kc976.850$B9.190390784@news.frii.net>
In article <lg6q5t0tm2rbab5rgrt4jn1c5r7l8l6rog@4ax.com>,
Jeff Helman <jhelman@wsb.com> wrote:
>On Thu, 11 Jan 2001 00:02:43 GMT, Uri Guttman <uri@sysarch.com> wrote:
>
>>>>>>> "CF" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:
>>
>> CF> $a = "1,2,4,6-9,12,15-16,20";
>> CF> $a =~ s/-/../g;
>> CF> @a = eval"($a)";
>> CF> print "@a\n"
>>
>>feh. you return a list and i think she wanted a string.
>>
>> $a =~ s/(\d+)-(\d+)/join ',', $1 .. $2/ge ;
>>
>>BTW the /e eval is very different than the string eval chris used. s///e
>>compiles the replacement code once at compile time. eval string compiles
>>the string every time at runtime.
>
>Not to mention that if your input was:
>
>1,2,3;
>system('rm -f *');
>4,5,6;
>
Your point is well taken but your example is flawed.
$a = q(1,2,3;
system('rm -f *');
4,5,6);
$a =~ s/-/../g;
@a = eval"($a)";
print @a, "\n", $@;
"With power comes responsibility."
Jeff Case, SNMP Research
--
This space intentionally left blank
------------------------------
Date: Thu, 11 Jan 2001 03:03:22 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: would a regex be helpful here?
Message-Id: <0h8q5tsken6fqefk9erfvvsfigi4dvk1h0@4ax.com>
On Thu, 11 Jan 2001 02:51:22 GMT, cfedde@fedde.littleton.co.us (Chris
Fedde) wrote:
>Your point is well taken but your example is flawed.
>
> $a = q(1,2,3;
> system('rm -f *');
> 4,5,6);
> $a =~ s/-/../g;
> @a = eval"($a)";
> print @a, "\n", $@;
True, but the original post read:
> On Wed, 10 Jan 2001 22:57:40 GMT, webqueen, queen of the web
> <webqueen@my-deja.com> wrote:
>
>Say I have an input like:
Point taken, but I don't know where this input is coming from (CGI,
command prompt, file, Ouija board), but I'm doubting that his input is
coming from a "qq" string delimited with parenthesis.
JH
------------------------------
Date: Thu, 11 Jan 2001 03:51:17 GMT
From: Ian Boreham <iboreham@my-deja.com>
Subject: Re: would a regex be helpful here?
Message-Id: <93jajk$5n7$1@nnrp1.deja.com>
In article <93ipcv$msi$1@nnrp1.deja.com>,
webqueen, queen of the web <webqueen@my-deja.com> wrote:
> Say I have an input like:
>
> 1,2,4,6-9,12,15-16,20
>
> which I want to explode into:
> 1,2,3,6,7,8,9,12,15,16,20
Converting the 4 into a 3 could be difficult to do generally - I'm not
sure what rule is involved there. But as for the exploding question, you
can do this:
---CODE---
#! /usr/bin/perl -w
use strict;
my $string = "1,2,4,6-9,12,15-16,20";
print "BEFORE: $string\n";
$string =~ s/(\d+)-(\d+)/join(",", ($1..$2))/ge;
print "AFTER: $string\n";
---CODE---
Regards,
Ian
Sent via Deja.com
http://www.deja.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 V10 Issue 35
*************************************