[22875] in Perl-Users-Digest
Perl-Users Digest, Issue: 5096 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 9 00:05:52 2003
Date: Sun, 8 Jun 2003 21:05:06 -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 Sun, 8 Jun 2003 Volume: 10 Number: 5096
Today's topics:
Formatting and encoding of words (slash)
loop problems (david)
Re: loop problems <jkeen@concentric.net>
Re: loop problems <ndronen@io.frii.com>
Re: loop problems <ndronen@io.frii.com>
Re: loop problems (david)
Re: loop problems (Tad McClellan)
Re: Newbie: Looking for MP3 script to trucate/fade my m <gmiller@NOTforSPAM.gregmiller.net>
newbie: will a big array hurt performance? <gejun@cs.iastate.edu>
Re: newbie: will a big array hurt performance? <pilsl_usenet@goldfisch.at>
Re: newbie: will a big array hurt performance? <gejun@cs.iastate.edu>
Re: newbie: will a big array hurt performance? <pilsl_usenet@goldfisch.at>
Re: newbie: will a big array hurt performance? (Tad McClellan)
Re: newbie: will a big array hurt performance? <gejun@cs.iastate.edu>
Re: newbie: will a big array hurt performance? <usenet@dwall.fastmail.fm>
Re: newbie: will a big array hurt performance? <ndronen@io.frii.com>
Pack/Unpack with templates 'p' and 'P' <ptrck.lhrtr@NOSPAMworldnet.att.net>
Re: Perl and Java (Charles DeRykus)
Re: Perl exam - fair or not? (Tramm Hudson)
Re: Perl exam - fair or not? (Jay Tilton)
Re: Perldoc formatting on Linux <s.patterson@freeuk.com>
Re: Perldoc formatting on Linux <grazz@pobox.com>
Re: Unusual Can't load fail (web only) <kalinabears@hdc.com.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jun 2003 20:35:44 -0700
From: satishi@gwu.edu (slash)
Subject: Formatting and encoding of words
Message-Id: <30fe9f1e.0306081935.638e74e4@posting.google.com>
I apologize for the simplicity of this question in advance as I am new
to Perl.
I have a table of words generated dynamically from Text::Table CPAN
module. I am trying to select certain columns.
Here is my code:
use CPAN;
use Text::Table;
my @words = qw( Use this form to post your message...);
my $n_cols = 3;
my $col = { align => 'left'};
my $tb = Text::Table->new( ( $col) x $n_cols);
my @stack = ( '*' ) x $n_cols;
for my $word ( @words ) {
shift @stack;
push @stack, $word;
$tb->add( @stack);
}
print $tb;
How do I select the columns? Let's say, if the columns had titles and
they were following (but they do not have column titles currently): a,
b, c
and I wanted the following output:
b, a b, c
I tried using the select() method from the module specification but I
guess I wasn't using it correctly. For whatever column i chose,
my $sub = select ($b, $a, $b, $c), the output would be always be 4
copies of column a. Can someone please help me?
Secondly, can I also sort table columns? I didn't see this in the
specification. For instance, if I wanted to sort column a and column c
based on their "value", i.e., whatever their memory encoding
representation value is. Which brings me to the next point...How is a
Perl string stored in memory? Can I write a script so that words are
encoded in binary? If I do that then the string comparisons will be
faster, right? So, can I encode them in base64 or any base I want? I
guess, all I would have to do is generate a lookup key or table of the
alphabet. Any suggestions would be greatly appreciated.
Much thanks,
Slash
------------------------------
Date: 8 Jun 2003 12:46:23 -0700
From: dwlepage@yahoo.com (david)
Subject: loop problems
Message-Id: <b09a22ae.0306081146.7df42ebe@posting.google.com>
I am stuck. I am trying to take a list of files that I find in a
specified directory, (/export/home) and write them to a tied hash
using DB_FILE. What I want to do in the foreach loop, is check to see
if a new file has appeared, or an already hashed file has disappeared.
foreach my $file (@files) {
open (FILE, "$dir/$file") || die "Can't open $!";
close FILE;
if (exists $MD5hash{$file}) {
print "$file exists\n"; }
else {
print SENDMAIL "$file was not originally hashed! Was
this file a
dded?\n\n";
}
if ($MD5hash{$file} ne $md5) {
print SENDMAIL "File digest has changed for :
$file\n";
print SENDMAIL "Hash was : $MD5hash{$file}\n";
print SENDMAIL "Hash is : $md5\n\n";
}
}
print SENDMAIL "All other files look good in
$dir\!\n";
close(SENDMAIL);
untie %MD5hash;
When I run this and a new file called 'a7.log' appears in this
directory:
a7.log 96d45fab15bc39dfee1f6e4b3e81e208
Use of uninitialized value at chkmd5.pl line 48.
Use of uninitialized value at chkmd5.pl line 50.
How can I also verify that a file doesn't disappear from this dir? Do
I need to iterate over the array of filenames and compare this to the
hash? or?
Thanks for any pointers.
D
------------------------------
Date: 08 Jun 2003 22:14:17 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: loop problems
Message-Id: <bc0cfp$8qr@dispatch.concentric.net>
"david" <dwlepage@yahoo.com> wrote in message
news:b09a22ae.0306081146.7df42ebe@posting.google.com...
> I am stuck. I am trying to take a list of files that I find in a
> specified directory, (/export/home) and write them to a tied hash
> using DB_FILE. What I want to do in the foreach loop, is check to see
> if a new file has appeared, or an already hashed file has disappeared.
>
> foreach my $file (@files) {
> open (FILE, "$dir/$file") || die "Can't open $!";
> close FILE;
Am I reading this correctly? You're opening a filehandle, not doing
anything with it, then closing it immediately. Why?
------------------------------
Date: 09 Jun 2003 02:46:31 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: loop problems
Message-Id: <3ee3f507$0$206$75868355@news.frii.net>
James E Keenan <jkeen@concentric.net> wrote:
JEK> "david" <dwlepage@yahoo.com> wrote in message
JEK> news:b09a22ae.0306081146.7df42ebe@posting.google.com...
>> I am stuck. I am trying to take a list of files that I find in a
>> specified directory, (/export/home) and write them to a tied hash
>> using DB_FILE. What I want to do in the foreach loop, is check to see
>> if a new file has appeared, or an already hashed file has disappeared.
>>
>> foreach my $file (@files) {
>> open (FILE, "$dir/$file") || die "Can't open $!";
>> close FILE;
JEK> Am I reading this correctly? You're opening a filehandle, not doing
JEK> anything with it, then closing it immediately. Why?
It looks like he's checking to see whether the file exists. If so,
he should just use -f.
Regards,
Nicholas
--
"Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: 09 Jun 2003 02:59:07 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: loop problems
Message-Id: <3ee3f7fb$0$206$75868355@news.frii.net>
david <dwlepage@yahoo.com> wrote:
d> I am stuck. I am trying to take a list of files that I find in a
d> specified directory, (/export/home) and write them to a tied hash
d> using DB_FILE. What I want to do in the foreach loop, is check to see
d> if a new file has appeared, or an already hashed file has disappeared.
d> foreach my $file (@files) {
d> open (FILE, "$dir/$file") || die "Can't open $!";
d> close FILE;
As the other poster asked, what do you hope to accomplish by
doing open(), then close(), if you don't do anything with the
filehandle? If you're just testing for existence, use -f.
d> if (exists $MD5hash{$file}) {
d> print "$file exists\n"; }
d> else {
That's a strange way to place your braces.
d> print SENDMAIL "$file was not originally hashed! Was
d> this file a
d> dded?\n\n";
d> }
d> if ($MD5hash{$file} ne $md5) {
d> print SENDMAIL "File digest has changed for :
d> $file\n";
d> print SENDMAIL "Hash was : $MD5hash{$file}\n";
d> print SENDMAIL "Hash is : $md5\n\n";
d> }
d> }
d> print SENDMAIL "All other files look good in
d> $dir\!\n";
d> close(SENDMAIL);
d> untie %MD5hash;
d> When I run this and a new file called 'a7.log' appears in this
d> directory:
d> a7.log 96d45fab15bc39dfee1f6e4b3e81e208
d> Use of uninitialized value at chkmd5.pl line 48.
d> Use of uninitialized value at chkmd5.pl line 50.
You don't say which of your lines of code are 48 and 50, but if the
unitialized value warnings come from the code you posted, I'd say
that the hash key $MD5hash{$file} doesn't exist. The flow of the
loop is such that the block beginning with:
if ($MD5hash{$file} ne $md5) {
runs even if the test for the existence of the hash key fails earlier
in the loop.
Regards,
Nicholas
--
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: 8 Jun 2003 20:00:59 -0700
From: dwlepage@yahoo.com (david)
Subject: Re: loop problems
Message-Id: <b09a22ae.0306081900.71d5fc61@posting.google.com>
"James E Keenan" <jkeen@concentric.net> wrote in message news:<bc0cfp$8qr@dispatch.concentric.net>...
> "david" <dwlepage@yahoo.com> wrote in message
> news:b09a22ae.0306081146.7df42ebe@posting.google.com...
> > I am stuck. I am trying to take a list of files that I find in a
> > specified directory, (/export/home) and write them to a tied hash
> > using DB_FILE. What I want to do in the foreach loop, is check to see
> > if a new file has appeared, or an already hashed file has disappeared.
> >
> > foreach my $file (@files) {
> > open (FILE, "$dir/$file") || die "Can't open $!";
> > close FILE;
>
> Am I reading this correctly? You're opening a filehandle, not doing
> anything with it, then closing it immediately. Why?
You are right. I dont know why I did that. I changed things a bit and
here is what I have now:
if ($opt_check) {
opendir(DIR, $dir) || die "Cannot open Directory : $!\n";
my @files = grep {-f} readdir(DIR);
close (DIR);
open(SENDMAIL, "|/usr/sbin/sendmail -oi -t") ||
die "Find the path to your sendmail executable : $!\n";
print SENDMAIL "To: dlepage\@yahoo.com\n";
print SENDMAIL "From: MD5hasher\@hackthis.com\n";
print SENDMAIL "Subject: File Integrity Check\n";
foreach my $file (@files) {
open (FILE, "$dir/$file") || die "Cannot open file : $!\n";
my $md5 = Digest::MD5->new->addfile(*FILE)->hexdigest;
close(FILE);
if (!(exists $MD5hash{$file})) {
print SENDMAIL "$file was not originally
hashed! Was thi
s file added?\n";
print SENDMAIL "Hash is : $md5\n\n";
}
elsif ($MD5hash{$file} ne $md5) {
print SENDMAIL "File digest has changed for :
$file\n";
print SENDMAIL "Hash was : $MD5hash{$file}\n";
print SENDMAIL "Hash is : $md5\n\n";
}
}
print SENDMAIL "All other files look good in
$dir\!\n";
}
close(SENDMAIL);
Everything seems to work fine this way. Now I match two conditions-
when a file is added, and when a hash has changed. I want to determine
when a file was removed. . Ill keep trying.
Thanks,
d
------------------------------
Date: Sun, 8 Jun 2003 22:50:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: loop problems
Message-Id: <slrnbe80vu.g7o.tadmc@magna.augustmail.com>
david <dwlepage@yahoo.com> wrote:
> "James E Keenan" <jkeen@concentric.net> wrote in message news:<bc0cfp$8qr@dispatch.concentric.net>...
>> "david" <dwlepage@yahoo.com> wrote in message
>> news:b09a22ae.0306081146.7df42ebe@posting.google.com...
> opendir(DIR, $dir) || die "Cannot open Directory : $!\n";
> my @files = grep {-f} readdir(DIR);
my @files = grep {-f "$dir/$_"} readdir(DIR);
You should read the documentation for the functions that you use.
perldoc -f readdir
...
If you're planning to filetest the return values
out of a "readdir", you'd better prepend the
directory in question. Otherwise, because we
didn't "chdir" there, it would have been testing
the wrong file.
> open (FILE, "$dir/$file") || die "Cannot open file : $!\n";
At least you remembered it there. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 08 Jun 2003 18:06:32 GMT
From: Greg Miller <gmiller@NOTforSPAM.gregmiller.net>
Subject: Re: Newbie: Looking for MP3 script to trucate/fade my mp3 collection to 20sec ea.
Message-Id: <9lu6evg8usmmun7kdk9fk72isc4iknquro@4ax.com>
On Sat, 07 Jun 2003 10:56:07 -0400, Stephen Hurrell
<hurrells@tbaytel.net> wrote:
>I am looking for a perl shell script (or ideas, suggestions) about how
>to write a perl script that can be run from a cronjob to go through a
>growing directory of MP3's and truncate, and possibly fade, them to
>perhaps about 20 secs each (adjustable). Yes there would also be many
>already "adjusted" mp3's in there. This program would only work on the
>larger/newer mp3 files obviously.
There are plenty of MP3 splitters out there already, writing a
new one would be a waste of time. Just write a script which reads the
directory and passes the right command line options via a system()
call.
Greg Miller (gmiller at gregmiller dot net)
http://www.gregmiller.net
http://www.net-chess.com
------------------------------
Date: Sun, 08 Jun 2003 14:48:22 -0500
From: Ge Jun <gejun@cs.iastate.edu>
Subject: newbie: will a big array hurt performance?
Message-Id: <3EE39306.5080407@cs.iastate.edu>
Hi Everyone,
I have a file to read and to deal with each line. I have two approach
to do it, one is using a scalar and to read lines one by one, while the
other way is to use an arrry @line. My question is: if the file is big,
@line should have a big buffer, will this hurt performance?
##### way 1: use scalar $file
$file = 'test.txt';
open(INFO, $file);
while ($lines = <INFO>) {
...
}
close(INFO);
#### way 2: use array @file
$file = 'test.txt';
open(INFO, $file);
@line = <INFO>;
close(INFO);
foreach $oneitem (@line) {
...
}
Thank you in advance!
Jun Ge
------------------------------
Date: Sun, 8 Jun 2003 22:13:44 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3ee399cd$1@e-post.inode.at>
Ge Jun wrote:
> Hi Everyone,
>
> I have a file to read and to deal with each line. I have two approach
> to do it, one is using a scalar and to read lines one by one, while the
> other way is to use an arrry @line. My question is: if the file is big,
> @line should have a big buffer, will this hurt performance?
>
I dont see any advantage in way2. You only fill up the memory. If you need
to access any line only once way1 is the best way.
If you need to access the lines more than once and you need them to keep in
memory for higher speed then it will need the amount of memory the file
actually has.
best,
peter
ps: if you want to read the whole file at once there are better ways than
way2: you can alter $/ for reading the whole file at once. (see
http://www2.goldfisch.at/knowledge/231)
>
> ##### way 1: use scalar $file
> $file = 'test.txt';
> open(INFO, $file);
> while ($lines = <INFO>) {
> ...
> }
> close(INFO);
>
>
>
> #### way 2: use array @file
> $file = 'test.txt';
> open(INFO, $file);
> @line = <INFO>;
> close(INFO);
>
> foreach $oneitem (@line) {
> ...
> }
>
>
> Thank you in advance!
>
> Jun Ge
>
>
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Sun, 08 Jun 2003 15:35:47 -0500
From: Ge Jun <gejun@cs.iastate.edu>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3EE39E23.1090009@cs.iastate.edu>
peter pilsl wrote:
> I dont see any advantage in way2. You only fill up the memory. If you need
> to access any line only once way1 is the best way.
>
> If you need to access the lines more than once and you need them to keep in
> memory for higher speed then it will need the amount of memory the file
> actually has.
Yes, after the first time I scan the file, I will need to access several
lines of it. That's why I want to use @line to store it.
>
> best,
> peter
>
> ps: if you want to read the whole file at once there are better ways than
> way2: you can alter $/ for reading the whole file at once. (see
> http://www2.goldfisch.at/knowledge/231)
------------------------------
Date: Sun, 8 Jun 2003 23:18:43 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3ee3a90c@e-post.inode.at>
Ge Jun wrote:
>
> Yes, after the first time I scan the file, I will need to access several
> lines of it. That's why I want to use @line to store it.
>
So just store the lines that you will need later. If you need all lines
later (or just dont know which one you'll need later) then you need to
consider if speed is more important or if memusage is a problem.
I dont know about your problem and I dont know how big the files are you
need to deal with.
If speed is an issue and memusage a problem then you might also think about
compressing the lines in memory using standard perl-modules from cpan.
For testing several different algorithms the Time::HiRes - module from CPAN
is very useful. You can very easily create testsuites and just measure how
much time it tooks to perform a certain task.
As soon as your system run out of memory and need to swap pages to disk
this will hurt performance very badly.
Often also one can change the algorithm so that you dont need to store all
lines in memory.
best,
peter
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Sun, 8 Jun 2003 16:26:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <slrnbe7ah0.fee.tadmc@magna.augustmail.com>
Ge Jun <gejun@cs.iastate.edu> wrote:
> My question is: if the file is big,
> @line should have a big buffer, will this hurt performance?
Yes.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 08 Jun 2003 16:51:27 -0500
From: Ge Jun <gejun@cs.iastate.edu>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3EE3AFDF.40504@cs.iastate.edu>
Thank you very much! I got it.
Have a good weekend :)
Jun
peter pilsl wrote:
> Ge Jun wrote:
>
>
>>Yes, after the first time I scan the file, I will need to access several
>>lines of it. That's why I want to use @line to store it.
>>
>
>
> So just store the lines that you will need later. If you need all lines
> later (or just dont know which one you'll need later) then you need to
> consider if speed is more important or if memusage is a problem.
> I dont know about your problem and I dont know how big the files are you
> need to deal with.
>
> If speed is an issue and memusage a problem then you might also think about
> compressing the lines in memory using standard perl-modules from cpan.
>
> For testing several different algorithms the Time::HiRes - module from CPAN
> is very useful. You can very easily create testsuites and just measure how
> much time it tooks to perform a certain task.
>
> As soon as your system run out of memory and need to swap pages to disk
> this will hurt performance very badly.
>
> Often also one can change the algorithm so that you dont need to store all
> lines in memory.
>
> best,
> peter
>
>
>
------------------------------
Date: Sun, 08 Jun 2003 23:19:08 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <Xns9394C48311B3dkwwashere@216.168.3.30>
peter pilsl <pilsl_usenet@goldfisch.at> wrote:
> For testing several different algorithms the Time::HiRes - module
> from CPAN is very useful. You can very easily create testsuites and
> just measure how much time it tooks to perform a certain task.
Benchmark.pm is quite useful for this, too. :-)
It's a standard module, comes with Perl.
------------------------------
Date: 09 Jun 2003 03:11:13 GMT
From: Nicholas Dronen <ndronen@io.frii.com>
Subject: Re: newbie: will a big array hurt performance?
Message-Id: <3ee3fad1$0$206$75868355@news.frii.net>
Ge Jun <gejun@cs.iastate.edu> wrote:
GJ> peter pilsl wrote:
>> I dont see any advantage in way2. You only fill up the memory. If you need
>> to access any line only once way1 is the best way.
>>
>> If you need to access the lines more than once and you need them to keep
>> in memory for higher speed then it will need the amount of memory the file
>> actually has.
GJ> Yes, after the first time I scan the file, I will need to access several
GJ> lines of it. That's why I want to use @line to store it.
If you want to do *some* read-ahead, then something like this might.
work. I don't know if it has any pitfalls.
#!/usr/bin/perl -w
$|++;
use strict;
use IO::File;
my $f = new IO::File "< /etc/passwd";
die $! unless defined $f;
while (<$f>) {
my @d;
# Arbitrary condition to check whether read-ahead is needed.
if (/^root:/) {
# Grab two lines after root's. This too is arbitrary.
@d[0,1] = <$f>, <$f>;
# Do stuff with @d.
} else {
# No read-ahead. Do something just with $_.
}
}
Regards,
Nicholas
--
"Meanings are another story." http://www.ifas.org/wa/glossolalia.html
------------------------------
Date: Sun, 08 Jun 2003 21:22:07 GMT
From: thud <ptrck.lhrtr@NOSPAMworldnet.att.net>
Subject: Pack/Unpack with templates 'p' and 'P'
Message-Id: <3EE3A72A.897AAE1A@NOSPAMworldnet.att.net>
Programming hobbyist studying the pack/unpack functions wrote the
following:
$s = pack("Csss", 65, 0x1234, 0x1235, 0x1236);
$r = pack("p", $s);
@a = unpack("asss", unpack("p", $r));
print "@a\n";
As I understand it, $s is the address of the string, and $r is a pointer
to the string. I then tried the 'P' template, and after many hours came
up with
$s = pack("Csss", 65, 0x1234, 0x1235, 0x1236);
$r = pack("PP", $s, $s + 1);
@a = unpack("asss", unpack("P*", $r));
print "@a\n";
Is $s now a structure (like struct in C), and $r a pointer to the
structure?
Would the second pack be considered pointer arithmetic as in C?
Why did I need a 2nd 'P' in the second pack and $s + 1?
Why did I need the '*' in the unpack?
Could someone explain the code clearly to a layman, and also provide
short code examples of the 'p' and 'P' templates? I grepped through
the Perl lib and found nothing.
--
"I'm thankful to women for one thing- they drove me to drink."
--W.C. Fields
------------------------------
Date: Mon, 9 Jun 2003 03:10:39 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Perl and Java
Message-Id: <HG725r.4In@news.boeing.com>
In article <G2HEa.3750$0d7.111221@newsfep4-glfd.server.ntli.net>,
Dave <noemail@test.com> wrote:
>Hi,
>
>I would be interested in creating a Java program that would be able to read
>in a Perl dbm database, and display the contents in a Java Swing GUI.
>
>Is it possible to create a wrapper of any sort that would allow the Java
>program to make a call to the Perl program ( to read a specified database ),
>which would then pass the data (say in a text format) to the Java program,
>which could then process it and display it in the Swing GUI ?
>
>AFAIK there is no direct support for Perl dbm databases in Java?
>
>There are also other reasons why I would like to do the GUI in Java and not
>Perl TK.
>
JPL (Java Perl Lingo) - the Java Perl cross compiler written by
Larry with a dash of RMI may well do what you need. For instance,
you can automagically convert a Perl string into a Java byte
array once you've pulled something from the DBM. JPL's been
opensourced and is distributed with Perl 5.8.0.
There may be some sample doc chapters at the O'Reilly site or just
pick up their "Perl Resource Kit" for the full monty.
--
Charles DeRykus
------------------------------
Date: Sun, 8 Jun 2003 22:54:21 +0000 (UTC)
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Perl exam - fair or not?
Message-Id: <bc0eqt$lcn$1@iruka.swcp.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> anon <> wrote:
> > [...]
> > 28. Which are valid methods of turning on call-by-value?
> > (a) Using the local function.
> > (b) Using the my function.
> > (c) Using the values function.
> > (d) Using the & symbol to call the subroutine.
>
> There is no correct answer for that question either.
>
> call-by-value is *impossible* in Perl, so you cannot "turn it on",
> though you _can_ get the _effect_ of call-by-value by making a copy
> and operating only on the copy.
And neither 'local' nor 'my' are functions. They are keywords that
modify the storage class of variables. I can't imagine a serious
teacher of C asking students if "using the static function" is a valid
method of creating a private variable that holds its value between
function calls. It seems to me that calling 'my' and 'local' functions
indicates a misunderstanding of Perl.
I agree with Tassilo's post <bbukip$kg9$1@nets3.rz.RWTH-Aachen.DE> that
this indicates that the author of the test does not understand that
Perl does things differently than other languages. However, not every
thing is different; they both have storage class modifiers.
Trammell
--
-----|----- hudson@osresearch.net W 240-283-1700
*>=====[]L\ hudson@rotomotion.com M 505-463-1896
' -'-`- http://www.swcp.com/~hudson/ KC5RNF
------------------------------
Date: Mon, 09 Jun 2003 00:05:24 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl exam - fair or not?
Message-Id: <3ee3cd1b.436036176@news.erols.com>
On Sat, 07 Jun 2003 13:45:24 -0700, anon <> wrote:
: 29. The subs function allows you to override built-in Perl functions
: (true/false).
s/function/pragma/;
------------------------------
Date: 8 Jun 2003 19:01:17 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: Perldoc formatting on Linux
Message-Id: <slrnbe71vt.gm.s.patterson@bloodnok.localdomain>
On Sun, 8 Jun 2003 17:29:13 +0000 (UTC), David Efflandt wrote:
> Something is converting the ANSI escape sequences to text instead of
> passing them on as escape sequences. Which Linux distro and did it always
> do that or did or did you change something? Do you have a similar problem
> with 'man perl' or color 'ls' output? What is your PAGER?
That reminds me, for each page in perldoc (apart from -q and -f) you
can use man instead of perldoc (assuming man works right).
--
Stephen Patterson http://www.lexx.uklinux.net http://patter.mine.nu
steve@SPAM.lexx.uklinux.net remove SPAM to reply
Linux Counter No: 142831 GPG Public key: 252B8B37
Last one down the pub's an MCSE
------------------------------
Date: Mon, 09 Jun 2003 00:43:18 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Perldoc formatting on Linux
Message-Id: <GKQEa.51112$ca5.4526@nwrdny02.gnilink.net>
Mina Naguib <spam@thecouch.homeip.net> wrote:
> S. Anthony Sequeira wrote:
>>
>> perldoc doesn't seem display doc pages correctly. I have tried a few
>> things, including changing the terminal type. It still behaves the same
>> for TERM = linux, vt100 and xterm. nroff is available (symlink to groff).
>> ESC[1mNAMEESC[0m
>> perl - Practical Extraction and Report Language
> The ESC[xyz stuff are ANSI escape sequences. They're supposed to be
> caught by your terminal emulator and acted on (move cursor, clear screen,
> change color, bold, etc...) not displayed.
I'm not sure where the configuration problem would be, but our OP
can turn off color escapes with:
$ export PERLDOC="-n 'nroff -c'"
--
Steve
------------------------------
Date: Mon, 9 Jun 2003 06:02:58 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Unusual Can't load fail (web only)
Message-Id: <3ee3979c$0$1202@echo-01.iinet.net.au>
"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote
>
> As you're well aware of in the Win32 world :), it can be tricky mixing
> and matching binaries (in this case, from rpms). From what I understand,
> Mike, the original poster, built DBD::mysql himself, and the script
> ran fine from the command line, but not from the web. This may be
> due to the web environment not seeing some external libraries that
> the command-line environment sees.
I'd have to agree - that seems more feasible than what I initially
suggested.
>It might also be that the web
> version is using an older DBD::mysql from the Perl rpm - the error
> referenced /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/,
> whereas CPAN.pm might have installed things under something like
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/.
>
Not so sure about that one. Since DBD::mysql bootstraps its $VERSION I would
expect a version mismatch error, rather than a "Can't load ...".
Then again, if the "other" perl lib that is found happens to be the same
version, but is in some way broken, you *could* get the "Can't load ..."
error.
Hmm ... there comes a point where one should cease to speculate, and I think
I may well have reached (or even proceeded beyond) that point :-)
I hope you don't feel that I'm "taking you to task" over this, btw. That's
*not* my intention. It's now become more about checking up on my own
understanding .... which amounts to a hijacking of this thread ... and I
don't want to do that either :-)
Cheers,
Rob
------------------------------
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 5096
***************************************