[23201] in Perl-Users-Digest
Perl-Users Digest, Issue: 5422 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 25 09:05:53 2003
Date: Mon, 25 Aug 2003 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 25 Aug 2003 Volume: 10 Number: 5422
Today's topics:
Re: A newbie's question <jdagur@hotmail.com>
Re: buffer overflow <tassilo.parseval@rwth-aachen.de>
Re: Commonly used modules <gellyfish@gellyfish.com>
Debugger question <dgoto@burntmail.com>
Re: Debugger question <REMOVEsdnCAPS@comcast.net>
Doing a 'mail merge' with RTF files (aka RTF templates (Tony)
Re: Doing a 'mail merge' with RTF files (aka RTF templ <gellyfish@gellyfish.com>
Re: Editing Word documents in Perl (Openoffice Writer o <gellyfish@gellyfish.com>
Help requird : got a problem with foreach loop??? (Vinod. K)
Re: Help requird : got a problem with foreach loop??? (Tad McClellan)
Re: Help requird : got a problem with foreach loop??? (Tad McClellan)
Re: Help requird : got a problem with foreach loop??? (Anno Siegel)
Re: is my HTML tag stripper up to par? <gellyfish@gellyfish.com>
Re: is my HTML tag stripper up to par? <cwilbur@mithril.chromatico.net>
Mail::Audit (removing attachment fails on "broken path" <ian@WINDOZEdigiserv.net>
Re: Passing a hash to a function (Mark Healey)
Re: regexp mystery <usenet@shadowprint.de>
Re: regexp mystery <abigail@abigail.nl>
Re: What ever happened to comp.lang.perl ? (Helgi Briem)
Re: What ever happened to comp.lang.perl ? <gellyfish@gellyfish.com>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 25 Aug 2003 10:59:52 +0530
From: Jitu <jdagur@hotmail.com>
Subject: Re: A newbie's question
Message-Id: <3F499ECF.B9E402DA@hotmail.com>
Hi Mike,
Thanx for ur suggestion.
I'll put the message again with diff subject.
once again thanx
Mike Flannigan wrote:
> Jitu wrote:
>
> > Hi All,
> > I have one EventHandler running on a particular port that listens to
> > some events.
> > After some time i want to shutdown the EventHandler running on that
> > port.
> > I have tried few things but all in vain.
> > Can anyone tell me how to do it.....
> >
> > Thanx in advance
>
> I've got a friendly suggestion for you. Use a subject that is more
> descriptive of your problem than "A newbie's question".
>
> Some of the smartest people on this list won't even see your
> post with a subject like the one you picked.
>
> Mike Flannigan
------------------------------
Date: 25 Aug 2003 09:14:26 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: buffer overflow
Message-Id: <bick1i$f6v$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ilya Zakharevich:
> [A complimentary Cc of this posting was sent to
> Tassilo v. Parseval
><tassilo.parseval@post.rwth-aachen.de>], who wrote in article <biarrd$jm4$1@nets3.rz.RWTH-Aachen.DE>:
>> > I have been programming with Perl for a year now and supporting my own
>> > webserver but with all of MS's security issues I was wondering if someone
>> > could give me some pointers for testing buffer overflow. How do I go about
>> > writing such a program to test something like iis, ftp or telnet?
>
>> You can't produce buffer-overflows in Perl (at least not in the way they
>> can happen in C). I'd even say that you are immune against anything even
>> remotely ressembling overruns.
>
> This is a very bold statement...
>
> A lot of effort went into avoiding overflows; but perl being written
> in C, there is no guaranty against bugs.
Nowhere is a guarantee against anything. For the OP however, this
statement wont help. From a Perl-code-point-of-view there are no
buffer-overruns. Unless of course you show me a a few lines of Perl
code, that reliably produce such a vulnerability and that can be
detected by a code-review (in this case this behaviou should be
documented somewhere, btw).
That's the difference to C: allocate a buffer of 10 bytes and read 20
into it. That is something that can be catched by some code-auditing.
But you can't scan Perl code and detect something that produces an
overrun in the interpreter because you wont know whether the underlying
C-code has some bugs or not.
So in C overruns are in the responsibility of the programmer, in Perl
they are not (he can blame someone else for them, a broken libc, the
p5porters etc).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Mon, 25 Aug 2003 11:25:35 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Commonly used modules
Message-Id: <Pmm2b.2$Re7.519@news.dircon.co.uk>
Jon <jonov@iprimus.com.au> wrote:
> Hi,
>
> I'm curious to know what CPAN modules people use in their general day-to-day
> perl scripting (or can't live without). For example I make lots of use of
> the Date::Manip module and would hate to have to ever implement something
> like that.
>
I found a script that I made in response to a similar question four years
ago which counted the most frequently used modules in example code and the
output (as it stood then, I get my news differently now so I can't re-run it):
CGI 65
Net::FTP 55
File::Find 53
Win32::OLE 49
Date::Parse 49
LWP::UserAgent 40
IO::Socket 36
Date::Manip 32
Benchmark 29
Math::BigInt 28
HTML::Parser 24
DBI 20
DBD::Oracle 17
CGI::Carp 17
Time::JulianDay 16
HTTP::Request 16
Net::SMTP 16
IO::File 15
URI::Escape 14
Socket 14
I can't find the original message on Google.
For those interested the code was:
#!/usr/bin/perl -w
use strict;
my $dirname = "/var/spool/news/comp/lang/perl/misc/";
opendir(DIR,$dirname) || die "No diretory";
my @files = map { $dirname . $_ ; } grep !/^\./, readdir(DIR);
my %modules;
FILES:
foreach(@files)
{
open(FILE,$_) || next;
while(<FILE>)
{
next FILES if (/^--/);
next if /^[>+#:]/;
next if /^Subject:/;
chomp;
if (/perl +-\w*?M(\w+(?::)*\w*)\b/ ||
/\b(\w+?::\w+?);?\b/ ||
/\buse +([A-Z]\w+(?::)*\w*)/)
{
$modules{$1}++;
}
}
}
my @sorted = reverse sort { $a->[1] <=> $b->[1] }
map { [ $_,$modules{$_}]}
keys %modules;
foreach (@sorted)
{
printf("%-60s%i\n",$_->[0],$_->[1]);
}
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sun, 24 Aug 2003 18:22:04 -1000
From: Derek Goto <dgoto@burntmail.com>
Subject: Debugger question
Message-Id: <z9ydnSYZqqlxE9SiRTvUqg@ilhawaii.net>
I was running the perl debugger with arguments "-d -e 1" to test a small
program. When I assigned a value to the variable $foo, I could use it
fine, but when I qualified $bar with my, it remained undefined. Same
with local. Why is this? Does the debugger operate in a different scope
than main? If so, shouldn't I be able to access those values anyway? I
could access the value of $bar from the debugger when it was assigned
within in a script, but I couldn't successfully modify it. What's going
on here?
------------------------------
Date: Mon, 25 Aug 2003 04:56:59 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Debugger question
Message-Id: <Xns93E23C7D1C531sdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Derek Goto <dgoto@burntmail.com> wrote in
news:z9ydnSYZqqlxE9SiRTvUqg@ilhawaii.net:
> I was running the perl debugger with arguments "-d -e 1" to test a small
> program. When I assigned a value to the variable $foo, I could use it
> fine, but when I qualified $bar with my, it remained undefined. Same
> with local. Why is this? Does the debugger operate in a different scope
> than main? If so, shouldn't I be able to access those values anyway? I
> could access the value of $bar from the debugger when it was assigned
> within in a script, but I couldn't successfully modify it. What's going
> on here?
It's a limitation inherent in the debugger.
Each expression you enter at the debugger prompt is evaluated in its own
scope. When the expression is finished, the scope goes away. Your
assignment to "my $bar" works, but at the end of the scope $bar goes away,
and when you next type "p $bar" or "x $bar", it's not there any more.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP0ndXGPeouIeTNHoEQKkKQCgzYi+ib0msMI/h4p7uLRW7QMdBhUAn1H+
YHV9TXERaOGVzxlbdLX6gQIb
=wA5Q
-----END PGP SIGNATURE-----
------------------------------
Date: 25 Aug 2003 04:05:07 -0700
From: hawkmoon1972@hotmail.com (Tony)
Subject: Doing a 'mail merge' with RTF files (aka RTF templates)
Message-Id: <c90e5468.0308250305.44de49b5@posting.google.com>
I have a MS Word document with mail merge fields in it.
I've saved it as rich text format (RTF), and now I want to write a
perl program that will take this template file as input, replace the
mail merge fields with data, and then spit out a populated RTF file
for each record.
Is there a module to make this easier? I can see the mail merge fields
in the raw RTF document, but they're complex structures, and I don't
really want to learn the RTF spec in order to know what I should be
replacing in each case.
For example, if I replace the word "address" with a merge field called
"address", this is the extra code that appears in the RTF file:
}{\field{\*\fldinst { MERGEFIELD address \\* MERGEFORMAT }}{\fldrslt
{\lang1024 \'abaddress\'bb}}}{
And it's even more obscure when you have tables, and formatting etc.
I'll take a look at rtf::tokenizer, but my initial assesment is that
it's not quite what I'm after.
Any ideas?
Thanks, Tony
------------------------------
Date: Mon, 25 Aug 2003 12:14:06 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Doing a 'mail merge' with RTF files (aka RTF templates)
Message-Id: <i4n2b.4$Re7.683@news.dircon.co.uk>
In comp.lang.perl.misc Tony <hawkmoon1972@hotmail.com> wrote:
> I have a MS Word document with mail merge fields in it.
>
> I've saved it as rich text format (RTF), and now I want to write a
> perl program that will take this template file as input, replace the
> mail merge fields with data, and then spit out a populated RTF file
> for each record.
>
> Is there a module to make this easier?
I would suggest that you use a templating module such as the Template
Toolkit - there seems to be no need to be parsing the RTF for this
application.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Mon, 25 Aug 2003 09:51:12 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Editing Word documents in Perl (Openoffice Writer or MS Word)
Message-Id: <k_k2b.1$Re7.31@news.dircon.co.uk>
In comp.lang.perl.misc Tony <hawkmoon1972@hotmail.com> wrote:
>
> I want to read and edit openoffice / staroffice writer documents. Does
> anyone know of any modules for that?
>
Native OpenOffice documents are XML, you might want to look at some of
the XML modules on CPAN to assess their suitability to the task.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: 25 Aug 2003 04:26:09 -0700
From: pkvinu@indiatimes.com (Vinod. K)
Subject: Help requird : got a problem with foreach loop???
Message-Id: <bde4ceed.0308250326.4f669f6d@posting.google.com>
Hi everybody,
I have a small query with foreach loop( as well as while loop).
Here is the small script with which i got a problem
----------------------------------------------------
#!/usr/local/perl/5.6.0/bin/perl
my @a=qw/ref txt dat/;
chomp @a;
foreach(@a)
{
my $fl=$_;
if(<*$fl>)
{
chomp $a;
$a=<*$fl>;
print $a,"\n";
}
else
{
print"no files\n";
}
}
-----------------------------------------
O/P of this program(test.pl) :
prompt>test.pl
a.ref
no files
prompt>
--------------------------------------------
Here in the above program, I am trying to list out the files which are
ending with ".ref" or ".txt" or ".dat" extension. But the output I am
getting here is only a file with .ref extension which is first element
of array,@a, even though each one of above said extension files are
existing under a dir from where I ran the this program.
Here .ref is the first element of array,@a. I observed that this
program lists only the files of extension which is there in the first
element of the array,@a and lists only to the maximum of 3 files
eventhough more than 3 files of the same extension are present under
the dirctory. if we change the content of first element to some other
extension, then it will lists files of that extension.
I don't know why it is so??? I am not able understand the logic behind
this foreach loop( and even with while loop too). why it is not
listing files of all the extensions(i.e .dat, .txt, and .ref)???
But if we use unix command, "ls" instead of diamond operator(<>),then
the same above program works fine.
is the probelm with diamond operator or loops???
Please help me out in clearing all my doubts.
Thanks for invaluable time,
- vinod.
------------------------------
Date: Mon, 25 Aug 2003 07:20:15 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help requird : got a problem with foreach loop???
Message-Id: <slrnbkjvnv.fkr.tadmc@magna.augustmail.com>
Vinod. K <pkvinu@indiatimes.com> wrote:
> Here is the small script with which i got a problem
>
>
> #!/usr/local/perl/5.6.0/bin/perl
> my @a=qw/ref txt dat/;
> chomp @a;
> foreach(@a)
> {
> my $fl=$_;
> if(<*$fl>)
> {
> chomp $a;
> $a=<*$fl>;
> print $a,"\n";
> }
> else
> {
> print"no files\n";
> }
> }
Yes. The problem is your code is not indented to show its structure.
> Please help me out in clearing all my doubts.
Please take the time to format your code sensibly if you hope
to get people to volunteer to read it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 25 Aug 2003 07:47:10 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help requird : got a problem with foreach loop???
Message-Id: <slrnbkk1ae.fkr.tadmc@magna.augustmail.com>
Vinod. K <pkvinu@indiatimes.com> wrote:
> I have a small query with foreach loop( as well as while loop).
You problem is not about loops, it is about filename glob()ing.
> my @a=qw/ref txt dat/;
> chomp @a;
Why are you chomp()ing strings without newlines?
> $a=<*$fl>;
Read up on what globbing does when in a scalar context like that.
perldoc -f glob
The glob may return many elements, but your code only looks at
the first one.
Look at the other ones if you want to look at the other ones:
foreach ( <*.$fl> ) {
print "$_\n"
}
> Here in the above program, I am trying to list out the files which are
> ending with ".ref" or ".txt" or ".dat" extension.
> I don't know why it is so???
"Context".
See the section with that same name in perldata.pod.
> is the probelm with diamond operator or loops???
That is not the diamond operator, the diamond operator (<>) has
to do with reading input, not with filename globbing.
That is the filename globbing operator (a different way of
writing the glob() function).
> Thanks for invaluable time,
Here are some one-liners that do what you are trying to do:
perl -e '$_="*.$_" for @ARGV; print "$_\n" for <@ARGV>' ref txt dat
or
perl -e 'print "$_\n" for glob join " *.", "", @ARGV' ref txt dat
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 25 Aug 2003 12:54:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help requird : got a problem with foreach loop???
Message-Id: <bid0tt$498$2@mamenchi.zrz.TU-Berlin.DE>
Vinod. K <pkvinu@indiatimes.com> wrote in comp.lang.perl.misc:
> Hi everybody,
>
>
> I have a small query with foreach loop( as well as while loop).
> Here is the small script with which i got a problem
The loop seems to be one part of your program that works.
> ----------------------------------------------------
>
> #!/usr/local/perl/5.6.0/bin/perl
> my @a=qw/ref txt dat/;
> chomp @a;
> foreach(@a)
> {
> my $fl=$_;
> if(<*$fl>)
> {
> chomp $a;
> $a=<*$fl>;
> print $a,"\n";
> }
> else
> {
> print"no files\n";
> }
> }
The lack of indentation makes this just about unreadable. Most people
take that for a reason to skip the post, but let's see what we got.
There is no "strict" and no "warnings". If some code gives you trouble,
switch them on and see if that changes anything.
> my @a=qw/ref txt dat/;
> chomp @a;
Why chomp @a? There is no way one of the strings could end with a
newline.
> foreach(@a) {
> my $fl=$_;
If you want a named loop variable, name the loop variable:
foreach my $fl ( @a ) {
> if(<*$fl>) {
That glob matches all files that end in "ref" (or "txt", or "dat").
You only want those that end in ".txt" etc. Change the glob to "<*.$fl>.
> chomp $a;
Chomping $a before assigning to it is useless. (Warnings would have
warned about it.) Anyway, the glob doesn't append newlines to filenames,
so the chomp is wrong.
> $a=<*$fl>;
Here you're doing the glob once again. This isn't necessarily wrong,
but it it wasteful. Do the assignment inside the if-condition.
> print $a,"\n";
> } else {
> print"no files\n";
This prints "no files" for each case ("ref", "txt", and "dat") you're
looping over. This may or may not be what you want.
> }
> }
This it what it boils down to:
use strict; use warnings;
my @a=qw/ref txt dat/;
chomp @a;
foreach(@a) {
my $fl=$_;
if( my $a = <*.$fl>) {
chomp $a;
print "$fl: $a\n";
} else {
print"no files\n";
}
}
However, this will still not work right. You are using glob in scalar
context. This means, you'll get only one file each time through. If
there is more than one file with one of the extensions, you'll miss them.
Using glob in list context, and using it with multiple arguments,
simplifies things:
if ( my @files = <*.ref *.txt *.dat> ) {
print "@files\n";
} else {
print "no files\n";
}
Anno
------------------------------
Date: Mon, 25 Aug 2003 09:36:15 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: is my HTML tag stripper up to par?
Message-Id: <jMk2b.7$5o5.3659@news.dircon.co.uk>
In comp.lang.perl.misc Dan Jacobson <jidanni@jidanni.org> wrote:
> Is my HTML tag stripper up to par?
> $ cat striptag
> #!/usr/bin/perl -w
> #usage example: striptag font div < file.html
> read( STDIN, $_, -s STDIN );
> foreach my $tag (@ARGV) { s@</?$tag.*?>@@sig }
> print;
As has already been pointed out this will not work for a lot of cases.
Lest anyone should look at this thread hoping for a working one:
#!/usr/bin/perl -w
use strict;
use HTML::Parser;
my $parser = HTML::Parser->new( text_h => [ sub { print shift; },"dtext" ]);
$parser->parse_file(*STDIN);
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Mon, 25 Aug 2003 12:38:16 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: is my HTML tag stripper up to par?
Message-Id: <87znhx52xx.fsf@mithril.chromatico.net>
>>>>> "Shawn" == Shawn K Quinn <skquinn@xevious.kicks-ass.net> writes:
Shawn> [adding c.i.w.a.tools and removing c.i.w.a.html from
Shawn> followups]
Shawn> Dan Jacobson wrote:
>> Is my HTML tag stripper up to par?
>> [well-intentioned but hopelessly broken code snipped]
Shawn> Looks pretty good to me. This could come in *very* handy
Shawn> when fixing pages with old garbage tags in them.
It could come in very handy, *if it worked*.
* Regular expressions can't handle arbitrary levels of nesting. Not
only does HTML expect arbitrary levels of nesting --
<b><i>foo</i></b> -- most common browsers *also* will allow for
arbitrary broken levels of nesting -- <b><i>foo</b></i> -- and a
regular expression is hopeless with that.
* You can't simply use /<.*?>/ or variations thereon to find tags, for
all the reasons outlined in the Perl FAQ.
This *is* a FAQ, and it's something that novice Perl programmers get
wrong constantly.
Charlton
--
cwilbur at chromatico dot net
cwilbur at mac dot com
------------------------------
Date: Mon, 25 Aug 2003 12:47:34 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Mail::Audit (removing attachment fails on "broken path")
Message-Id: <20030825134748.2cf6c112.ian@WINDOZEdigiserv.net>
Morning all =)
Thanks to a post the other day I read here, IIRC.. by Eric(?) (apologies
if wrong) regarding an article about Mail::Audit.. I went to have a
look. It looks like a great module and I've had some "fun" playing
around with its various capabilities, but have struck one problem...
removing attachments. The error I receive is:
<tk@MUNGEDhybris.digiserv.net>: Command died with status 255:
"~/bin/dFilter". Command output: fileparse(): need a valid pathname
at /usr/lib/perl5/site_perl/5.8.0/Mail/Audit.pm line 398
My thinking is this has an issue with the file being a part of
/var/mail/tk rather than an individual file as such for the attachment..
but I'm really not sure. This would be great for stripping worms et
al. on delivery but allowing the actual mail through etc for users.
Has anyone else any experience with this, or know of a workaround / fix
/ kick in the right direction for doing it properly? I have spent a
while searching google and found a few related articles but not a great
deal.. and have checked perldoc Mail::Audit(::Attach) but the code in
the perldoc
The code I have (with irrelevant parts snipped) is (quick / hacked
code):
#!/usr/bin/perl
use strict;
use warnings;
use Mail::Audit qw(Attach);
my $mail = Mail::Audit->new;
## Attachment: filter
my @filter_attachment_tag = (
'details.pif'
);
my @filter_attachment_desc = (
'Sobig.f@mm'
);
my $num_attachments = $mail->num_attachments;
my $attachments = $mail->attachments;
## Strip attachment(s)
my $a_ctr = 0;
foreach (@$attachments) {
foreach my $fa (@filter_attachment_tag) {
if ($_->filename =~ m|$fa|i) {
$mail->replace_header(
'Subject', '[dFilter - ' .
$filter_attachment_desc[$a_ctr] . ' warning!] ' .
$mail->subject
);
# $_->remove;
# ^^^^^^^^^^^ causes error
# same as using remove_attachments()
}
$a_ctr++;
}
}
$mail->make_singlepart; # If possible
$mail->accept();
Any help / advice etc more than welcomed =)
TIA.
Regards,
Ian
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
------------------------------
Date: Mon, 25 Aug 2003 05:41:58 GMT
From: die@spammer.die (Mark Healey)
Subject: Re: Passing a hash to a function
Message-Id: <VP2SpNyJrzMZ-pn2-1KxgZup4vjVz@adsl-63-207-135-60.dsl.sndg02.pacbell.net>
On Sun, 24 Aug 2003 07:01:09 UTC, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:
> Also sprach Mark Healey:
>
> > I can't seem to find in in my perl book. I'd like to pass hashes to
> > functions
> >
> > #!/usr/bin/perl -wT
> >
> > my %someHash;
> >
> > $someHash{'one'} = "1";
> > $someHash{'two'} = "2";
> > $someHash{'three'} = "3";
> >
> >
> > sub onsiestwosies
> > {
> > do stuff with %someHash
> > }
> >
> > I'd simply like to pass %someHash to onesiestwosies.
>
> Under well defined circumstances, you can simply do it like this:
>
> sub func {
> my %hash = @_;
> }
> ...
> func(%someHash);
>
> The problem with that is that it a) copies the hash (which may be
> inefficient if it is large) and b) you can't pass more than one list-ish
> variable to the subroutine (perl flattens all arguments passed into one
> large list). So best is to use a reference:
>
> sub func {
> my ($hash1_ref, $hash2_ref) = @_;
> # do the dereferencing
> my %hash1 = %$hash1_ref;
> ...
> }
> ...
> func(\%someHash1, \%someHash2);
>
> See perlreftut.pod and perlref.pod if you aren't acquainted with
> references. All about subroutines (including how to pass arguments and
> access them), can be found in perlsub.pod.
>
> Not sure whether you are familiar with the perldocs. You only mention a
> book. The documentation of Perl is often more suitable for looking up such
> things. See 'perldoc perl' for a list of available manpages and 'perldoc
> perldoc' on how to access the Perl documentation.
Thanks. Now I have to figure out how flexible I want the function to
be.
--
Mark Heaely
marknews(at)healeyonline(dot)com
------------------------------
Date: Sun, 24 Aug 2003 23:20:29 +0200
From: Daniel Hofmann <usenet@shadowprint.de>
Subject: Re: regexp mystery
Message-Id: <86oeyeeorm.fsf@shadowprint.de>
"John Davison" <compiler@bahamutirc.net> writes:
> I want to match the first N letters after the period after the
> number N. The regular expression has to be built first, so it has
> to be something like /$regexp/.
>
> Here's what I was working with:
> $regexp = '(\\d+)(?{ $reg_1 = $^N })\\.(.{$reg_1})';
>
> where $reg_1 gets the number, but I can't make it become the
> quantifier later. I tried the (??{ $reg_1 }) but I couldn't get
> that to go either. I get the feeling that $reg_1 never gets
> evaluated.
If you want expressions in strings to be evaluated you have to use
double quotes. But i don't understand your regex at all. The following
works for me:
#!/usr/bin/perl -w
use strict;
my $test = "6.hello everybody";
(my $number) = ( $test =~ /^(\d+)\./);
if ($test =~ /^\d+\.(.{$number})/) {
print "$1\n";
}
HTH,
Daniel.
------------------------------
Date: 25 Aug 2003 08:26:50 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regexp mystery
Message-Id: <slrnbkji2a.b2d.abigail@alexandra.abigail.nl>
Daniel Hofmann (usenet@shadowprint.de) wrote on MMMDCXLV September
MCMXCIII in <URL:news:86oeyeeorm.fsf@shadowprint.de>:
## "John Davison" <compiler@bahamutirc.net> writes:
##
## > I want to match the first N letters after the period after the
## > number N. The regular expression has to be built first, so it has
## > to be something like /$regexp/.
## >
## > Here's what I was working with:
## > $regexp = '(\\d+)(?{ $reg_1 = $^N })\\.(.{$reg_1})';
## >
## > where $reg_1 gets the number, but I can't make it become the
## > quantifier later. I tried the (??{ $reg_1 }) but I couldn't get
## > that to go either. I get the feeling that $reg_1 never gets
## > evaluated.
##
## If you want expressions in strings to be evaluated you have to use
## double quotes. But i don't understand your regex at all. The following
## works for me:
##
## #!/usr/bin/perl -w
##
## use strict;
##
## my $test = "6.hello everybody";
## (my $number) = ( $test =~ /^(\d+)\./);
## if ($test =~ /^\d+\.(.{$number})/) {
## print "$1\n";
## }
That fails on '123.foo.3.bar'.
Abigail
--
sub f{sprintf$_[0],$_[1],$_[2]}print f('%c%s',74,f('%c%s',117,f('%c%s',115,f(
'%c%s',116,f('%c%s',32,f('%c%s',97,f('%c%s',0x6e,f('%c%s',111,f('%c%s',116,f(
'%c%s',104,f('%c%s',0x65,f('%c%s',114,f('%c%s',32,f('%c%s',80,f('%c%s',101,f(
'%c%s',114,f('%c%s',0x6c,f('%c%s',32,f('%c%s',0x48,f('%c%s',97,f('%c%s',99,f(
'%c%s',107,f('%c%s',101,f('%c%s',114,f('%c%s',10,)))))))))))))))))))))))))
------------------------------
Date: Mon, 25 Aug 2003 09:46:49 GMT
From: f_baggins80@hotmail.com (Helgi Briem)
Subject: Re: What ever happened to comp.lang.perl ?
Message-Id: <3f49da9c.247644053@News.CIS.DFN.DE>
On Fri, 22 Aug 2003 17:49:34 -0400, "Matt Garrish"
<matthew.garrish@sympatico.ca> wrote:
>My question is: has anyone considered a c.l.learn.perl group? (Or anything
>similar?) I'm aware that learn.perl.org has mailing lists, but I suspect
>that much of the unwanted posting in this group would be more quickly
>diverted were posters presented the option of posting to .learn.perl or
>.perl.misc when looking for a group.
Newcomers wanting to learn are more than welcome on
comp.lang.perl,misc and are uniformly warmly treated.
What is unwelcomes is questions about CGI, Unix, sendmail,
shell scripting, awk, Javascript, web server configuration,
yada yada yada.
Oh, and top-posting.
------------------------------
Date: Mon, 25 Aug 2003 12:00:04 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: What ever happened to comp.lang.perl ?
Message-Id: <8Tm2b.3$Re7.683@news.dircon.co.uk>
Hudson <none@example.com> wrote:
> I would suggest:
>
> comp.lang.perl - pure perl (no modules)
To cater for all the particular restrictions people might want to place
on their code might I suggest more granularity:
comp.lang.perl.no-modules
comp.lang.perl.no-strict
comp.lang.perl.no-foreach
comp.lang.perl.four
and so forth.
> comp.lang.perl.cgi - all things cgi in perl
I would suggest also
comp.lang.perl.munging-energis-cdrs-for-billing-purposes
comp.lang.perl.parsing-biztalk-xml-data
comp.lang.perl.managing-foundry-switch-configuration
Which are things I do with Perl more frequently than applications that use
the CGI.
> comp.lang.perl.nix - perl on unix
Actually I think that:
comp.lang.perl.aix
comp.lang.perl.amiga
comp.lang.perl.apollo
comp.lang.perl.beos
comp.lang.perl.bs2000
comp.lang.perl.ce
comp.lang.perl.cygwin
comp.lang.perl.dgux
comp.lang.perl.dos
comp.lang.perl.epoc
comp.lang.perl.freebsd
comp.lang.perl.hpux
comp.lang.perl.hurd
comp.lang.perl.irix
comp.lang.perl.machten
comp.lang.perl.macos
comp.lang.perl.micro
comp.lang.perl.mint
comp.lang.perl.mpeix
comp.lang.perl.netware
comp.lang.perl.os2
comp.lang.perl.os390
comp.lang.perl.os400
comp.lang.perl.plan9
comp.lang.perl.qnx
comp.lang.perl.solaris
comp.lang.perl.tru64
comp.lang.perl.uts
comp.lang.perl.vmesa
comp.lang.perl.vms
comp.lang.perl.vos
comp.lang.perl.win32
would be better if one was going to take that to it's logical conclusion.
I mean we wouldn't want anyone in particular to feel excluded.
I think you might want to get started on the RFDs now.
/J\
--
Jonathan Stowe |
<http://www.gellyfish.com> | This space for rent
|
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5422
***************************************