[18540] in Perl-Users-Digest
Perl-Users Digest, Issue: 708 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 18 18:31:01 2001
Date: Wed, 18 Apr 2001 15:30:35 -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: <987633035-v10-i708@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 18 Apr 2001 Volume: 10 Number: 708
Today's topics:
Problems trying to process multiple items on a single l <g_adams27@hotSPAMISBADmail.com>
Re: Problems trying to process multiple items on a sing <uri@sysarch.com>
Re: Processing all files in directory <taka@yarn.demon.co.uk>
Re: Processing all files in directory <bart.lateur@skynet.be>
Re: Processing all files in directory <dan@nospam_dtbakerprojects.com>
Re: Processing all files in directory <mischief@velma.motion.net>
Re: Recursive directory listing (Dave Bailey)
Re: RegExp for parsing HTML table entries (Bernard El-Hagin)
Re: RegExp for parsing HTML table entries <christian.weyer@eyesoft.de>
Re: regular expression question nobull@mail.com
Returning 2 arrays from a sub <news@ian-howlett.com>
Re: Returning 2 arrays from a sub <news@ian-howlett.com>
Secure key generator/Algorithum <variant@shell.pacifier.com>
Re: Secure key generator/Algorithum nobull@mail.com
Re: Sending data from CGI script to other application <pratt@biop.ox.ac.uk>
Re: Sending Requests from Client to Server using Socket nobull@mail.com
Re: Slighty OT: Perl Books... (---Pete---)
Re: submission script help! <iou4evr@excite.com>
Re: unicode, perl and webbrowsers <bart.lateur@skynet.be>
Re: Using a Unix script in a Perl Script (Tad McClellan)
What is taking so long? (Profiling) david_kershaw@merck.com
Re: Why does Perl stringify this number? <pne-news-20010418@newton.digitalspace.net>
Re: Why does Perl stringify this number? <bart.lateur@skynet.be>
Re: Why does Perl stringify this number? <Geoffrey.Kinnel@bms.com>
Windows Perl <slcarvalho@hotmail.com>
Re: Windows Perl <juex@deja.com>
Re: Windows Perl <rayj00@yahoo.com>
Re: Windows Perl (Eric Bohlman)
Re: Windows Perl <bart.lateur@skynet.be>
workaround for sourcing file from perlscript <r.diwan@india.ti.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Apr 2001 17:12:01 -0400
From: "George Adams" <g_adams27@hotSPAMISBADmail.com>
Subject: Problems trying to process multiple items on a single line
Message-Id: <9bkvv2$eja$1@taliesin.netcom.net.uk>
Here's a simplified example that demonstrates a problem I'm trying to solve.
$foo = "We can store your files for 5 months, 10 months, or 12 months.";
I know that $foo contains a certain number of phrases that have the syntax
of "NNN months", though I'm not sure how many occurences there are.
Furthermore, I need to capture what all the NNN amounts are (in this
example, 5, 10, and 12).
I thought I might do something like this:
$foo =~ s/(\d+) months/push(@months,$1)/eig;
This does the trick (@foo now contains 5, 10, and 12), but it modifies $foo
in the process (now $foo = "We can store your files for 1, 2, or 3.")
Is the solution as simple as doing something like "$foo_orig = $foo" before
I start working with $foo? Or is there a more "elegant" way to achieve what
I'm doing above that leaves $foo untouched?
------------------------------
Date: Wed, 18 Apr 2001 21:33:03 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Problems trying to process multiple items on a single line
Message-Id: <x7r8ypki7a.fsf@home.sysarch.com>
>>>>> "GA" == George Adams <g_adams27@hotSPAMISBADmail.com> writes:
GA> $foo = "We can store your files for 5 months, 10 months, or 12 months.";
GA> $foo =~ s/(\d+) months/push(@months,$1)/eig;
GA> This does the trick (@foo now contains 5, 10, and 12), but it
GA> modifies $foo in the process (now $foo = "We can store your files
GA> for 1, 2, or 3.")
GA> Is the solution as simple as doing something like "$foo_orig =
GA> $foo" before I start working with $foo? Or is there a more
GA> "elegant" way to achieve what I'm doing above that leaves $foo
GA> untouched?
if you don't want to modify $foo, why are you using s///?
use m/// instead in an array context.
@month_ranges = $foo =~ m/(\d+) months/ig;
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 18 Apr 2001 10:28:48 +0100
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: Re: Processing all files in directory
Message-Id: <87oftud0a7.fsf@euterpe.yarn.demon.co.uk>
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> In article <87k84jhoy2.fsf@euterpe.yarn.demon.co.uk>,
> Paul the Nomad <taka@yarn.demon.co.uk> wrote:
> >I want to process all the files in a directory in date order (latest
> >first). So I needed to get a list of files in the directory - 'ls -t'
> >would do it. I've ended up doing it like this, is there a better way?
>
> Well, you might want to try working the GRT or ST into that sort
> routine, but really I think you are better off doing:
>
> chomp(@articles = `ls -t`);
I've tried this, but it seems to return as a scalar rather than as a list.
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> It takes a smart husband to have the last word and not use it.
--
-----------
Paul
http://www.seditiousdiaries.com/Donald10.html
------------------------------
Date: Wed, 18 Apr 2001 11:01:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Processing all files in directory
Message-Id: <kgsqdtci31du6feujo2athne3f9mhk0op3@4ax.com>
Paul the Nomad wrote:
>Perl Cookbook has a discussion on Schwartzian, but is there any good
>info on Orcish transformations?
A web search revealed some slides on MJD's site:
"Orcish Maneuver"
<http://perl.plover.com/yak/hw1/slide030.html>
and the Guttman-Rosler sort paper:
A Fresh Look at Efficient Perl Sorting
<http://www.sysarch.com/perl/sort_paper.html>
BTW these people credit Joseph N. Hall for the name, who is the author
of a popular Perl book: "Effective Perl Programming".
<http://www.effectiveperl.com/>
p.s. Why they all insist on writing "maneuver", which looks Dutch, I
don't know. My English dictionary says it should be written "Manoeuvre".
--
Bart.
------------------------------
Date: Wed, 18 Apr 2001 12:33:59 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: Processing all files in directory
Message-Id: <3ADD8873.EC3BE718@nospam_dtbakerprojects.com>
I haven't timed it... but the approach I use is to keep track of the
implicit stat() done on the file during the find() in a hash, and then
do a <=> on the hash... seems to be fast, but I haven't tried it with a
big list. Anyway, here is the code for the experts to pull apart:
sub FindByModified { my ( $StartDir , $Return , $MaxReturn , $Pattern ,
@PruneDirs ) = @_ ;
# init local vars
# -----
my @FilesFound = ();
my %WhenModified = ();
my $ExitFlag = 0 ;
my $tempString ;
my $tempKey = "";
my $tempTime = 0 ;
# --------------- executable --------------------------------
find (
sub { # this sub is executed for each dir listing traversed
# print DEBUG_LOG "\t looking at $File::Find::name \n" ; # comment out
for speed
if ( $ExitFlag ) { # flag has been set to exit ASAP
$File::Find::prune = 1 ;
return;
}
if ( -d ) { # its a dir, deal with it
if ( @PruneDirs ) { # check to see if it should be pruned
foreach $tempString ( @PruneDirs ) {
if ( $tempString eq $File::Find::dir ) {
$File::Find::prune = 1 ;
return;
}
}
}
if (( $Return eq 'top' )and ($File::Find::name ne $StartDir )) {
# dont go in ANY subdirs
$File::Find::prune = 1 ;
return;
}
return ; # go to the next listing, we dont want to return the bare
dirname
}
# print DEBUG_LOG "\t check for match to m\/$Pattern\/ \n" ;
if ( $_ =~ m/$Pattern/ ) { # listing matches the pattern
# print DEBUG_LOG "\t matches! \n" ;
$WhenModified{$File::Find::name} = (stat _)[9]; # use current stat
values
}
return ; # loop to the next listing
}
, $StartDir
);
if ( $Return eq 'since' ) {
# go thru the list only keep those modified since $MaxReturn
# -----
while (( $tempKey , $tempTime ) = each %WhenModified ) {
if ( $tempTime >= $MaxReturn ) { push( @FilesFound , $tempKey ) }
}
} else {
# sort em in decending num by time last modified, and save only the top
ones
# -----
@FilesFound = sort { $WhenModified{$b} <=> $WhenModified{$a} } keys
%WhenModified ;
unless ($MaxReturn ) {$MaxReturn = 1 }
splice( @FilesFound , $MaxReturn ); # discard older stuff
}
return( @FilesFound );
} 1;
------------------------------
Date: Wed, 18 Apr 2001 21:45:04 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Processing all files in directory
Message-Id: <tds2n04376gkce@corp.supernews.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> Paul the Nomad wrote:
>>Perl Cookbook has a discussion on Schwartzian, but is there any good
>>info on Orcish transformations?
[snip]
> BTW these people credit Joseph N. Hall for the name, who is the author
> of a popular Perl book: "Effective Perl Programming".
> <http://www.effectiveperl.com/>
> p.s. Why they all insist on writing "maneuver", which looks Dutch, I
> don't know. My English dictionary says it should be written "Manoeuvre".
[mischief@velma ~/perl_stuff]$ ../sp manoeuvre
sp: incorrect: manoeuvre does not appear in the dictionary.
[mischief@velma ~/perl_stuff]$ ../sp maneuver
sp: correct.
Darn us crazy Americans... thinking we can spell things differently
from a country we fought against for our independence. ;-) Seriously,
though, standard American English and standard British English are a
bit different. Some people even try to classify American as its own
language, but that doesn't fly with me since both dialects can
generally understand both the speakings and the writings in the
other.
It's kind of like having Perl with a pragma turned off, then
programming with it turned on. You probably can cope with either,
but it takes a very slight compensation on your part.
Chris
--
Christopher E. Stith
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, clp.misc
------------------------------
Date: 17 Apr 2001 09:39:57 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: Recursive directory listing
Message-Id: <slrn9dnpil.g1l.dave@sydney.daveb.net>
On Mon, 16 Apr 2001 23:05:31 -0400, Claudio Inglesi <cinglesi@puc.cl> wrote:
>Does anyone know of a perl script that builds a directory listing such as
>etc/
>lib/
>pub/
>dos/
>incoming/
> lrwp/
> cgi-bin/
> others/
> etc/
I am assuming you are doing this on a Unix variant. This is one of
those wheels that continually gets reinvented by people. If you just
want to print out such a listing, try 'tree -d'. If you want to store
the listing in a Perl data structure, then try messing around with
something like below. If you don't have the 'find' command, you
can easily use the File::Find module to build the @dirs array used by
the insert routine. Note, however, that backticking find will be
significantly faster for large directory trees.
#!/usr/bin/perl -w
use strict;
# print out the directory tree in /usr/local.
my $tree = print_tree(dir_tree('/usr/local'));
# returns a Perl data structure representing a directory tree.
sub dir_tree {
my $root = shift;
my @dirs = split "\n", `find $root -type d -printf \"\%d \%f\\n\"`;
my $tree = { $root => {} };
insert($tree,$root,\@dirs);
return $tree;
}
# recursive subroutine to fill the data structure.
sub insert {
my ($tree,$root,$dirs,$depth) = @_;
$depth ||= 0;
while ( @$dirs ) {
my $dir = shift @$dirs;
if ( $dir =~ /^(\d+)\s+(.*)$/ and $1 ) {
if ( $1 < $depth ) {
unshift @$dirs, $dir;
return;
} elsif ( $1 == $depth ) {
$tree->{$2} = {};
} elsif ( $1 == $depth + 1 ) {
unshift @$dirs, $dir;
insert($tree->{$root},$root,$dirs,$1);
}
$root = $2;
}
}
}
# recursive subroutine to print the contents of the data structure.
sub print_tree {
my ($tree,$depth) = @_;
$depth ||= 0;
foreach ( sort keys %$tree ) {
print ' ' x $depth, "$_/\n";
print_tree($tree->{$_},$depth+1);
}
}
__END__
--
Dave Bailey
davidb54@yahoo.com
------------------------------
Date: Tue, 17 Apr 2001 10:58:51 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: RegExp for parsing HTML table entries
Message-Id: <slrn9do85u.3vvn7c9.bernard.el-hagin@gdndev25.dev.lido-tech>
Christian Weyer <christian.weyer@eyesoft.de> wrote:
::Hi all,
::
::I am looking for a neat and small solution to get a list/array of entries in an HTML table.
::E.g.:
[snipped data which is repeated below]
::
::Now I want the 'Textn' values to be parsed ...
::
::Any ideas?
If that's really as complicated as your input HTML is going to get this
should be enough:
------------------------------
#!/usr/bin/perl -w
use strict;
my @text;
while(<DATA>){
push @text, $1 if m#<TD>(.*?)</TD>#;
}
$"="\n";
print "@text\n";
__DATA__
<HTML>
<TABLE ...>
<TR>
<TD>Text1</TD>
<TD>Text2</TD>
</TR>
...
<TR>
<TD>Text3</TD>
<TD>Text4</TD>
</TR>
</TABLE>
</HTML>
------------------------------
Cheers,
Bernard
--
perl -e's;;s,,Just another Perl hacker,;and$\="\r"and
$$=q!print${"\x27"}!;$;=qq.$0..q.v..qq!al $$!;$;=~s-\---;
/^....*(?{$|=eval$;;select($Just,$another,$Perlhacker,0.1)}).{25}/x;'
------------------------------
Date: Tue, 17 Apr 2001 13:06:10 +0200
From: Christian Weyer <christian.weyer@eyesoft.de>
Subject: Re: RegExp for parsing HTML table entries
Message-Id: <3ADC23A2.EEB19165@eyesoft.de>
Thanx Bernard,
I just found it out myself in the meantime ;-) (as always when posting ...)
Christian
--
___________________________________________________
eYesoft We see your visions.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Christian Weyer http://www.eyesoft.de
christian.weyer@eyesoft.de Bernhard-Krieg-Str. 4
Tel.: +49-9393-993161 97845 Neustadt/Main
___________________________________________________
Building Smart Internet Architectures
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
------------------------------
Date: 18 Apr 2001 08:35:25 +0100
From: nobull@mail.com
Subject: Re: regular expression question
Message-Id: <u9d7aaip1z.fsf@wcl-l.bham.ac.uk>
"whitetigercat" <whitetiger@pinc.com> writes:
> I've been playing around with regular expressions and can't seem to find an answer to this:
> If I have a pattern, how can i delete everything in the string doesn't match that pattern?
Untested, off the top of my head.
s/.*?($pattern|$)/$1/g;
> For example, if $content is an HTML page that contains a FORM and $pattern = "<input ([^>]|\n)*>"
You should get into the habit of using qr rather than qq (double
quotes) to qoute regexes. In this case it makes almost no difference
but if you had had escaped metacharacters it would have.
Since $content contains \n that should be treated as a normal
character you'll want a /s switch of the above s/// too.
> i.e. input statements in an HTML FORM, how can i delete everything in the page except
> these INPUT tags so I can do further processing on them? I've tried numerous methods.
You really should be using the HTML parser modules. Your pattern is
not always going to work.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 17 Apr 2001 22:55:13 +0100
From: "Ian Howlett" <news@ian-howlett.com>
Subject: Returning 2 arrays from a sub
Message-Id: <9bidru$s3l$1@news6.svr.pol.co.uk>
Hello,
I wonder if someone might be able to help me here.
I have a sub which I would like to return two arrays.
I understand from the O'Reilly books (Cookbook and Camel) that these need to
be passed back via references. The sub apepars to be building the arrays
correctly, but I can't see them back in the main program. I'm not sure
whether it's a problem with the return statement of the sub or the way I'm
writing the main program.
For now, let's assume that I just want to print the two arrays back in the
main program to show that they work.
If anyone could shed some light on what's going on here I'd be grateful,
Thanks Ian.
use strict;
sub getConfigInfo {
my $sectionName;
my @clientDirectories;
my @serverDirectories;
open (CONF, "test.conf") || die "Could not open test.conf";
while (<CONF>) {
chomp;
# Detect if we are in the client or server part of the configuration file
if (m/^# Client/) { $sectionName = "Client"; next; }
if (m/^# Server/) { $sectionName = "Server"; next;}
if (m/^#/) {next;} # Ignore comment lines beginning with #
if (m/^$/) {;next;} # Ignore blank lines
tr?\\?/?; # Replace any backslashes with slashes
# Populate the relevant array
if ($sectionName eq 'Client') { push @clientDirectories, $_; }
if ($sectionName eq 'Server') { push @serverDirectories, $_; }
}
return (\@clientDirectories, \@serverDirectories) ;
} # end of getConfigInfo
my @a;
my @b;
# Attempt to put the array values into @a and @b
($a, $b) = getConfigInfo() ;
# Attempt to print out the arrays to show that they have been retrieved
correctly
my $i;
print "\nclient:\n";
foreach $i (@a) {
print "$i\n";
}
print "\nserver:\n";
foreach $i (@b) {
print "$i\n";
}
------------------------------
Date: Wed, 18 Apr 2001 19:51:29 +0100
From: "Ian Howlett" <news@ian-howlett.com>
Subject: Re: Returning 2 arrays from a sub
Message-Id: <9bknfe$447$1@news8.svr.pol.co.uk>
Thanks, chaps.
> You need to dereference when attempting to actually use the array
contents.
------------------------------
Date: 18 Apr 2001 10:58:10 PDT
From: Jason Hurst <variant@shell.pacifier.com>
Subject: Secure key generator/Algorithum
Message-Id: <3addd5b2_2@news.pacifier.com>
This probably isnt the best place to be asking this question, but I really
didnt now where to post this.
Im trying to create a simple validation program. Id like to be able to
set a cookie with a value. Then in my other scripts Id check for the
existence of that cookie, and if the person had it then Id know they were
already validated somewhere else. The thing is, Id like to ensure the
validity of that cookie so I was thinking the best way to do this would be
to set a mathematical value that I could run an algorithm against to make
sure it checks out.
My math skills are only so-so and I was wondering if anyone already had
something like this or could point me in the right direction to start.
Ive really got no idea how Id even go about doing something like that. I
dont need ultra hard to crack security, just something simple. Thanks for
any help you can provide!
-jason
JAPH
------------------------------
Date: 18 Apr 2001 19:29:44 +0100
From: nobull@mail.com
Subject: Re: Secure key generator/Algorithum
Message-Id: <u966g2gixz.fsf@wcl-l.bham.ac.uk>
Jason Hurst <variant@shell.pacifier.com> writes:
> This probably isnt the best place to be asking this question, but I really
> didnt now where to post this.
Certainly not here - it definitely has nothing to do with Perl.
You could try one of the www related groups, but then again this
really has nothing to do with WWW either.
You could try a cryptography group - but you'd probably get flamed for
asking a FAQ.
This is one of those awkward universal programming problems.
> Im trying to create a simple validation program. Id like to be able to
> set a cookie with a value. Then in my other scripts Id check for the
> existence of that cookie, and if the person had it then Id know they were
> already validated somewhere else. The thing is, Id like to ensure the
> validity of that cookie so I was thinking the best way to do this would be
> to set a mathematical value that I could run an algorithm against to make
> sure it checks out.
You mean a cryptograpically strong hashing (aka "message digest") algorithm.
> My math skills are only so-so and I was wondering if anyone already had
> something like this or could point me in the right direction to start.
Actually that's a good start in itself. If you were moderately good
at maths then you'd be temped to roll your own crypto alorithm.
> Ive really got no idea how Id even go about doing something like
> that.
perldoc -f crypt
Note: I'm not suggesting you necessarily choose crypt() as your
hashing alorithm, there are stonger ones on CPAN, but it'll give you
the idea.
> I dont need ultra hard to crack security, just something simple.
In that case crypt() may be stong enough.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 17 Apr 2001 14:23:05 -0500
From: "David Pratt" <pratt@biop.ox.ac.uk>
Subject: Re: Sending data from CGI script to other application
Message-Id: <9bhfi9$27q$1@news.ox.ac.uk>
Thank you all for the info.... my script works now by utilising
system "app.pl -radius " . $radius . " &";
and properly untainting my data, which wasn't happening.
Thank you for your input.
Dave
David Pratt <pratt@biop.ox.ac.uk> wrote in message
news:9aetdt$f96$1@news.ox.ac.uk...
> I have tried the FAQ and books and google.com to find the answer to this.
> It's probably easy so apologies if it is.
>
> Using CGI.pm, I have a front end CGI script to an program that generates a
> file related to protein structures (not particularly important that bit).
> The CGI script allows options to be set by the user. Once submitted the
> script reads these options and I want now to send them to the other
program
> which generates the output. Initially I was simply sending them via
>
> system "make_surf -radius $radius -size $size" etc.
>
> However, when running under perl -T as I have to to allow this to be safe,
> perl complains about unsafe usage.
>
> What is the safe way of passing information, having untainted it, to
> subsiduary applications. This information also includes the random number
of
> the CGITempxxxxx file.
>
> Thanks for any help
>
> Dave
>
>
>
------------------------------
Date: 17 Apr 2001 17:30:18 +0100
From: nobull@mail.com
Subject: Re: Sending Requests from Client to Server using Sockets
Message-Id: <u9y9szij51.fsf@wcl-l.bham.ac.uk>
Lyle Goldman <Lyle_Goldman@ibi.com> writes:
> use Socket;
Unless execution speed is absolutely crucial[1] you may want to move to
using IO::Socket - it makes your code a lot more compact and less
looking like C.
Also IO::Socket defaults to creating sockets in autoflush mode and
that would have avoided the problem you are experiencing.
> use vars qw($port);
Why a package variable? Why not my?
> $| = 1;
This sets the autoflush attribute on the currently select()ed handle,
i.e. STDOUT. You probably want to set the autoflush attribute on the
socket instead.
For examples of how to set the autofush attribute on an arbitrary
handle see "perldoc -f select"
[1] If execution speed were crucial you'd be writing in C anyhow!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 18 Apr 2001 11:44:55 GMT
From: bogus@erol.com (---Pete---)
Subject: Re: Slighty OT: Perl Books...
Message-Id: <3add7dad.213842655@news.earthlink.net>
On Wed, 18 Apr 2001 01:01:23 GMT, "RobbieB" <robbie@totaln.com> wrote:
>Okay, i know there are numerous guides/faqs/tutorials/documents relating to
>Perl on the web, I really need a good book...
-------
If you search this newsgroup's posts over the
past 30 days on keyword... "book" you will find
what you are looking for.
---pete---
------------------------------
Date: Wed, 18 Apr 2001 14:41:36 GMT
From: "Kat" <iou4evr@excite.com>
Subject: Re: submission script help!
Message-Id: <AIhD6.5989$q51.55924@news1.gvcl1.bc.home.com>
I did find out that I am unable to use setuid on my works server. Are there
any free web sites that can handle this kind of stuff? I'm a little out of
touch with that kind of thing.
Thank-you for your help.
"David Efflandt" <see-sig@from.invalid> wrote in message
news:slrn9dq7jk.jc6.see-sig@typhoon.xnet.com...
> On Tue, 17 Apr 2001 15:36:38 GMT, Kat <iou4evr@excite.com> wrote:
> >
> > I am trying to get an assignment submission script. I cannot get the
script
> > to setuid properly. Everytime I test it the owner of the directory and
file
> > belong to "nobody". I was told to use a c wrapper so I have one that
> > hopefully gets the uid but I do not know how to use it. In the c file
there
> > is a call to the perl script. Now, where to make this call to the c
file?
> > Do I put it in the call to the script itself on the form or is there
> > something else I have to do? Any help would be greatly appreciated.
>
> You would submit the form to the suid C wrapper, which in turn should call
> the script as that uid. Of course it would be easier if you found a web
> host that runs cgiwrap or apache suexec so all your CGI would run as you.
>
> Or you could try using 'suidperl' instead of 'perl' in the first line of
> the script and see if you can do away with the C wrapper. But first read
> perldoc perlsec about untainting input and the environment.
>
> --
> David Efflandt (Reply-To is valid) 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: Wed, 18 Apr 2001 14:25:15 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: unicode, perl and webbrowsers
Message-Id: <ao8rdtol2jk6c1unfief8ka8j3cjuinsu5@4ax.com>
Alan J. Flavell wrote:
>On Mon, 9 Apr 2001, Bart Lateur wrote:
>
>> Off topic, but anyway... Let's get this over with.
>
>...and help to demonstrate the risks of off-topic answers... :-}
>
>> Netscape bug.
>
>There is a relevant Netscape 4 bug, agreed. But it _can_ still cope
>with either utf-8 coded characters _or_ &#bignumber; representations
>as long as you tell it the charset is utf-8. My checklist should
>help: http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist
>
>> It happens if you use numerical entities too.
>> Netscape 4.x *only* properly displays those entities, if they do map
>> properly to the currently selected code page. So I need to specify
>> ISO-8859-2 (instead of UTF-8) in order to properly display Polish, for
>> example.
>
>No Sir: if you've got your Unicode font properly configured, then
>it'll work with utf-8 selected as the coding.
I slightly misremembered. But your "checklist" is wrong, too. The truth
is inbetween these two extremes.
On Netscape 4.x, you CAN display any kind of character if you say that
the charset is UTF-8. But it DOES NOT WORK in forms. If you want to edit
French accented characters, you must set charset to ISO-Latin-1. If you
want to edit Polish characters, you must set the charset to ISO-Latin-2.
If you set it to UTF-8, all you get is blocks for those special
characters.
Of course, Netscape will also send the special characters in that
currently selected code page.
So: there's no way, in Netscape 4.x, to *edit* both French and Polish in
the same HTML form. UTF-8 just doesn't work there.
--
Bart.
------------------------------
Date: Wed, 18 Apr 2001 08:23:29 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using a Unix script in a Perl Script
Message-Id: <slrn9dr1q1.239.tadmc@tadmc26.august.net>
[ Do not send Stealth Cc's, they get you killfiled ]
[ Please put your comments *following* the quoted text that you
are commenting on.
Please do not quote an entire article.
Please never quote .sigs.
Thanks.
Jeopardectomy performed.
]
[ If your comment applies to the OP's question, you should followup
to the OP's post. Since you are following up to my post, I assume
you are trying to say something about the answer that I gave, but
I cannot discern what it might be that you are commenting on...
]
jkit <jkit@cipsinc.com> wrote:
>Tad McClellan wrote:
>
>> Prasad, Victor [FITZ:K500:EXCH] <vprasad@americasm01.nt.com> wrote:
>>
>> >I have to pass the parameters to the Unix script - but am not sure how
>> >to get the output from the script to Perl.
>> The answer to your question is given by:
>>
>> perldoc -f system
Which says:
"This is not what you want to use to capture the output from a command,
for that you should use merely backticks"
>Try back ticks.
That is what I said, why are you saying it again? That seems a
waste of time.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 17 Apr 2001 10:18:16 -0400
From: david_kershaw@merck.com
Subject: What is taking so long? (Profiling)
Message-Id: <3ADC50A8.F2CA273F@merck.com>
I tried to profile my perl script to find out what routines are doing
the most work. My script will be forced to parse over 4 million records
from a text file; so speed and efficiency matter a lot. I ran on 10,000
records and it took 146 secs. But my problem is when I ran dprofpp on
the output here is what I got:
Total Elapsed Time = 146.5911 Seconds
User+System Time = 6.181192 Seconds
Exclusive Times
%Time ExclSec CumulS #Calls sec/call Csec/c Name
49.1 3.038 2.975 10000 0.0003 0.0003 DBI::st::execute
18.9 1.169 1.105 10000 0.0001 0.0001 FOO::_parse_record
16.5 1.025 6.629 1 1.0249 6.6290 FOO::main
10.3 0.639 3.505 10000 0.0001 0.0004 FOO::_update_date
8.09 0.500 0.500 1 0.5000 0.5000 DBD::Oracle::db::_login
7.28 0.450 0.385 10000 0.0000 0.0000 IO::Handle::getline
2.43 0.150 0.654 10001 0.0000 0.0001 FOO::_get_dbh
1.44 0.089 0.217 7 0.0127 0.0309 FOO::BEGIN
0.65 0.040 0.040 4 0.0100 0.0100 DynaLoader::dl_load_file
0.49 0.030 0.030 2 0.0150 0.0150 AutoLoader::AUTOLOAD
0.49 0.030 0.099 6 0.0050 0.0165 IO::File::BEGIN
0.32 0.020 0.020 2 0.0100 0.0099 File::Spec::Unix::BEGIN
0.32 0.020 0.040 4 0.0050 0.0099 IO::Seekable::BEGIN
0.32 0.020 0.060 1 0.0199 0.0597 DBI::install_driver
0.16 0.010 0.010 5 0.0020 0.0020 Exporter::heavy_export
My routines only add up to 6 seconds! How do I find out what was
happening for the other 140 seconds? What could it be File I/0, the
disk, memory, someone else using up the CPU?
The contents of this message express only the sender's opinion.
This message does not necessarily reflect the policy or views of
my employer, Merck & Co., Inc. All responsibility for the statements
made in this Usenet posting resides solely and completely with the
sender.
------------------------------
Date: Wed, 18 Apr 2001 12:35:18 +0200
From: Philip Newton <pne-news-20010418@newton.digitalspace.net>
Subject: Re: Why does Perl stringify this number?
Message-Id: <n4rqdt4ni5qa42seldj4ru567q54dcur5b@4ax.com>
On Tue, 17 Apr 2001 15:16:34 -0400, Geoffrey C Kinnel
<Geoffrey.Kinnel@bms.com> wrote:
> $VAR1 = {
> 'bar' => 3
> };
> $VAR1 = {
> 'bar' => 1
> };
> $VAR1 = {
> 'bar' => '3'
> };
FWIW, here's what Devel::Peek says (on ActivePerl build 623, which is
basically 5.6.0):
U:\pne>perl -MDevel::Peek -de1
Default die handler restored.
Loading DB routines from perl5db.pl version 1.07
Editor support available.
Enter h or `h h' for help, or `perldoc perldebug' for more help.
main::(-e:1): 1
DB<1> $h->{foo} = 1
DB<2> $i->{bar} = 3
DB<3> x Dump $i
SV = RV(0x1e16244) at 0x1dadf48
REFCNT = 1
FLAGS = (ROK)
RV = 0x1dc3378
SV = PVHV(0x1dac22c) at 0x1dc3378
REFCNT = 1
FLAGS = (SHAREKEYS)
IV = 1
NV = 0
ARRAY = 0x1da0b20 (0:7, 1:1)
hash quality = 150.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "bar" HASH = 0x1bb43
SV = IV(0x1c99a98) at 0x1dadf3c
REFCNT = 1
FLAGS = (IOK,pIOK,IsUV)
UV = 3
empty array
DB<4> $i->{bar} = $h->{foo}
DB<5> x Dump $i
SV = RV(0x1e16244) at 0x1dadf48
REFCNT = 1
FLAGS = (ROK)
RV = 0x1dc3378
SV = PVHV(0x1dac22c) at 0x1dc3378
REFCNT = 1
FLAGS = (SHAREKEYS)
IV = 1
NV = 0
ARRAY = 0x1da0b20 (0:7, 1:1)
hash quality = 150.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "bar" HASH = 0x1bb43
SV = IV(0x1c99a98) at 0x1dadf3c
REFCNT = 1
FLAGS = (IOK,pIOK,IsUV)
UV = 1
empty array
DB<6> $i->{bar} = 4 - $h->{foo}
DB<7> x Dump $i
SV = RV(0x1e16244) at 0x1dadf48
REFCNT = 1
FLAGS = (ROK)
RV = 0x1dc3378
SV = PVHV(0x1dac22c) at 0x1dc3378
REFCNT = 1
FLAGS = (SHAREKEYS)
IV = 1
NV = 0
ARRAY = 0x1da0b20 (0:7, 1:1)
hash quality = 150.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "bar" HASH = 0x1bb43
SV = PVNV(0x1d781f8) at 0x1dadf3c
REFCNT = 1
FLAGS = (NOK,pNOK)
IV = 1
NV = 3
PV = 0
empty array
DB<8> use Data::Dumper
DB<10> print Dumper $i
$VAR1 = {
'bar' => '3'
};
DB<11> q
So the third $i->{bar} has a(n apparently empty) PV slot but no POK
flag on, which may be why Data::Dumper is stringifying it. Still
strange to me why it should have a PV slot[1] if neither ($i->{bar} =
1) nor ($i->{bar} = $h->{foo}) have one (they only have UV).
Cheers,
Philip
[1] Maybe it has something to do with the fact that the member is not
an IV but a PVNV since the subtraction was not done with "use
integer"? You'll see that the original UV slot is also still there (as
an IV slot), though there's no IOK flag. Maybe there's no NV that
doesn't also have a PV? My knowledge of the guts is not that good.
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Wed, 18 Apr 2001 19:26:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Why does Perl stringify this number?
Message-Id: <rjqrdtkm69pflp0qq9t4gsvssicikb973q@4ax.com>
Bart Lateur wrote:
>David Coppit wrote:
>
>>> Data::Dumper always does that.
>>
>>I'm not sure what you mean. Data::Dumper does *not* stringify all numbers.
>
>Eh, no. Apparently not. But I'm used to seeing it already. It's far from
>uncommon.
One example.
use Data::Dumper;
%x = %y = ( a => 1, b => 2);
print Dumper keys %x == keys %y;
-->
$VAR1 = '1';
Any reason why this boolean is tiurned into a string?
--
Bart.
------------------------------
Date: Tue, 17 Apr 2001 15:16:34 -0400
From: Geoffrey C Kinnel <Geoffrey.Kinnel@bms.com>
Subject: Re: Why does Perl stringify this number?
Message-Id: <3ADC9692.FCC1D52D@bms.com>
David Coppit wrote:
>
> On Tue, 17 Apr 2001, Bart Lateur wrote:
>
> > Data::Dumper always does that.
>
> I'm not sure what you mean. Data::Dumper does *not* stringify all numbers.
I see what David is talking about. See below for an example. I read
through perlref to see if I could see why it would do this, but no
joy. I also looked over perldelta for 5.6.1 and nothing jumped out at
me, but there are many references to references, so I may have missed
something going by. I also have to admit that references give me
headaches sometimes, mostly when I've had enough sleep and can think
clearly.
#!/usr/bin/perl
use Data::Dumper;
$h->{foo} =1;
$i -> {bar} = 3;
print Dumper $i;
$i -> {bar} = $h->{foo};
print Dumper $i;
$i -> {bar} = 4 - $h->{foo};
print Dumper $i;
$ perl junk.pl
$VAR1 = {
'bar' => 3
};
$VAR1 = {
'bar' => 1
};
$VAR1 = {
'bar' => '3'
};
This is perl, v5.6.0 built for ppc-linux
Geoff
------------------------------
Date: Wed, 18 Apr 2001 16:12:08 -0700
From: Sherry Carvalho <slcarvalho@hotmail.com>
Subject: Windows Perl
Message-Id: <3ADE1F47.1D7AA9D1@hotmail.com>
Where can I get a simulator that runs Perl programs from a win32 pc. My
OS is win98. I have acces to unix through telnet, but I have to get
online in order to write or test my code. I'd rather not tie up my
phone line if I don't have to.
Thank you,
Henry
please reply to hmust2@pitt.edu
------------------------------
Date: Wed, 18 Apr 2001 13:37:08 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: Windows Perl
Message-Id: <3addfaf4$1@news.microsoft.com>
"Sherry Carvalho" <slcarvalho@hotmail.com> wrote in message
news:3ADE1F47.1D7AA9D1@hotmail.com...
> Where can I get a simulator that runs Perl programs from a win32 pc. My
> OS is win98.
Why are you looking for a simulator?
Sure, there are a very few differences between Perl on Unix and Perl on
Windows.
But if you write your code OS independent (which in general is fairly easy)
then your Perl programs will run on any OS, be it Unix, Mac, Windows, or
whatever.
BTW: those differences are OS specific (if a file system doesn't have e.g.
access permissions for groups then you can't set them) and to write a
simulator which eliminates those differences would probably require the
re-implementing of UNIX on top of Windows. Not a very realistic scenario.
jue
------------------------------
Date: Wed, 18 Apr 2001 16:36:34 -0400
From: RayJ <rayj00@yahoo.com>
Subject: Re: Windows Perl
Message-Id: <3ADDFAD2.7040608@yahoo.com>
You can get Perl for Windows here:
http://www.activestate.com/ASPN/Downloads/ActivePerl/
Sherry Carvalho wrote:
> Where can I get a simulator that runs Perl programs from a win32 pc. My
> OS is win98. I have acces to unix through telnet, but I have to get
> online in order to write or test my code. I'd rather not tie up my
> phone line if I don't have to.
>
> Thank you,
> Henry
>
> please reply to hmust2@pitt.edu
------------------------------
Date: 18 Apr 2001 20:38:51 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Windows Perl
Message-Id: <9bku0r$csh$1@bob.news.rcn.net>
Sherry Carvalho <slcarvalho@hotmail.com> wrote:
> Where can I get a simulator that runs Perl programs from a win32 pc. My
> OS is win98. I have acces to unix through telnet, but I have to get
> online in order to write or test my code. I'd rather not tie up my
> phone line if I don't have to.
What you want isn't a "simulator" but a real honest-to-goodness Perl
interpreter. You can get Win32 binaries from ActiveState
(http://www.activestate.com) and some other places (there's an
"IndigoPerl" but I forget the URL). They're all free. If you're doing
CGI work, you'll probably want to get a Web server (I suggest Apache) and
install it locally as well. You should become familiar with the Win32
command line (though Win98 calls it a "DOS prompt" it's not restricted to
running DOS programs).
------------------------------
Date: Wed, 18 Apr 2001 21:09:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Windows Perl
Message-Id: <eqvrdtge0jdnge3j9m13nc748hoosp80ci@4ax.com>
Sherry Carvalho wrote:
>Where can I get a simulator that runs Perl programs from a win32 pc. My
>OS is win98.
"Simulator"? There are fullblown perls for Win32.
>I have acces to unix through telnet, but I have to get
>online in order to write or test my code. I'd rather not tie up my
>phone line if I don't have to.
You want to test CGI's? Then maybe your best bet would be to get
IndigoPerl for <www.indigostar.com>. That also includes an Apache
webserver in the same install, which makes getting started a snap. Fior
the rest, it's very highly ActivePerl compatible, which is where other
people pointed you to (<www.activestate.com>).
--
Bart.
------------------------------
Date: Thu, 19 Apr 2001 03:30:26 +0530
From: Ritesh Diwan <r.diwan@india.ti.com>
Subject: workaround for sourcing file from perlscript
Message-Id: <3ADE0E7A.4ED4A52D@india.ti.com>
Hi all,
I want to use put this command in perl script
source abc
executable argument
where abc is file which when sourced sets some variable
and allow to use some executables
but if i put this in perl script and runs it. it source the file in new
shell and hence all those executables can't be run as they are run in
different shell .
Can any body tell the workaround
bye
ritesh
--
-----------------------------------------------------------------------
RITESH DIWAN Ph(O)-- 5099555
Group - Alit Ph(R)-- 5215583
H.no.3134 13th cross 6th C main
HAL IInd stage Indranagar Bangalore INDIA
-----------------------------------------------------------------------
------------------------------
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 708
**************************************