[10797] in Perl-Users-Digest
Perl-Users Digest, Issue: 4397 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 10 13:07:22 1998
Date: Thu, 10 Dec 98 10:00:27 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Dec 1998 Volume: 8 Number: 4397
Today's topics:
array initialisation <michaelr@lndn.tensor.pgs.com>
Re: array initialisation <ajohnson@gatewest.net>
Re: array initialisation (Larry Rosler)
bootstrapping Perl script and self on NT <jbo@dator.dk>
Browser capabilities... <email@siu.edu>
Re: Browser capabilities... (brian d foy)
Re: Can someone tell me why .... (James Peregrino)
Re: Change Directory (Tad McClellan)
Re: Change Directory <newsposter@cthulhu.demon.nl>
Dec's Atlanta Perm Monger Meeting sboss@my-dejanews.com
Re: Decent Editor (Clay Irving)
Re: Help! Possible permissions problem? kmitev@my-dejanews.com
How can I read a serial port in Perl (with NT4.0 server <tdumort@webraska.com>
Re: How to effectively match _many_ regular expressions (Andrew Allen)
How to get system resource status? <sansil@pchome.com.tw>
Re: IS there a difference really? $var and ${var}? Exam <ajohnson@gatewest.net>
Re: IS there a difference really? $var and ${var}? Exam (Greg Bacon)
Joined and split arrays <Brad.McBride@Axom.com>
Re: Joined and split arrays (Sam Holden)
Re: Joined and split arrays (Larry Rosler)
Re: Joined and split arrays (Tad McClellan)
Re: Joined and split arrays <newsposter@cthulhu.demon.nl>
Re: Joined and split arrays <niral@corporate.planet.net>
mail attachment <michaelr@lndn.tensor.pgs.com>
namespace question <alexb@sig.net>
Re: Newbie Question (Tad McClellan)
Re: opening /dev/sequencer <newsposter@cthulhu.demon.nl>
Out of memory!?? <sansil@pchome.com.tw>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Dec 1998 14:07:48 +0000
From: Michael Renshaw <michaelr@lndn.tensor.pgs.com>
Subject: array initialisation
Message-Id: <366FD5B4.D9F@lndn.tensor.pgs.com>
anybody know the fastest way to initialise an array with zeros
in perl:
im currently using a for loop and setting each index location to zero,
is there a faster way !!!!
cheers
Mike
------------------------------
Date: Thu, 10 Dec 1998 09:27:43 -0600
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: array initialisation
Message-Id: <366FE86F.329D648@gatewest.net>
Michael Renshaw wrote:
>
> anybody know the fastest way to initialise an array with zeros
> in perl:
>
> im currently using a for loop and setting each index location to zero,
> is there a faster way !!!!
init an array of length 100 to zeros:
@array = (0) x 100;
see 'perldoc perlop' for the binary repetition operator 'x'
in list context.
regards
andrew
------------------------------
Date: Thu, 10 Dec 1998 08:09:39 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: array initialisation
Message-Id: <MPG.10d9921cae016ce798994b@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <366FD5B4.D9F@lndn.tensor.pgs.com> on Thu, 10 Dec 1998
14:07:48 +0000, Michael Renshaw <michaelr@lndn.tensor.pgs.com> says...
> anybody know the fastest way to initialise an array with zeros
> in perl:
>
> im currently using a for loop and setting each index location to zero,
> is there a faster way !!!!
As I seem to be taking on the benchmarking burden these days...
#!/usr/local/bin/perl -w
use Benchmark;
$#a = 99; # Preallocate an array of 100 elements.
timethese ( (1 << (shift || 0) ), {
Assign0 => sub { @a = (0) x 100 },
Assign1 => sub { @a = (0) x @a },
Foreach => sub { foreach (@a) { $_ = 0 } },
Index => sub { for ($i = 0; $i < 100; ++$i) { $a[$i] = 0 } },
Map0 => sub { @a = map 0, 1 .. 100 },
Map1 => sub { @a = map 0, 1 .. @a },
} );
__END__
Benchmark: timing 16384 iterations of Assign0, Assign1, Foreach, Index,
Map0, Map1...
Assign0: 4 wallclock secs ( 3.73 usr + 0.00 sys = 3.73 CPU)
Assign1: 7 wallclock secs ( 6.91 usr + 0.00 sys = 6.91 CPU)
Foreach: 5 wallclock secs ( 4.90 usr + 0.00 sys = 4.90 CPU)
Index: 8 wallclock secs ( 8.68 usr + 0.00 sys = 8.68 CPU)
Map0: 11 wallclock secs (12.19 usr + 0.00 sys = 12.19 CPU)
Map1: 15 wallclock secs (14.99 usr + 0.00 sys = 14.99 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 10 Dec 1998 17:49:57 +0100
From: "Jesper Bork" <jbo@dator.dk>
Subject: bootstrapping Perl script and self on NT
Message-Id: <3WSb2.260$t26.811@news.get2net.dk>
Hi,
I have a Perl application which now exists in multiple versions, some of
them requiring different versions of Perl also. I'd like to create a sort of
'boot manager' application which could be used by everybody and then
determine and bootstrap the correct version of Perl and the real app. Anyone
know if and how this could be done - preferrably in pure Perl (It's a
multiuser app, so just writing into e.g. a predetermined batch-file won't
do) ?!
TIA,
Jesper
jbo@dator.dk
------------------------------
Date: Thu, 10 Dec 1998 10:34:08 -0600
From: V l a d i m i r <email@siu.edu>
Subject: Browser capabilities...
Message-Id: <366FF7FF.B8B25573@siu.edu>
How do I check if a browser can play MIDI? That is, if a sound card is
installed?
Please reply directly to email@siu.edu. Thanks.
--
Vladimir
mailto:email@siu.edu http://131.230.194.8
------------------------------
Date: Thu, 10 Dec 1998 12:31:34 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Browser capabilities...
Message-Id: <comdog-ya02408000R1012981231340001@news.panix.com>
In article <366FF7FF.B8B25573@siu.edu>, V l a d i m i r <email@siu.edu> posted:
> How do I check if a browser can play MIDI? That is, if a sound card is
> installed?
in theory, the Accept header would be the place to look.
in practice, you can't tell.
but this has nothing to do with Perl
--
brian d foy <brianNOSPAM@NOSPAM.smithrenaud.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
remove NOSPAM or don't. it doesn't matter either way.
not all computers need sound cards to play sound.
------------------------------
Date: Thu, 10 Dec 1998 11:55:52 -0500
From: james_peregrino@harvard.edu (James Peregrino)
Subject: Re: Can someone tell me why ....
Message-Id: <1djtjok.15qaxyln8q08N@dcepf5.harvard.edu>
Owen,
You posted a large amount of code. Even the sharpest
programmers take over an hour to read that amount of code before they
can figure out the bugs in it.
So realize that you asked a bunch of people to take an hour out
of their time to help you. Given the volume of postings on c.l.p.m,
most of us don't have that time to devote to a single posting.
So what you end up with is a first-pass at the code, catching
the obvious problems with it, without any in-depth analysis.
I've never read alt.html, but I can parse pages of html in 1/100
of the time it takes to parse a programming language.
You'd have saved yourself some perceived grief by taking a stab
at the code yourself and suggesting possible places you think it is
broken.
The "arrogance" you perceive is due entering a high-volume
newsgroup with its own history, politics, and conventions that have
developed over years of being an active Usenet newsgroup.
Whenever I enter a big newsgroup with a well-developed culture,
I spend a lot of time lurking about until I get a sense of the proper
way to start conversations within the group.
-James
Owen <info@kn1.com> wrote:
> I did not write the script. It is Freeware from the CGI resource.
>
> That said, I posted here hoping to get some help and maybe learn something
> form you guys.
>
> I wish I had not bothered.
>
> Arrogance is here in abundance.
>
> You should maybe all take a break for a few weeks and just sit around
> reading the positive vibes from alt.html
>
> If you ever need any html or Java help, dont come looking to us.
>
> Owen
--
James Peregrino (617)496-6288 (v)
Manager of Comp. Services (617)495-5685 (f)
Harvard Div. Cont. Ed.
james_peregrino@harvard.edu
------------------------------
Date: Thu, 10 Dec 1998 09:27:13 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Change Directory
Message-Id: <h8po47.uk1.ln@magna.metronet.com>
Rollo Chan Ka Chun (kcchan@csis.hku.hk) wrote:
: I would like to ask...when I writing a PERL program to list the
: contents of several direcotries under UNIX...there are some unexpected
: results...I coded as follow...
: @list = {"dir1", "dir2"};
^ ^
^ ^ those should be parenthesis
in idiomatic Perl, the above would be written:
@list = qw/ dir1 dir2 /;
: for ($loop = 0; $loop < 2; $loop++)
You seldom _need_ to index arrays in Perl. But this is not your problem.
in idiomatic Perl, the above would be written:
foreach $dir (@list)
: {
: chdir @list[$loop];
^
^
You should access a scalar here rather than an array slice
chdir $list[$loop];
^
^
You should be using -w on *all* of your Perl programs.
Really.
It would have pointed out the array slice thing above.
You should check the return value from the chdir() call.
Doing so would have supplied a clue as to what is going wrong:
chdir $list[$loop] or die "could not change to '$list[$loop]' $!";
The first time through the loop you go down into 'dir1'.
The second time through the loop you are still inside of 'dir1'
when you try to open 'dir2'.
This will fail unless 'dir2' is a subdirectory under 'dir1'...
You don't _need_ to chdir() to get the listing. In fact doing
so requires that you go back to the parent dir at the end
of the loop:
chdir('..') || die "could not go back to parent dir $!";
: opendir(DIR, ".");
You should check the return value from the opendir() call:
opendir(DIR, ".") || die "could not open current directory $!";
: while ($_ = readdir DIR)
: {
: print "$_ \n";
: }
: closedir(DIR);
: }
Here it is in idiomatic Perl:
------------------
#!/usr/bin/perl -w
foreach $dir ('dir1', 'dir2') {
opendir(DIR, $dir) || die "could not open '$dir' $!";
foreach (readdir DIR)
{
print "$_\n";
}
closedir(DIR);
}
------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Dec 1998 11:38:36 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Change Directory
Message-Id: <366FF90B.F4A1085B@cthulhu.demon.nl>
Rollo Chan Ka Chun wrote:
>
> I would like to ask...when I writing a PERL program to list the
> contents of several direcotries under UNIX...there are some unexpected
> results...I coded as follow...
Unexpected?
> @list = {"dir1", "dir2"};
^ ^ why not use ( and ) ?
> for ($loop = 0; $loop < 2; $loop++)
> {
> chdir @list[$loop];
^ use a $
> opendir(DIR, ".");
^ where's the 'or die' part ?
> while ($_ = readdir DIR)
> {
> print "$_ \n";
> }
>
> closedir(DIR);
> }
>
> It just can list the content of the 1st directory(dir1)...but
> can't list that of 2nd directory...it seems caused by the "chdir
> @list[$loop]" statement which change the current working directory to
> "dir1", thus can't list the "dir2" properly...
Well, that's exactly what I would expect :) Either chdir back to the
original directory, or do not chdir at all.
> but when I directly pass the
> element of array into the "opendir" statement...it fails to list both
> directories "opendir(DIR, @list[$loop]);".....what can I do???.....
First of all, _check_ the results of the chdir/opendir.
add the or die "Could not open dir: $!"].
Hm, @list[$loop] is supposed to return an array, assuming the
array contains 2 elements, might it be possible that you try to open
the directory '2'?
Erik
------------------------------
Date: Thu, 10 Dec 1998 14:48:27 GMT
From: sboss@my-dejanews.com
Subject: Dec's Atlanta Perm Monger Meeting
Message-Id: <74omvq$cm0$1@nnrp1.dejanews.com>
Hello All,
I hate to cancel the meeting at the last minute but I have gotten
severalc messages stating that ya'll could not make it this month.
So, I have canceled this month's meeting. If some of you want to
get together and have dinner one night after work, let me know. We
do not have to have formal meetings always.
Next month:
Topic: Perl for Win32
by: Scott Boss (myself)
Time: 7:00pm, Jan 12th, 1999
Location: Colltech (the same place as the last meeting)
The presentation will take no more than an hour then there will be
a q&a session about the topic and other perl topics.
Please RSVP via email to myself (mailto:sboss@technologist.com) so
I can plan for the right number of people. RSVPing is NOT required.
Please showup!
Please forward this email to anyone that is interested in Perl.
Thanks
Scott Boss
Atlanta Perl Monger Fearless Leader
PS> It will take me a few days to update the webpage.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 10 Dec 1998 10:48:23 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Decent Editor
Message-Id: <74oqg7$cj1@panix.com>
In <74mjie$r2g$1@bcarh8ab.ca.nortel.com> "Antony McNulty" <tony_mc@hotmail.com> writes:
>OK people calm down, let's not get worked up here....
Its our nature with subjects like "best editor" or "best programming
language." :)
>I'm on a Windows platform, have access to a UNIX platfom, but prefer to use
>Windows.
>I noticed many editors mentioned were UNIX, any ideas for the PC then ??
Check the 'editors' section of Perl Reference:
http://reference.perl.com/query.cgi?editors
--
Clay Irving
clay@panix.com
------------------------------
Date: Thu, 10 Dec 1998 15:28:26 GMT
From: kmitev@my-dejanews.com
Subject: Re: Help! Possible permissions problem?
Message-Id: <74opam$er3$1@nnrp1.dejanews.com>
In article <36708c7e.1124534@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:
<snip instructions on mkdir()>
>
> That's right.
>
> It's remarkable that you even need the second parameter on systems that
> know nothing about this kind of file permissions, such as Macintosh and
> DOS. (probably on Win32 too, but untested).
> Bart.
>
Portability ?
--
Kiril
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 10 Dec 1998 18:06:39 +0000
From: Thierry Dumort <tdumort@webraska.com>
Subject: How can I read a serial port in Perl (with NT4.0 server)
Message-Id: <36700DAF.9C9330B3@webraska.com>
Hi, this is Thierry from France.
I'm trying to read a serial port on a PC running under NT4.0 server
with the following script and it does not works very well.
$input = "COM1";
print "Opening $input\n";
system("MODE COM1: BAUD=19200 PARITY=N DATA=8 STOP=1");
open(PORT,"<COM1") or die "Cannot open $input\n";
open(OUT,">test.log") or die "Cannot open test.log\n";
print "reading $input\n";
while (<PORT>) {
print OUT "$_";
}
close(PORT);
close(OUT);
Can anybody help me ???
Thanks a lot.
Thierry.
------------------------------
Date: 10 Dec 1998 17:20:07 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: How to effectively match _many_ regular expressions at once?
Message-Id: <74ovs7$li1@fcnews.fc.hp.com>
Magnus Almgren (maa@zurich.ibm.com) wrote:
: I am trying to match quite a few regexps at once, but I am receving an
: error message from Perl. Can anyone tell me what I am doing wrong?
Here it is briefly (please try to post a _minimal_ code example-- it
often helps you find out what's wrong yourself)
#!/usr/bin/perl5 -w
use vars qw(@regexp);
use strict;
$_="bob";
@regexp=("bob")x105;
m/($regexp[99])/o; #works
m/($regexp[100])/o; #doesn't
m/(${regexp[100]})/o; #works!
and then I remembered a snippet from the documentation that running
"perlindex subscript ambiguity" found in 'perldata': (of course, if
you never remembered reading it, you'd might not ever find it :)
Within search patterns (which also undergo double-quotish
substitution) there is a bad ambiguity: Is /$foo[bar]/ to be
interpreted as /${foo}[bar]/ (where [bar] is a character class for the
regular expression) or as /${foo[bar]}/ (where [bar] is the subscript
to array @foo)? If @foo doesn't otherwise exist, then it's obviously
a character class. If @foo exists, Perl takes a good guess about
[bar], and is almost always right. If it does guess wrong, or if
you're just plain paranoid, you can force the correct interpretation
with curly brackets as above.
So apparently, a three-digit number is "guessed" to be a character
class. The wrong guess in this case. Oh well... perhaps perl should
print a warning?
: (included perl program)
some quick notes:
: @manyPatterns=split("\n","string\n" x$numPatterns);
creative. simpler: @manyPatterns=("string")x$numPatterns;
(note that yours would put a empty string as the last element of
manyPatterns, too. Probably not what you want).
: my $expr = join $condition => map { "m/(\$regexp[$_])/o" } (0..$#regexp);
note: instead of putting the variable name & subscript in, why not just
interpolate it directly? (especially if you're going to be eval-ing it
anyways):
my @new_regexp=@regexp;
map(s{/}{\\/},@new_regexp); # quote those pesky slashes!
my $expr=join($condition,map("m/$_/",@newregexp));
you might also consider using alternation (you could check which is
faster):
my $expr="m/".join('|',@newregexp)."/";
Andrew
------------------------------
Date: Thu, 10 Dec 1998 23:58:18 +0800
From: Silver CHEN <sansil@pchome.com.tw>
Subject: How to get system resource status?
Message-Id: <366FEF9A.B2FE370C@pchome.com.tw>
Dear Sir:
How can I get the system resource usage like:
MEM usage
SWAP usage
Overall loading
Is there any built-in functions or modules that
can help?
All I know is using `xxx` to quote the result
of shell commands.
Thanks for your help.
--
Silver CHEN
12/10/1998
------------------------------
Date: Thu, 10 Dec 1998 09:21:29 -0600
From: Andrew Johnson <ajohnson@gatewest.net>
Subject: Re: IS there a difference really? $var and ${var}? Example.
Message-Id: <366FE6F9.4FBFC8AF@gatewest.net>
Tom Adriaenssen wrote:
!
! $var and ${var} are exactly the same. Actually, they're not, but
! practical they are (correct me when i'm wrong). $var is the actual
! var, ${var} is a symbolic reference, which yields to $var.
actually, ${var} is the same as $var ... it is not treated as a
symbolic reference to $var but the same as $var. This is why it
works with my variables and under use strict;
use strict;
my $var = 12;
print ${var}; # works fine
#print ${'var'}; # error, now it's treated as a symbolic ref
regards
andrew
------------------------------
Date: 10 Dec 1998 15:51:54 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: IS there a difference really? $var and ${var}? Example.
Message-Id: <74oqmq$kmd$3@info.uah.edu>
In article <74olg6$k82$1@nickel.uunet.be>,
"Tom Adriaenssen" <tom@imagic.be> writes:
: $var and ${var} are exactly the same. Actually, they're not, but practical
: they are (correct me when i'm wrong). $var is the actual var, ${var} is a
: symbolic reference, which yields to $var.
No. Observe:
[9:42] ettsn% cat try
#! /usr/bin/perl -w
$var = 'dynamic';
my $var = 'lexical';
print "\$var = ", $var, "\n";
print "\${var} = ", ${var}, "\n";
[9:42] ettsn% ./try
Name "main::var" used only once: possible typo at ./try line 3.
$var = lexical
${var} = lexical
If I change ${var} to ${'var'}, then I have a symbolic reference
(and I'll die under strict 'refs'). However, keep in mind that the
symref is the only way to get to the dynamic if both a dynamic and
lexical of the same name are in scope.
: You can also use the ${} notation with an expression.
:
: foreach my $i ( 1..10 )
: {
: print "var$i = ", ${'var'.$i}, "\n";
: }
See <URL:http://www.plover.com/~mjd/perl/varvarname.html> for why this
is usually a bad idea.
Greg
--
Woody: Hey, Mr. Peterson, there's a cold one waiting for you.
Norm: I know, and if she calls, I'm not here
------------------------------
Date: Thu, 10 Dec 1998 10:24:49 -0500
From: Brad McBride <Brad.McBride@Axom.com>
Subject: Joined and split arrays
Message-Id: <366FE7C1.8FBFF8C1@Axom.com>
Hello all,
I've just run into a problem that I'm not too sure how to fix.
According to my documentation, this should work. I have an array called
@openticketlist which is full of information (any number of rows) from
an oracle database. I have joined all of the information from the
database in this array using ':' as the delimiter. I then am trying to
get each individule piece of information out of that array by putting it
into another array called @opentickets. Here is how I am doing it:
@opentickets = split(/:/, @openticketlist);
When I print out the contents of @openticketlist, I see all of my
information, nicely seperated by :s. When I print out my split array,
instead of seeing the same information formated differently, I get the
number 6. That's it, just the number 6. Is there something I am screwing
up with the split function or am I going about this all the wrong way?
Brad
------------------------------
Date: 10 Dec 1998 15:59:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Joined and split arrays
Message-Id: <slrn76vruh.al3.sholden@pgrad.cs.usyd.edu.au>
On Thu, 10 Dec 1998 10:24:49 -0500, Brad McBride <Brad.McBride@Axom.com> wrote:
>Hello all,
>
> I've just run into a problem that I'm not too sure how to fix.
>According to my documentation, this should work. I have an array called
>@openticketlist which is full of information (any number of rows) from
>an oracle database. I have joined all of the information from the
>database in this array using ':' as the delimiter. I then am trying to
>get each individule piece of information out of that array by putting it
>into another array called @opentickets. Here is how I am doing it:
>
>@opentickets = split(/:/, @openticketlist);
>
>When I print out the contents of @openticketlist, I see all of my
>information, nicely seperated by :s. When I print out my split array,
>instead of seeing the same information formated differently, I get the
>number 6. That's it, just the number 6. Is there something I am screwing
>up with the split function or am I going about this all the wrong way?
Let me guess... there are six items in the @openticketlist array...
what does the documentation say an array evaluates to in a scalar context?
Why are you treating an array as a string anyway - surely this seems a
little strange to you as well?
--
Sam
Simple rule: include files should never include include files.
--Rob Pike
------------------------------
Date: Thu, 10 Dec 1998 08:23:35 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Joined and split arrays
Message-Id: <MPG.10d99561eece729098994c@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and copy mailed.]
In article <366FE7C1.8FBFF8C1@Axom.com> on Thu, 10 Dec 1998 10:24:49 -
0500, Brad McBride <Brad.McBride@Axom.com> says...
...
> @opentickets = split(/:/, @openticketlist);
>
> When I print out the contents of @openticketlist, I see all of my
> information, nicely seperated by :s. When I print out my split array,
> instead of seeing the same information formated differently, I get the
> number 6. That's it, just the number 6. Is there something I am screwing
> up with the split function or am I going about this all the wrong way?
'split' splits a scalar into an array. In scalar context, an array
evaluates into its size. I'll bet that there are 6 elements in
@openticketlist.
You might try something like this:
@opentickets = split(/:/, join "", @openticketlist);
But it's not clear whether you should join with "" or ':'.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 10 Dec 1998 09:49:40 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Joined and split arrays
Message-Id: <kiqo47.802.ln@magna.metronet.com>
Brad McBride (Brad.McBride@Axom.com) wrote:
: I've just run into a problem that I'm not too sure how to fix.
: According to my documentation, this should work. I have an array called
: @openticketlist which is full of information (any number of rows) from
: an oracle database. I have joined all of the information from the
: database in this array using ':' as the delimiter. I then am trying to
: get each individule piece of information out of that array by putting it
: into another array called @opentickets. Here is how I am doing it:
: @opentickets = split(/:/, @openticketlist);
: When I print out the contents of @openticketlist, I see all of my
: information, nicely seperated by :s. When I print out my split array,
: instead of seeing the same information formated differently, I get the
: number 6. That's it, just the number 6. Is there something I am screwing
: up with the split function or am I going about this all the wrong way?
You are going about this the wrong way.
split() wants a _string_ as the second argument. You have
given in a list.
wrap the split() in a loop:
foreach $ticket_record (@openticketlist) {
@fields = split(/:/, $ticket_record);
# do something with the fields from this record
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Dec 1998 11:42:13 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Joined and split arrays
Message-Id: <366FF9E5.9D11EFD7@cthulhu.demon.nl>
Brad McBride wrote:
>
> @opentickets = split(/:/, @openticketlist);
>
> When I print out the contents of @openticketlist, I see all of my
> information, nicely seperated by :s. When I print out my split array,
> instead of seeing the same information formated differently, I get the
> number 6. That's it, just the number 6. Is there something I am screwing
> up with the split function or am I going about this all the wrong way?
Does your split array happen to have 6 elements? an expression of
the form @array in a scalar context evaluates to the number of elements
in the array...
Erik
------------------------------
Date: Thu, 10 Dec 1998 12:04:40 -0500
From: Niral Trivedi <niral@corporate.planet.net>
To: Brad McBride <Brad.McBride@Axom.com>
Subject: Re: Joined and split arrays
Message-Id: <366FFF27.58497B16@corporate.planet.net>
yeah.. u were right...u were mistankenly using array in the split
function... actually split works on a string and not an array....
i.e. u have to use like follwoing:
@opentickets = split(/:/,$openticketlist)
now as u have said that u are storing all the information from database
in array joining them with ':' and u are getting the result when u print
full array like @openticketlist.
the reason for this could be that all of u result after joining is
stored in the array but stored in the first position of the array.. i.e.
at $openticketlist[0] and not in the whole array.. because that is what
join() does.. it creates a string with joining parameter...
so, what u can do is first of all try to print out some data for the
openticketlist array(i.e. the first array u have created from the
database) using for loop and see what do u get in the other field of the
array..... and if u won't get anything in rest of the field except the
first i.e. $openticketlist[0] then u got the thing what u have to do...
i.e. try the following:
@openticket = split(/:/,$openticketlist[0])
hope that will work....
--
Regards...
********************************************
Niral K. Trivedi, Planet Access Network Inc.
Email : niral@corporate.planet.net
Phone : 973-691-4704
------------------------------
Date: Thu, 10 Dec 1998 17:03:57 +0000
From: Michael Renshaw <michaelr@lndn.tensor.pgs.com>
Subject: mail attachment
Message-Id: <366FFEFD.AE7@lndn.tensor.pgs.com>
does anyone know how to send a file as an attachment in perl.
i normally just open a pipe to the filehandle and print
all the lines to the file (im sure most of us do that) but
now i want something different, any ideas ???
thanx
Mike
------------------------------
Date: Thu, 10 Dec 1998 09:33:03 -0600
From: Alexander Bibighaus <alexb@sig.net>
Subject: namespace question
Message-Id: <366FE9AF.276FBFCD@sig.net>
I am confused on the namespaces. Any help or pointers to reading would
be beneficial.
Here is my question:
------------------------------
package Manager;
use CGI qw(:standard);
------------------------------
Are the CGI functions now part of the Manager package?
-----------------------------------------
package Director;
use vars qw(@ISA);
@ISA = qw(Manager);
use CGI qw(:standard);
-------------------------------------
What happens now that I have inherited from manager?
Are they defined twice?
thanks in advance,
alexander
------------------------------
Date: Thu, 10 Dec 1998 09:42:31 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie Question
Message-Id: <75qo47.uk1.ln@magna.metronet.com>
John Casey (jcasey@workingventures.ca) wrote:
: It is my first time in this news group so bear with me. I have been a
: VB programmer for years now. My boss just came up to me and asked me
: to learn CGI by yesterday.........AGHHHHHHH!!!
Does he wear his hair in a pointy style? ;-)
You can do CGI in any programming language.
VB will work (though perhaps not as well as Perl).
: I do not want to do the
: shell acount thing with my ISP. So my question is I have a web server
: at home running Omnicron HTTPd version 1.6. I know it supports
: CGI/Perl,
Perl does not equal CGI.
You can do CGI in any programming language.
: but I do not believe the interpreter comes with it. Does any
: one know where to get a simple shareware CGI/Perl interpreter that
: will work with the above mentioned software.
*All* Perl's are freely available.
PoBs expect to pay for stuff, but Perl doesn't come
from that world (thankfully).
Perl is available from
http://www.perl.com
or, more specifically:
http://www.perl.com/CPAN/src
or
http://www.perl.com/CPAN/ports
: Ummmmm and any good
: CGI/Perl tutorial pages that you would reccomend.
Once you get the perl distribution, avail yourself of the
*hundreds* of pages of documentation that comes with it.
Of particular interest to that minority that use Perl for
CGI programming is the Perl FAQ, part 9, titled "Networking":
-----------------
The useful FAQs and related documents are:
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
Web FAQ
http://www.boutell.com/faq/
WWW Security FAQ
http://www.w3.org/Security/Faq/
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
-----------------
Another part of the standard perl documentation cites these
resources:
-----------------
http://www.perl.com/perl/faq/idiots-guide.html
http://www.perl.com/perl/faq/perl-cgi-faq.html
ftp://rtfm.mit.edu/pub/usenet/news.answers/www/cgi-faq
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
-----------------
Note again that Perl does *not* equal CGI.
In fact, most Perl programming is *not* related to the WWW
(though this becomes less true with each passing day)
Perl was around for years before the WWW was even invented.
Ask Perl-specific questions here.
Ask CGI and server-specific questions in one of these other newsgroups:
comp.infosystems.www.advocacy
comp.infosystems.www.announce
comp.infosystems.www.authoring.cgi
comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.images
comp.infosystems.www.authoring.misc
comp.infosystems.www.browsers.mac
comp.infosystems.www.browsers.misc
comp.infosystems.www.browsers.ms-windows
comp.infosystems.www.browsers.x
comp.infosystems.www.misc
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
comp.infosystems.www.providers
comp.infosystems.www
comp.infosystems.www.users
Good luck!
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 10 Dec 1998 11:52:44 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: opening /dev/sequencer
Message-Id: <366FFC5B.98E68180@cthulhu.demon.nl>
Etienne Grossmann wrote:
>
> Hello, I have been trying to open /dev/sequencer for writing,
> without success. I have tried such things as :
>
> try1:
> open(FD,">/dev/sequencer") or die "NOPE\n";
> print FD "";
>
> try2:
> use IO::File;
> $fh = new IO::File "/dev/sequencer", O_WRONLY;
> print "NOPE\n" unless defined($fh);
>
> try3:
> use Fcntl;
> sysopen(FD,"/dev/sequencer",O_WRONLY) ;
> print FD "" ;
>
> but none of them work. In C, I can do
>
> fd = open("/dev/sequencer", O_WRONLY))
>
> and then use the handle without problem.
>
> Would anyone have an explanation to my troubles?
How about printing the cause of failing to open? Eg,
open(FD,">/dev/sequencer") or die "Could not open /dev/sequencer: $!\n";
Erik
------------------------------
Date: Fri, 11 Dec 1998 00:54:19 +0800
From: Silver CHEN <sansil@pchome.com.tw>
Subject: Out of memory!??
Message-Id: <366FFCBB.9CADE656@pchome.com.tw>
Dear sir:
I've a FreeBSD w/ 32M memory and very very big swap (about 200M+)
but when I run a data-comsuming perl program, it told me "Out of Memory!"
and quit.
I do sure the swap is large enough for this program, but why I got this
message still?
is there anything that can't be put in swap for perl? or something I missed?
However, I can run this program on a solaris 2.6 w/ 512M RAM smoothly.
Thanks for your help!
--
Silver CHEN
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4397
**************************************