[23051] in Perl-Users-Digest
Perl-Users Digest, Issue: 5272 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 25 14:06:26 2003
Date: Fri, 25 Jul 2003 11:05:08 -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 Fri, 25 Jul 2003 Volume: 10 Number: 5272
Today's topics:
Re: Can one control swap in Perl? <grazz@pobox.com>
Re: cpan problems with 02packages.details.txt.gz and 03 (Randy Kobes)
DBfile::lock - does not work on a certain server <ixanthi@ixanthi.remove.gr>
Re: DBfile::lock - does not work on a certain server <dwilga-MUNGE@mtholyoke.edu>
Re: document ID tracking <asu1@c-o-r-n-e-l-l.edu>
failed /g match on empty string does not reset pos() <dbo@xbn.nl>
Re: failed /g match on empty string does not reset pos( <grazz@pobox.com>
LDAP group membership query (Paul)
Re: Lookup Country by IP Address <njh@despammed.com>
module and $ARGV help (slash)
need help-how to parse references (susan)
Re: need help-how to parse references (Tad McClellan)
Re: newbie question <bart.lateur@pandora.be>
Re: newbie question (Tad McClellan)
Re: Newbie: Problems with a CPAN installation <Olof.KarlbergNOSPAMatebc.uu.se>
Piping through gzip <bill_knight2@yahoo.com>
Re: Piping through gzip <kevin.campbell@framestore-cfc.com>
Re: push -- weird problem <Mental_Patient_0057@psychiatric-center.Bellevue-Hospital.com>
Re: Q: Summarize/Condense already tight text string? (Brock Gunter-Smith)
scalar function (fatted)
Re: scalar function <noreply@gunnar.cc>
Re: scalar function <dbo@xbn.nl>
Re: scalar function <shawn@magma.ca>
Re: scalar function <dbo@xbn.nl>
Re: size of graphics files.... <bart.lateur@pandora.be>
Unappropriate ioctl for device <bguillon@snv.jussieu.fr>
Update BuiltinDocumentProperties (Blackpower)
use of shift exists? <Mental_Patient_0057@psychiatric-center.Bellevue-Hospital.com>
Re: use of shift exists? <dbo@xbn.nl>
Re: UTF-8 module <flavell@mail.cern.ch>
writing to parallel port <admin@asarian-host.net>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 25 Jul 2003 16:11:27 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Can one control swap in Perl?
Message-Id: <PEcUa.43$JS2.42@nwrdny03.gnilink.net>
news@roaima.freeserve.co.uk wrote:
> Irving Kimura <irving_kimura@lycos.com> wrote:
> > Is there any way that I can designate a
> > variable in a Perl script so that it will never be swapped out to
> > disk?
>
> Some platforms provide the mlock() and munlock() system calls to do
> just this (POSIX.1b and SVr4, apparently - which probably means most
> UNIX/Linux systems). One could conceivably write a module to provide
> these to a perl process. Bear in mind, though, that your program would
> need to run as a privileged process to be able to use these calls.
You'd have to be awfully careful not to make accidental copies
of the string -- e.g. by interpolating it, using a regex on it,
printing it into a stdio buffer, etc.
And setuid scripts are disabled on many platforms (and suidperl
has been deprecated).
Perl just doesn't seem like the right tool for this job.
--
Steve
------------------------------
Date: 25 Jul 2003 14:13:26 GMT
From: randy@theoryx5.uwinnipeg.ca (Randy Kobes)
Subject: Re: cpan problems with 02packages.details.txt.gz and 03modlist.data.gz
Message-Id: <slrnbi2eom.13k.randy@theoryx5.uwinnipeg.ca>
On Thu, 24 Jul 2003 23:11:12 GMT,
David Christensen <dpchrist@holgerdanske.com> wrote:
>Hello, world!
>
>I am having trouble with cpan on Cygwin:
>
>dpchrist@w2k30g:~/.cpan/sources$ cpan
>cpan shell -- CPAN exploration and modules installation (v1.70_54)
>ReadLine support enabled
>cpan> install Class::Base
>Going to read /home/dpchrist/.cpan/sources/authors/01mailrc.txt.gz
>Going to read
>/home/dpchrist/.cpan/sources/modules/02packages.details.txt.gz
>Warning: Your
>/home/dpchrist/.cpan/sources/modules/02packages.details.txt.gz does not
>contain a Line-Count header.
>Please check the validity of the index file by comparing it to more than
>one CPAN mirror. I'll continue but problems seem likely to happen.
[ .. ]
>I STFW and came up with a message by a lady who had a same/similar
>problem. She said that it was caused by a rogue "~" file or folder in
>her directory tree. Removing it fixed the problem. I searched my
>system, found "C:\~", and removed it, but no luck.
Perhaps Cygwin perl gets confused with the '~', sometimes
thinking it a real directory (eg, presence of a C:\~) and other
times expanding it to a home directory (/home/dpchrist/). It
might be worth trying to again remove C:\~, and then start
the CPAN.pm shell but first reconfigure it:
cpan> o conf init
and try choosing the build and source directories with a root
directory of something like C:/.cpan/.
--
best regards,
randy kobes
------------------------------
Date: Fri, 25 Jul 2003 15:18:59 +0300
From: "Vassilis Tavoultsidis" <ixanthi@ixanthi.remove.gr>
Subject: DBfile::lock - does not work on a certain server
Message-Id: <bfr77l$fap$1@nic.grnet.gr>
I am running the following script on an Apache Server 1.3.27 (Unix) with
Linux as an operating system and perl version 5.006001 (I don't know any
other information I just rent this server) and it dies when I try to tie the
hash with the database.
#!/usr/bin/perl
use CGI;
use Fcntl qw( :DEFAULT :flock);
use DB_File::Lock;
my $q = new CGI;
$temp_data = $ENV{'DOCUMENT_ROOT'};
if($temp_data =~ /\/$/) {
chop($temp_data);
}
print "Content-type: text/html\n\n";
print "DB_File::Lock >>> ";
$db_filename = "${temp_data}/database/epipla";
print "${db_filename}<br>";
tie(%db_hash, 'DB_File::Lock', $db_filename, O_RDONLY, 0755, $DB_HASH,
'read') or die"error";
while (($k, $v) = each(%db_hash))
{
print $k."::".$v."<br>";
};
untie(%db_hash);
print "end";
exit;
------------------------------
Date: Fri, 25 Jul 2003 17:54:20 GMT
From: Dan Wilga <dwilga-MUNGE@mtholyoke.edu>
Subject: Re: DBfile::lock - does not work on a certain server
Message-Id: <dwilga-MUNGE-A5EA53.13541625072003@nap.mtholyoke.edu>
In article <bfr77l$fap$1@nic.grnet.gr>,
"Vassilis Tavoultsidis" <ixanthi@ixanthi.remove.gr> wrote:
> tie(%db_hash, 'DB_File::Lock', $db_filename, O_RDONLY, 0755, $DB_HASH,
> 'read') or die"error";
If you change this to:
or die "error: $!\n";
you may get more useful informtaion out of it. I would also suggest
running it from the commandline, so you can see the error message right
away (rather than having to look in the server error log.)
--
Dan Wilga dwilga-MUNGE@mtholyoke.edu
** Remove the -MUNGE in my address to reply **
------------------------------
Date: 25 Jul 2003 14:23:53 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: document ID tracking
Message-Id: <Xns93C369C725FDAasu1cornelledu@132.236.56.8>
"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in
news:Xns93C33D640AD40sdn.comcast@206.127.4.25:
> "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in
> news:Xns93C2A80F838A4asu1cornelledu@132.236.56.8:
>
>> if(exists $word_to_files{$word}) {
>> unless(grep /$ARGV/, @{$word_to_files{$word}}) {
>> push @{$word_to_files{$word}}, ($ARGV);
>> }
>> } else {
>> $word_to_files{$word} = [$ARGV];
>> }
>
> Why use an array as the second-level data structure -- why not a hash?
>
> $word_to_files{$word}{$ARGV} = 1;
Muddled thinking I guess. And I do remember making a mental note of this
when you pointed out the same thing in another thread, but it looks like
I regarded that as just another deadline reminder :)
Is this better?
# cw: Common Word
# Script to list words that appear in all the files
# passed on the command line
use diagnostics;
use strict;
use warnings;
die "$0: file1 ... fileN\n" unless scalar @ARGV;
my %word_to_files;
while(<ARGV>) {
chomp;
my @words = split /\s+/;
foreach (@words) {
$word_to_files{$_}{$ARGV} = 1;
}
}
foreach (sort keys %word_to_files) {
print "$_: ", join(" ", keys %{$word_to_files{$_}}), "\n";
}
__END__
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Fri, 25 Jul 2003 12:33:47 +0200
From: David Bouman <dbo@xbn.nl>
Subject: failed /g match on empty string does not reset pos()
Message-Id: <3F21078B.FBE1915F@xbn.nl>
Please consider the following constructed example:
#!/usr/bin/perl -Tw
use strict;
sub foo {
for( $_[0] ){
m/\A(.*)/gs or print("1st match failed\n"), return ; # won't
m/\G(.+)/gs or print("2nd match failed, ") ; # will
print "pos: ", defined(pos) ? pos : "reset", "\n";
}
}
foo( 'bar' );
foo( '' );
Which outputs:
2nd match failed, pos: reset
2nd match failed, pos: 0
For the empty string I'm expecting pos() to have been reset after the
failed second match just as it has for the non-empty string. However,
on all versions of perl I've tested - 5.005_03, 5.6.1 and 5.8.0 -
apparently it isn't.
I'm tempted to say it's a bug.
--
David.
------------------------------
Date: Fri, 25 Jul 2003 15:43:03 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: failed /g match on empty string does not reset pos()
Message-Id: <becUa.30$JS2.3@nwrdny03.gnilink.net>
David Bouman <dbo@xbn.nl> wrote:
>
> For the empty string I'm expecting pos() to have been reset after the
> failed second match just as it has for the non-empty string. However,
> on all versions of perl I've tested - 5.005_03, 5.6.1 and 5.8.0 -
> apparently it isn't.
>
> I'm tempted to say it's a bug.
More generally, it looks like the "target is too short" optimization
isn't resetting pos().
for ("f") {
m/./g; print pos || "<undef>";
m/../g; print pos || "<undef>";
}
If you change the second match to "m/./g" it will reset.
--
Steve
------------------------------
Date: 25 Jul 2003 07:17:09 -0700
From: ppopour@coastalnow.net (Paul)
Subject: LDAP group membership query
Message-Id: <8ba68739.0307250617.16ec7a1f@posting.google.com>
I am trying to query an NDS tree using the Win32::OLE and
Win32::OLE::Enum modules. I was able to traverse the tree and gather
all the group names, however, I can't seem to get the members of the
groups. I've tried several methods and I must be missing something.
Below is a snippet of the last try. Any help would be greatly
appreciated.
my $obj = Win32::OLE->GetObject("LDAP://$srv/$oh")||die
Win32::OLE->LastError();
foreach my $object (in $obj)
{
my $objectclass = $object->Get(objectClass);
foreach my $objclass (in $objectclass)
{
if ($objclass eq "organizationalUnit")
{
&showgrp("$object->{Name},$oh");
}
if ($objclass eq "groupOfNames")
{
print "$object->{Name}\t$object->{Class}\t$object->{ADsPath}\n";
my $grpenum = Win32::OLE::Enum->new($object)|| die
Win32::OLE->LastError();
foreach ($grpenum->All)
{
if(lc($_->{'class'}) eq "member")
{
print "$_->{Name}\n";
}
}
}
}
}
------------------------------
Date: Fri, 25 Jul 2003 17:26:22 +0100
From: Nigel Horne <njh@despammed.com>
Subject: Re: Lookup Country by IP Address
Message-Id: <bfrlne$dcf$1$8302bc10@news.demon.co.uk>
As it's a perl group I should have given the Perl route:
#!/usr/bin/perl -wT
use strict;
use Net::Whois::IANA;
my $ip = '212.159.106.41'; # Insert an IP address here
print new Net::Whois::IANA->whois_query(-ip=>$ip)->country() . "\n";
------------------------------
Date: 25 Jul 2003 10:30:42 -0700
From: satishi@gwu.edu (slash)
Subject: module and $ARGV help
Message-Id: <30fe9f1e.0307250930.11cad0e1@posting.google.com>
Hello,
I need some desperate help with the Text::Table module. I am trying to
add another column of data that carries the filename from which the
ngrams are being done. The program parses a text file and performs an
ngram on the word level and I select certain columns for display. For
hours I have been trying to figure out how to add the documentID also
at the end of each line. Following is the code I am trying to workout:
use Text::Table;
undef $/;
my @words = split /\W+/, <> ;
my $line_number = 2;
my $n;
my $n_columns = 4;
my $line_num = 2;
my $n_cols = 5;
my $col = { align => 'left'}; # no title, left alignment
my $tb = Text::Table->new( ( $col) x $n_cols);
my @stack = ( '*' ) x $n_cols;
foreach $word ( @words ) {
shift @stack;
push @stack, $word;
$tb->add(@stack);
}
my @lines = $tb->add("$stack[-4]", "$stack[-3]", "$stack[-2]",
"$stack[-1]", "*");
my @lines = $tb->add("$stack[-3]", "$stack[-2]", "$stack[-1]",
"*", "*");
my @lines = $tb->table($line_number, $n);
#print @lines;
my $t1 = Text::Table->new( ($col) x $n_columns);
my $t1 = $tb->select(2, {is_sep => 2, body => " "}, 1,0,
{is_sep => 2, body => "\n"},
2, {is_sep =>2, body => " "}, 3,4);
#@textID=$tb->select(1);
#foreach $textID (@textID) {
# $t1 = $t1->add($ARGV); }
my $input = $t1->table($line_num, $n);
print $input;
What I get right now is this:
quick brown fox
brown quick
brown fox jumped
fox brown quick
fox jumped over
What I have been trying for hours is:
quick brown fox fox.txt
brown quick fox.txt
brown fox jumped fox.txt
fox brown quick fox.txt
fox jumped over fox.txt
I also have another general question about $ARGV.
Let's say if I wanted to run the above script over multiple input
files. Can I do the following:
perl -n script.pl *.TXT
I actually tried doing the above but it hung because of the while.
What is the terminating condition for the loop? Or, is there a better
way of doing this?
When my script moves from one file to the next does it update the
value of $ARGV?
Thanks so much,
Slash
------------------------------
Date: 25 Jul 2003 07:04:06 -0700
From: anzhenli@hotmail.com (susan)
Subject: need help-how to parse references
Message-Id: <d1b124d8.0307242254.690d791b@posting.google.com>
Hello everyone:
I am a perl beginner. I am practicing to parse a list of different
references. The list looks like any references followed a paper. In
the list, every reference has different numbers of authors. Most
references are either books or journals. I would like to separate each
field, for example, the result I assume looks like:
author article name journal name or book name volume#...year
Alison Balter Access 2000 development 1999
I feel it is hard to find a regular expression to separate them. Does
anyone advise me where I can find more inforamtion?
Thanks.
Susan
------------------------------
Date: Fri, 25 Jul 2003 10:30:32 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: need help-how to parse references
Message-Id: <slrnbi2j8o.ahs.tadmc@magna.augustmail.com>
susan <anzhenli@hotmail.com> wrote:
> I am practicing to parse a list of different
> references.
If you show us several good examples of your data, we would
probably be able to help you.
But you didn't, so we can't.
Have you seen the Posting Guidelines that are posted here frequently?
> for example, the result I assume looks like:
^^^^^^^^^^
^^^^^^^^^^
> author article name journal name or book name volume#...year
> Alison Balter Access 2000 development 1999
So that is the output you want from your program?
What does the input look like?
We cannot parse data that we know nothing about.
If that _is_ meant to be your input, then why must you "assume"
what it looks like?
We must know the input with great precision if we are to devise
a way to process it. "Assuming" what the input looks like will
not result in an answer that is useable in real life.
> I feel it is hard to find a regular expression to separate them.
Maybe you do not need a regular expression to separate them.
Maybe you could use some other approach...
> Does
> anyone advise me where I can find more inforamtion?
... but without knowing what you have, and how you want to
transform it, we cannot advise one way or the other.
Your post does not contain the information we need to answer your question.
Show use some example input. (one record is not good enough)
Show use some desired output (for that same data).
Tell (and show) us anything you know about the format of the input data:
Can fields be "missing" or "empty"? How can you tell when they are?
Do the fields always line up in columns?
Is there some separator between each column?
If you can do something like that, then we would have a really
good chance of being able to help you with your problem.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 25 Jul 2003 13:10:10 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: newbie question
Message-Id: <rta2ivkmti8o6rdp6d8bvvvucr6tqjrj7l@4ax.com>
A. Sinan Unur wrote:
>Each ".." operator maintains its own boolean state. It is false as long
>as its left operand is false. [...]
You're quoting from the decription of the bahaviour of the range
operator in scalar context. Clearly, the OP's code shows the use of
"..." in list context, which is what confuses him. Actually, it confuses
me, too. I think it must be considered as one of these cases:
In all other regards, "..." behaves just like ".." does.
--
Bart.
------------------------------
Date: Fri, 25 Jul 2003 09:54:22 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: newbie question
Message-Id: <slrnbi2h4u.ahs.tadmc@magna.augustmail.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> A. Sinan Unur wrote:
>> hou <dhou@rohan.sdsu.edu> wrote:
>>>Would you please tell me how to locate the posting guidelines?
>>
>> http://mail.augustmail.com/~tadmc/clpmisc.shtml
>
> Maybe it would be a good idea to append that URL to the bottom of
> every message, like they do at ciwac.
I do not think that is a good idea.
It is already the top hit at Google and posted twice a week.
It should be the rare person that finds usenet/clpmisc before
finding Google, so not many people will benefit from a
reminder on every single post.
Plus, it is kind of "in your face", which I object to.
The "cost" is higher than the "benefit" in _my_ CBA,
it would be a lot of work for a questionable benefit...
> Would that be possible, Tad?
... making the answer to that question moot. :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 25 Jul 2003 12:46:48 +0200
From: Olof Karlberg <Olof.KarlbergNOSPAMatebc.uu.se>
Subject: Re: Newbie: Problems with a CPAN installation
Message-Id: <20030725124648.269c8cc8.Olof.KarlbergNOSPAMatebc.uu.se@molev155.ebc.uu.se>
On 25 Jul 2003 01:52:03 -0700
francescomoi@europe.com (Francesco Moi) wrote:
> Hello.
>
> I'm trying to install 'LWP:Simple' module on my Linux machine.
>
> # perl -MCPAN -e shell
> cpan> install LWP:Simple
> Going to read /root/.cpan/sources/modules/03modlist.data.gz
> Warning: Cannot install LWP:Simple, don't know what it is.
> Try the command
> i /LWP:Simple/
> to find objects with similar identifiers.
>
> I don't have any idea about this error. Any suggestion?
Try with "install LWP::Simple" instead. That should be with two colons,
not one.
Olof
------------------------------
Date: Fri, 25 Jul 2003 16:44:52 +0000 (UTC)
From: bill <bill_knight2@yahoo.com>
Subject: Piping through gzip
Message-Id: <bfrmq4$cil$1@reader1.panix.com>
I'm trying to figure out how to gunzip a gzipped string from within
a Perl program without creating a temporary file. (The gzipped
string arrives as the content of a certain HTTP::Response object.)
The following works if the string is sufficiently small:
open2(*READ, *WRITE, 'gzip -dc');
print WRITE $gzipped; # blocks if $gzipped is too large
close WRITE; # required before <READ> !
$/ = undef;
my $gunzipped = <READ>;
close READ;
It's a deadlock issue for sure, but I can't figure out how to solve
it. I tried using syswrite and sysread to interleave writes and
reads of small chunks of data, but this doesn't work either; I can
write a small chunk of data to the WRITE handle, but then the READ
does not receive anything...
The Perl Cookbook warns about the problem of deadlock when one does
not have control of the buffering done by the intermediate program
('gzip -dc' in this case), but it gives no solution to the problem.
In another book (Stein's "Network Programming with Perl") the author
considers IO::Open2, but later claims that socketpair() provides
a more "elegant" solution to this kind of problem. Unfortunately
he does not elaborate.
Any advice would be most welcome.
Thanks in advance,
bill
------------------------------
Date: Fri, 25 Jul 2003 18:43:09 +0100
From: Kevin Campbell <kevin.campbell@framestore-cfc.com>
Subject: Re: Piping through gzip
Message-Id: <1059154989.954234@proxy>
bill wrote:
> I'm trying to figure out how to gunzip a gzipped string from within
> a Perl program without creating a temporary file. (The gzipped
> string arrives as the content of a certain HTTP::Response object.)
>
Compress::Zlib from www.cpan.org does this, i think
kevin
------------------------------
Date: Fri, 25 Jul 2003 09:14:06 -0400
From: Mental Patient 0057 <Mental_Patient_0057@psychiatric-center.Bellevue-Hospital.com>
Subject: Re: push -- weird problem
Message-Id: <3F212D1E.B13DA43E@psychiatric-center.Bellevue-Hospital.com>
"David K. Wall" wrote:
>
> butt-fuzz <butt-fuzz@ass.wipe.com> wrote:
>
> > sorry, I'm not a real programmer.
..........
>
> Then learn. :-) I'm not primarily a programmer either, have little formal
........
> it can, for a particular problem domain -- just different. I need to
> learn more languages and more theory and get more practice, but that's all
> part of the fun, right?
>
> Oh, and I for one will take you more seriously if you use a name other
> than "butt-fuzz".
>
how about if he change his name to "jon maddog hall"?
> --
> David Wall
------------------------------
Date: 25 Jul 2003 05:52:15 -0700
From: brock@gunter-smith.com (Brock Gunter-Smith)
Subject: Re: Q: Summarize/Condense already tight text string?
Message-Id: <f6181183.0307250452.2e3acd0c@posting.google.com>
Excellent. Thank you for those suggestions. As soon as I read your
post about obviously removing short words and prepositions, that is an
obvious and very effective means to reduce length without removing
readability.
For this project I can't use the Soundchange system because of the
characters involved, but for another project I have coming up shortly
I will. Very nice.
Thanks.
Brock
JS Bangs <jaspax@u.washington.edu> wrote in message news:<Pine.A41.4.56.0307241649080.73652@dante18.u.washington.edu>...
>
> Assuming that your filenames are in English, I would suggest adding the
> following at the *beginning* of your algorithm:
>
> - Remove all words of 2 or less characters
> - Remove all common prepositions and articles: the, with, and, from, for,
> this, etc.
>
> These items all carry little information, and can be pretty safely lost.
>
> For a more esoteric solution, you could use Lingua::Soundchange and
> implement the English-spelling algorithm at http://zompist.com/spell.html,
> which will reduce English text by about 40%
------------------------------
Date: 25 Jul 2003 06:00:11 -0700
From: fatted@yahoo.com (fatted)
Subject: scalar function
Message-Id: <4eb7646d.0307250500.606869b4@posting.google.com>
Consider 2 statements:
my $value = 3 + @array;
my $value = 3 + scalar(@array);
They both result in $value having the same value (as far as I've seen).
Is there any difference, or to put it another way, what's the point in using scalar?
------------------------------
Date: Fri, 25 Jul 2003 15:34:50 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: scalar function
Message-Id: <bfrbl6$hsegt$1@ID-184292.news.uni-berlin.de>
fatted wrote:
> Consider 2 statements:
>
> my $value = 3 + @array;
> my $value = 3 + scalar(@array);
>
> They both result in $value having the same value (as far as I've
> seen).
>
> Is there any difference, or to put it another way, what's the point
> in using scalar?
The point with using scalar is to _ensure_ a return value in scalar
context. In this case, you get it implicitly - out from context :) -
by including @array in an addition.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 25 Jul 2003 15:37:07 +0200
From: David Bouman <dbo@xbn.nl>
Subject: Re: scalar function
Message-Id: <3F213283.955F9E31@xbn.nl>
fatted wrote:
> Consider 2 statements:
>
> my $value = 3 + @array;
> my $value = 3 + scalar(@array);
>
> They both result in $value having the same value (as far as I've seen).
Your insights are correct;
> Is there any difference, or to put it another way, what's the point in using scalar?
Consider:
print 3, @array;
print 3, scalar(@array);
--
David.
------------------------------
Date: Fri, 25 Jul 2003 09:41:12 -0400
From: Shawn Corey <shawn@magma.ca>
Subject: Re: scalar function
Message-Id: <6-ScnSttWeJAr7yiXTWJiA@magma.ca>
Hi,
The point of the scalar function is to tell Perl you want the number of
elements of the array rather than the array itself in those contexts
where it's unclear whether the context is scalar or array.
Example: parameters of a function.
&foo( @arr ); # send the array
&foo( scalar( @arr )); # send the number of elements
If you're not sure, use it anyway. I always use it just to make
understanding the program clearer.
fatted wrote:
> Consider 2 statements:
>
> my $value = 3 + @array;
> my $value = 3 + scalar(@array);
>
> They both result in $value having the same value (as far as I've seen).
>
> Is there any difference, or to put it another way, what's the point in using scalar?
------------------------------
Date: Fri, 25 Jul 2003 15:48:14 +0200
From: David Bouman <dbo@xbn.nl>
Subject: Re: scalar function
Message-Id: <3F21351E.51C8326F@xbn.nl>
Shawn Corey wrote:
> The point of the scalar function is to tell Perl you want the number
> of elements of the array rather than the array itself in those
> contexts where it's unclear whether the context is scalar or array.
The point of scalar EXPR is to force a scalar context upon it's
expression argument. It just so happens that an array in scalar
context evaluates to its number of elements but that's not the
intended purpose of the scalar operator.
--
David.
------------------------------
Date: Fri, 25 Jul 2003 13:06:33 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: size of graphics files....
Message-Id: <ana2iv4ubukdbp6oi5160epeq94ink4f8i@4ax.com>
Martien Verbruggen wrote:
>The book advises one to use Image::Size for this, and I fully
>subscribe to that view :)
Me too.
Yet I'd like to point out that there is also an other module available,
with overlapping use: Image::Info. Current URL:
<http://search.cpan.org/author/GAAS/Image-Info-1.12/>
--
Bart.
------------------------------
Date: 25 Jul 2003 14:34:16 GMT
From: Benoit Guillon <bguillon@snv.jussieu.fr>
Subject: Unappropriate ioctl for device
Message-Id: <2003725-163416-880135@foorum.com>
Hello,
I upgraded Perl from 5.6 to 5.8. The software I develop used to work fine with
Perl 5.6 and now, sometimes, I get the error "Unappropriate ioctl for device"
when I try to open a file for write.
My Perl version is v5.8.0 included in the Debian 'sid' - unstable.
Does somebody have an idea ?
Thanks,
Benoit.
--
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr
http://forums.club-internet.fr/
------------------------------
Date: 25 Jul 2003 03:24:09 -0700
From: bpower7@hotmail.com (Blackpower)
Subject: Update BuiltinDocumentProperties
Message-Id: <597ae48b.0307240143.1b413d92@posting.google.com>
Im trying to update some BuiltinDocumentProperties of office documents.
It all goes wel, except that it doesnt save the properties.
If I save to a new file the new properties are saved as well.
here is the code.
use strict;
use Win32::OLE qw(in);
my $Word = Win32::OLE->new('Word.Application', 'Quit');
my $Doc = $Word->Documents->Open('Document1.doc');
$Doc->BuiltinDocumentProperties->{Title} = "Custom Title" ;
$Doc->BuiltinDocumentProperties->{Comments} = "Custom Comment" ;
#$Doc->SaveAs( 'Document2.doc'); # this works
$Doc->Save ; #this doesnt work.
$Doc->Quit ;
------------------------------
Date: Fri, 25 Jul 2003 10:14:45 -0400
From: Mental Patient 0057 <Mental_Patient_0057@psychiatric-center.Bellevue-Hospital.com>
Subject: use of shift exists?
Message-Id: <3F213B55.F82B102F@psychiatric-center.Bellevue-Hospital.com>
this moves one item over
$a = shift @rray;
is there a way to move three at a time?
($a, $b, $c) = shift 3things @rray?
($d, $e, $f, $g) = shift nowShift4Things @rray?
------------------------------
Date: Fri, 25 Jul 2003 16:19:22 +0200
From: David Bouman <dbo@xbn.nl>
Subject: Re: use of shift exists?
Message-Id: <3F213C6A.28B8BA6C@xbn.nl>
Mental Patient 0057 wrote:
> this moves one item over
> $a = shift @rray;
>
> is there a way to move three at a time?
Yes, use splice. A perldoc -f splice will explain it.
--
David.
------------------------------
Date: Fri, 25 Jul 2003 12:41:13 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: UTF-8 module
Message-Id: <Pine.LNX.4.53.0307251212390.21819@lxplus082.cern.ch>
On Fri, Jul 25, Bob Walton inscribed on the eternal scroll:
> Jerry Maguire wrote:
>
> > Is there any module to encode a URL into UTF-8 format?
I assumed this was a question about encoding per RFC2718,
http://www.ietf.org/rfc/rfc2718.txt
> > I have looked at cpan and could not find anything.
I haven't stayed up to date with developments in this area, but it was
my impression that this extension to the original URI specifications -
see e.g RFC2396:
It is expected that a systematic treatment of character encoding
within URI will be developed as a future modification of this
specification.
had not really developed into a widely-used procedure, at least not
yet. Feel free to correct me on this (the W3C activity page is at
http://www.w3.org/Addressing/ ).
> UTF-8 support is native in Perl 5.8.
It is, but I don't think that really addresses what the questioner
wanted to achieve. I'm not aware of a module, nor can I find one at
CPAN.
Presumably what's needed is that every character whose ord() value is
above 127 decimal needs to be subjected to some kind of unpack() or
sprintf to yield the relevant number of %HH%HH... encoded ASCII
strings. Not forgetting, of course, to encode the so-called "unsafe"
ASCII characters in %HH format also. But sorry, I don't have any
tried and tested code for this, and I'm reluctant to post anything
that's not properly tested. Google's sole match for my search terms
was http://www.geocities.co.jp/SilkRoad/4511/vb/urlenc.htm which is a
block of (visualbasic?) code commented in Japanese ;-)
------------------------------
Date: Fri, 25 Jul 2003 19:13:23 +0200
From: "Mark" <admin@asarian-host.net>
Subject: writing to parallel port
Message-Id: <SOycnRSqqtze-LyiU-KYuQ@giganews.com>
Hello,
Has anyone an idea how to set/unset a bit on a parallel port in freebsd 4.7?
I installed Device::ParallelPort from CPAN, but that does nothing (seems
made for linux).
Thanks,
- Mark
------------------------------
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 5272
***************************************