[25668] in Perl-Users-Digest
Perl-Users Digest, Issue: 7909 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 29 12:26:59 2005
Date: Tue, 29 Mar 2005 09:26:51 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 29 Mar 2005 Volume: 10 Number: 7909
Today's topics:
A hash or array of regexp's? <shoppa@trailing-edge.com>
Re: A hash or array of regexp's? xhoster@gmail.com
Re: A hash or array of regexp's? <pilkowsk@informatik.uni-marburg.de>
Re: A hash or array of regexp's? <shoppa@trailing-edge.com>
Re: a program to delete duplicate files alanwo@gmail.com
Re: Absolute path problem <nobull@mail.com>
accessing arrays in a different sub-routine <ewitkop90@hotmail.com>
Re: accessing arrays in a different sub-routine <ewitkop90@hotmail.com>
Re: accessing arrays in a different sub-routine <mritty@gmail.com>
Re: accessing arrays in a different sub-routine <1usa@llenroc.ude.invalid>
Re: accessing arrays in a different sub-routine <ewitkop90@hotmail.com>
Re: accessing arrays in a different sub-routine <1usa@llenroc.ude.invalid>
Re: accessing arrays in a different sub-routine <notvalid@email.com>
Re: accessing arrays in a different sub-routine <mritty@gmail.com>
Anyone with experience usging ADO for Oracle? <centuryinnovative@gmail.com>
Re: Anyone with experience usging ADO for Oracle? robic0@yahoo.com
Re: Anyone with experience usging ADO for Oracle? robic0@yahoo.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Mar 2005 06:31:03 -0800
From: "Tim Shoppa" <shoppa@trailing-edge.com>
Subject: A hash or array of regexp's?
Message-Id: <1112020263.855594.86360@l41g2000cwc.googlegroups.com>
I often find myself with a list of things that I'm searching for. And
for each of the things I'm searching for, there's an action I want to
do.
Sometimes the "search for" pattern is just the first four characters in
the line, for example. Here things are easy: I build a hash with the
key being the four-character pattern, and the value being the
subroutine to execute. Works very nicely: get each line, use a
substr() to extract the first four characters, look them up in the
hash, and execute the correct subroutine. Very quick, very fast, very
idiomatic.
But other times the patterns are not so easily handled. Often they are
true regexp's, matching variable repeats/patterns. This of course can
be handled with if matches and blocks to do the actions, but this
screams out to me as something that I ought to be able to handle using
a data structure which is something like a hash, using regexp's as
keys.
Pages 193/194 of the Camel book reveal how to loop over a bunch of
precompiled regexp's, using qr// to precompile the regexp's, and this
isn't bad. But it's not quite the same as a hash lookup. And it seems
to me that there ought to be an idiom, maybe a CPAN module, that makes
the whole operation look more like a hash lookup, because that's how I
think of it in my head, even though I know that regexp's aren't really
as quick or efficient as simple keys.
So, is there a common perl idiom for dealing with this situation?
Maybe a CPAN module?
Tim.
------------------------------
Date: 28 Mar 2005 15:46:58 GMT
From: xhoster@gmail.com
Subject: Re: A hash or array of regexp's?
Message-Id: <20050328104658.301$2F@newsreader.com>
"Tim Shoppa" <shoppa@trailing-edge.com> wrote:
> I often find myself with a list of things that I'm searching for. And
> for each of the things I'm searching for, there's an action I want to
> do.
>
> Sometimes the "search for" pattern is just the first four characters in
> the line, for example. Here things are easy: I build a hash with the
> key being the four-character pattern, and the value being the
> subroutine to execute. Works very nicely: get each line, use a
> substr() to extract the first four characters, look them up in the
> hash, and execute the correct subroutine. Very quick, very fast, very
> idiomatic.
>
> But other times the patterns are not so easily handled. Often they are
> true regexp's, matching variable repeats/patterns. This of course can
> be handled with if matches and blocks to do the actions, but this
> screams out to me as something that I ought to be able to handle using
> a data structure which is something like a hash, using regexp's as
> keys.
>
> Pages 193/194 of the Camel book reveal how to loop over a bunch of
> precompiled regexp's, using qr// to precompile the regexp's, and this
> isn't bad. But it's not quite the same as a hash lookup. And it seems
> to me that there ought to be an idiom, maybe a CPAN module, that makes
> the whole operation look more like a hash lookup, because that's how I
> think of it in my head, even though I know that regexp's aren't really
> as quick or efficient as simple keys.
Also, any given string can match many different regexes, while there is
exactly one hash key it can match. Trying to munge such a situation into a
hash-like idiom seems very misleading and just asking for trouble.
I'd just use an array of arrays, with each inner array being of length 2,
a regex/action pair.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 29 Mar 2005 02:26:18 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: A hash or array of regexp's?
Message-Id: <3arlkhF6ddiamU1@individual.net>
* Tim Shoppa schrieb:
> I often find myself with a list of things that I'm searching for. And
> for each of the things I'm searching for, there's an action I want to
> do.
>
> Sometimes the "search for" pattern is just the first four characters in
> the line, for example. Here things are easy: I build a hash with the
> key being the four-character pattern, and the value being the
> subroutine to execute. Works very nicely: get each line, use a
> substr() to extract the first four characters, look them up in the
> hash, and execute the correct subroutine. Very quick, very fast, very
> idiomatic.
>
> But other times the patterns are not so easily handled. Often they are
> true regexp's, matching variable repeats/patterns. This of course can
> be handled with if matches and blocks to do the actions, but this
> screams out to me as something that I ought to be able to handle using
> a data structure which is something like a hash, using regexp's as
> keys.
>
> So, is there a common perl idiom for dealing with this situation?
I would do this with an array containing a regex as each second element
and the callback in the following one, then iterating over this array
while skipping the callback elements.
#!/usr/bin/perl -w
use strict;
my @array = (
qr/(line\s(\d)\2)/ => sub { print "match: $1" },
# ...
);
while ( <DATA> ) {
for my $i ( 0 .. @array-1 ) {
next if $i % 2; # skip if odd
my( $re, $sub ) = @array[ $i, $i+1 ];
$sub->() if $_ =~ $re; # callback
}
}
__DATA__
line 10
line 11
line 12
>
> Maybe a CPAN module?
The Modul Tie::HashRef is moving around the problem of stringified hash
keys. Perhaps it accepts a reference to a regex as keys -- the doc isn't
talking about and neither I checked it out yet.
regards,
fabian
------------------------------
Date: 29 Mar 2005 06:12:43 -0800
From: "Tim Shoppa" <shoppa@trailing-edge.com>
Subject: Re: A hash or array of regexp's?
Message-Id: <1112105563.364606.83860@g14g2000cwa.googlegroups.com>
Fabian Pikowski wrote:
> The Modul Tie::HashRef is moving around the problem
Thanks for the tip, it's not only a tied hash but also a useful
object-oriented approach to looking for matches. It takes "qr//" forms
directly as the key, no need stringify/destringify. And to answer the
other reply, the approach taken ("first match") works fine for my
purposes.
I know it's not really a hash (with all the efficiencies that would be
implied if it was) but I like to think in terms of a hash, and
Tie::HashRef works wonderfully for this.
Tim.
------------------------------
Date: 29 Mar 2005 00:56:48 -0800
From: alanwo@gmail.com
Subject: Re: a program to delete duplicate files
Message-Id: <1112086608.687402.61000@z14g2000cwz.googlegroups.com>
Why not try to use NoClone, it finds and deletes duplicate files by
true byte-by-byte comparison. Smart marker filters duplicate files to
delete. With GUI.
http://noclone.net
Xah Lee wrote:
> here's a large exercise that uses what we built before.
>
> suppose you have tens of thousands of files in various directories.
> Some of these files are identical, but you don't know which ones are
> identical with which. Write a program that prints out which file are
> redundant copies.
>
> Here's the spec.
> --------------------------
> The program is to be used on the command line. Its arguments are one
or
> more full paths of directories.
>
> perl del_dup.pl dir1
>
> prints the full paths of all files in dir1 that are duplicate.
> (including files in sub-directories) More specifically, if file A has
> duplicates, A's full path will be printed on a line, immediately
> followed the full paths of all other files that is a copy of A. These
> duplicates's full paths will be prefixed with "rm " string. A empty
> line follows a group of duplicates.
>
> Here's a sample output.
>
> inPath/a.jpg
> rm inPath/b.jpg
> rm inPath/3/a.jpg
> rm inPath/hh/eu.jpg
>
> inPath/ou.jpg
> rm inPath/23/a.jpg
> rm inPath/hh33/eu.jpg
>
> order does not matter. (i.e. which file will not be "rm " does not
> matter.)
>
> ------------------------
>
> perl del_dup.pl dir1 dir2
>
> will do the same as above, except that duplicates within dir1 or dir2
> themselves not considered. That is, all files in dir1 are compared to
> all files in dir2. (including subdirectories) And, only files in dir2
> will have the "rm " prefix.
>
> One way to understand this is to imagine lots of image files in both
> dir. One is certain that there are no duplicates within each dir
> themselves. (imagine that del_dup.pl has run on each already) Files
in
> dir1 has already been categorized into sub directories by human. So
> that when there are duplicates among dir1 and dir2, one wants the
> version in dir2 to be deleted, leaving the organization in dir1
intact.
>
> perl del_dup.pl dir1 dir2 dir3 ...
>
> does the same as above, except files in later dir will have "rm "
> first. So, if there are these identical files:
>
> dir2/a
> dir2/b
> dir4/c
> dir4/d
>
> the c and d will both have "rm " prefix for sure. (which one has "rm
"
> in dir2 does not matter) Note, although dir2 doesn't compare files
> inside itself, but duplicates still may be implicitly found by
indirect
> comparison. i.e. a==c, b==c, therefore a==b, even though a and b are
> never compared.
>
>
> --------------------------
>
> Write a Perl or Python version of the program.
>
> a absolute requirement in this problem is to minimize the number of
> comparison made between files. This is a part of the spec.
>
> feel free to write it however you want. I'll post my version in a few
> days.
>
> http://www.xahlee.org/perl-python/python.html
>
> Xah
> xah@xahlee.org
> http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: Wed, 23 Mar 2005 08:51:46 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Absolute path problem
Message-Id: <d1rac6$mn4$1@sun3.bham.ac.uk>
seema wrote:
> I am fresher learning perl programming.
So it is quite likely that most questions you have will be one that are
frequently asked.
> Is it possible
> to resolve the (.,~) to give the absolute path. for
> example to parse strings like "~john" or "../john/LFS"
> to get the absolute path of directory specified.
Those are two separate questions. ~ and .. are conceptually very
different - one is part of the shell and the other part of the filesystem.
Both questions are frequently asked and one is even Frequently Asked.
The answer to one is Cwd::abspath but that you probably really should
not do it - it is usually detremental to convert a relative path to an
absolute one. See numerous previous threads for details.
The answer to the other question is in the FAQ.
------------------------------
Date: 28 Mar 2005 11:21:28 -0800
From: "erik" <ewitkop90@hotmail.com>
Subject: accessing arrays in a different sub-routine
Message-Id: <1112037688.658680.167210@g14g2000cwa.googlegroups.com>
I tried to find the answer on the web, camel book, and did not know
which perldoc to look in(perlop did not have it). I also tried a few
different things to make it work, any nothing has worked.
I dynamically create an array from an expect output. I want to then
print it out in a different array. I research references private vs.
global scalars and did not find my answer. This is my code:
#!/usr/bin/perl
#################################################################
# Global Variables #
#################################################################
use warnings;
use Expect;
use CGI(":standard");
$Expect::Log_Stdout = 0;
$device = param("device");
$username = param("username");
$password = param("password");
$enable = "enable";
$save = "wr mem";
$enable_password = param("enable_password");
$service_type = param("service_type");
my $datetemp = `date +%x_%r`;
my @dateStamp = split('\n',$datetemp);
my @bandwidth_array;
my $bandwidth_array;
(SNIP)
##################################################################
# Now we check for bandwidth statement #
###################################################################
sub bandwidth_router_check{
$timeout ="15";
my $bandwidth = "The router has at least 1 bandwidth statement";
my $no_bandwidth = "The router is missing a bandwidth statement";
$command->clear_accum();
print $command "show config \| inc band\r";
unless ($command->expect($timeout, -re, '#')) {
return "Never got telnet prompt".$command->exp_error()."\n";
}
my $bandwidth_capture = $command->exp_before();
my @bandwidth_array = split ('\n', $bandwidth_capture);
#HERE WE CHECK LOGGING
if ($bandwidth_capture =~ /band.*/)
{
push (@band_tests, $bandwidth);
$band_action = "OK";
}
else{
push (@band_tests, $no_bandwidth);
$band_action = "FAIL";
}
print "bandwidth_array 1 is $bandwidth_array[1]\n"; #THIS PRINT WORKS
GREAT!
};#end sub
Then I call it in a different sub-routine.
################################################################### #
Prints the main parameters that should be in ALL routers #
###################################################################
sub print_main_report
{
my @bandwidth_array;
my $bandwidth_array;
print "Content-type: text/html\n\n";
print "<html><head><title>QA REPORT</title></head>";
print "<body bgcolor=#000000>";
print "<p align=center><b><font color=#FFFFFF size=5>ROUTER QA
REPORT</font></b></p>";
print "<br>";
print "<p align=center><font color=#FFFFFF><b>Date: $dateStamp[0]
EST<b></font></p>";
print "<br>";
print "<body><font color=#FFFFFF><b>QA Report for:
$device<b></font></body>";
print "<br>";
print "<br>";
#we print for bandwidth
if ($band_action eq "OK")
{
print "<body><font
color=33CC33>@band_tests.............$band_action</font></body>";
}
else{
print "<body><font
color=FF0000>@band_tests.............$band_action</font></body>";
}
print "<br>";
print "<body>bandwidth_array 1 is $bandwidth_array[1]</body>";
#THIS DOES NOT PRINT AN ELEMENT, IT PRINT AN EMPTY ELEMENT.
print "<br>";
}
Can anyone give me some input? I tried to may the refences to it global
instead of scoped, but that did not do it. How should this sort of
thing be done?
------------------------------
Date: 28 Mar 2005 11:42:04 -0800
From: "erik" <ewitkop90@hotmail.com>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <1112038924.196811.281490@f14g2000cwb.googlegroups.com>
I dynamically create an array from an expect output. I want to then
print it out in a different array. I research references private vs.
global scalars and did not find my answer. This is my code:
I had a typo here, should read:
I dynamically create an array from an expect output. I want to then
print it out in a different sub-routine. I research references private
vs.
global scalars and did not find my answer. This is my code:
------------------------------
Date: Mon, 28 Mar 2005 20:06:23 GMT
From: Paul Lalli <mritty@gmail.com>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <3tZ1e.28793$qN3.986@trndny01>
erik wrote:
> I tried to find the answer on the web, camel book, and did not know
> which perldoc to look in(perlop did not have it). I also tried a few
> different things to make it work, any nothing has worked.
>
> I dynamically create an array from an expect output. I want to then
> print it out in a different array.
This is non-sensical. Arrays do not print anything.
> I research references private vs.
> global scalars and did not find my answer.
I don't think you researched enough.
> This is my code:
> #!/usr/bin/perl
> #################################################################
> # Global Variables #
> #################################################################
> use warnings;
You are forgetting "use strict;"
> use Expect;
> use CGI(":standard");
> $Expect::Log_Stdout = 0;
> $device = param("device");
> $username = param("username");
> $password = param("password");
> $enable = "enable";
> $save = "wr mem";
> $enable_password = param("enable_password");
> $service_type = param("service_type");
There is no reason to make any of these package variables. They should
all be declared with 'my'
> my $datetemp = `date +%x_%r`;
> my @dateStamp = split('\n',$datetemp);
> my @bandwidth_array;
This variable, having been declared lexical outside of any subroutine,
will be accessable anywhere below its declaration.
> my $bandwidth_array;
That's a remarkably poor choice of a variable name. For one, you
already have an array named "bandwidth_array". (Just because Perl
allows this doesn't make it a good idea). For two, this isn't an array,
it's a scalar.
> (SNIP)
> ##################################################################
> # Now we check for bandwidth statement #
> ###################################################################
> sub bandwidth_router_check{
> $timeout ="15";
> my $bandwidth = "The router has at least 1 bandwidth statement";
> my $no_bandwidth = "The router is missing a bandwidth statement";
> $command->clear_accum();
> print $command "show config \| inc band\r";
> unless ($command->expect($timeout, -re, '#')) {
> return "Never got telnet prompt".$command->exp_error()."\n";
> }
> my $bandwidth_capture = $command->exp_before();
> my @bandwidth_array = split ('\n', $bandwidth_capture);
You are declaring a new lexical array. This array will be valid for the
duration of this subroutine, and will then disappear. For the remainder
of this subroutine, this new variable masks the existing lexical you
decalred above.
>
> #HERE WE CHECK LOGGING
>
> if ($bandwidth_capture =~ /band.*/)
> {
> push (@band_tests, $bandwidth);
> $band_action = "OK";
> }
> else{
> push (@band_tests, $no_bandwidth);
> $band_action = "FAIL";
> }
>
> print "bandwidth_array 1 is $bandwidth_array[1]\n"; #THIS PRINT WORKS
> GREAT!
Of course it does. You're printing the second element of the variable
you just declared in this subroutine.
>
> };#end sub
>
>
> Then I call it in a different sub-routine.
>
> ################################################################### #
> Prints the main parameters that should be in ALL routers #
> ###################################################################
> sub print_main_report
> {
> my @bandwidth_array;
Now here's another entirely new lexical. This one again masks the first
one you declared, and is valid for the duration of this subroutine. It
has absolutely nothing whatsoever to do with either the variable you
declared in the previous subroutine, or with the variable you declared
at the top of the file.
> my $bandwidth_array;
<snip>
> print "<body>bandwidth_array 1 is $bandwidth_array[1]</body>";
> #THIS DOES NOT PRINT AN ELEMENT, IT PRINT AN EMPTY ELEMENT.
Of course it does. You're trying to print the second element of an array
you never added anything to.
> print "<br>";
> }
>
> Can anyone give me some input? I tried to may the refences to it global
> instead of scoped, but that did not do it. How should this sort of
> thing be done?
You generally have two options:
1) Make a variable that is lexically scoped to the entire file. You put
one declaration near the top of the file, just as you did here. You
then simply *use* that variable. Don't declare any more variables of
the same name.
2) Have the function that first sets the variable declare the variable
lexically scoped to the function itself, and then pass that variable (or
at least its value) around using array parameters and function return
values.
You should probably read "Coping with Scoping", which talks about the
different scopes of variables.
http://perl.plover.com/FAQs/Namespaces.html
Paul Lalli
------------------------------
Date: Mon, 28 Mar 2005 22:19:22 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <Xns9627B03A3C424asu1cornelledu@127.0.0.1>
"erik" <ewitkop90@hotmail.com> wrote in news:1112037688.658680.167210
@g14g2000cwa.googlegroups.com:
> my $datetemp = `date +%x_%r`;
In addition to Paul Lalli's excellent commnents elsethread, let me please
ask, WHY?
No need to spawn an external program to just a get a timestamp.
perldoc -f time
perldoc -f localtime
> my @dateStamp = split('\n',$datetemp);
perldoc -f chomp
See also the strftime function in the POSIX module.
The only reason you declare and use @dateStamp is to get rid of the EOL at
the end of $datetemp. You might think the above is harmless, but puzzling
gems like this make your programs hard to read later.
Sinan
------------------------------
Date: 28 Mar 2005 14:38:16 -0800
From: "erik" <ewitkop90@hotmail.com>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <1112049496.433969.94040@g14g2000cwa.googlegroups.com>
I just read that, thanks. That sheds some light. So basically with my
example above, and due to it's dynamic nature, the only way I can get
this working is a sub-function within a subfunction. I really didn't
want to do that, but I take it I have no choice. I thought I could do
my $bandwidth_array; in my printing sub-routine but like you said, it
in't DOING anything.
I liked this line from the coping with scope.
When to Use my and When to Use local
Always use my; never use local.
Wasn't that easy?
BTW, what was wrong with the name that I gave my array
@bandwidth_array? You lost me on that one.
------------------------------
Date: Mon, 28 Mar 2005 23:05:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <Xns9627B81D150D6asu1cornelledu@127.0.0.1>
"erik" <ewitkop90@hotmail.com> wrote in news:1112049496.433969.94040
@g14g2000cwa.googlegroups.com:
> I just read that, thanks.
Please quote an appropriate amount of context when replying.
> That sheds some light. So basically with my
> example above, and due to it's dynamic nature, the only way I can get
> this working is a sub-function within a subfunction. I really didn't
> want to do that, but I take it I have no choice.
You lost me here.
Here is a simple example of what you can do:
#! /usr/bin/perl
my $files = read_files_in_current_dir();
$files or die "No files in current directory\n";
my_print($files);
sub read_files_in_current_dir {
opendir my $dir, '.'
or die "Cannot open current directory: $!";
[ grep { -f } readdir $dir ];
}
sub my_print {
print "$_\n" for sort @{ shift() };
}
__END__
The first subroutine you call generates the array you want, and returns
a reference to it. Then, you pass that reference to other subroutines
that work on the array.
No need for nested subroutines.
> BTW, what was wrong with the name that I gave my array
> @bandwidth_array? You lost me on that one.
For me, the '@' in front of the name already signifies that the variable
is an array, why replicate that information?
Sinan
------------------------------
Date: Mon, 28 Mar 2005 23:42:20 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <wD02e.16371$C47.6452@newssvr14.news.prodigy.com>
A. Sinan Unur wrote:
> "erik" <ewitkop90@hotmail.com> wrote in news:1112049496.433969.94040
> @g14g2000cwa.googlegroups.com:
>>BTW, what was wrong with the name that I gave my array
>>@bandwidth_array? You lost me on that one.
>
>
> For me, the '@' in front of the name already signifies that the variable
> is an array, why replicate that information?
Actually, Paul was commenting on this:
>> my $bandwidth_array;
This is a scalar, not an array (note the leading '$' sigil). Having the
name of a scalar end in '_array' can lead to confusion.
--Ala
------------------------------
Date: Tue, 29 Mar 2005 15:15:36 GMT
From: Paul Lalli <mritty@gmail.com>
Subject: Re: accessing arrays in a different sub-routine
Message-Id: <sie2e.31229$qN3.11897@trndny01>
I wrote, but erik didn't quote:
> You generally have two options:
> 1) Make a variable that is lexically scoped to the entire file. You
> put one declaration near the top of the file, just as you did here.
> You then simply *use* that variable. Don't declare any more variables
> of the same name.
> 2) Have the function that first sets the variable declare the variable
> lexically scoped to the function itself, and then pass that variable
> (or at least its value) around using array parameters and function
> return values.
erik wrote:
> I just read that, thanks. That sheds some light. So basically with my
> example above, and due to it's dynamic nature, the only way I can get
> this working is a sub-function within a subfunction. I really didn't
> want to do that, but I take it I have no choice.
How does anything I said above translate to this? I said nothing about
nested subroutines. I simply said to not re-declare your variable
within the subroutine. Just use the variable you already have:
my $foo;
sub fctn1{
$foo = 1;
}
sub fctn2{
print "Foo = $foo\n";
}
fctn1(); #$foo gets set here
fctn2(); #$foo gets printed here.
Your problem is that you had additional "my $foo;" statements within
fctn1 and fctn2. Get rid of them.
> BTW, what was wrong with the name that I gave my array
> @bandwidth_array? You lost me on that one.
Well, if you'd bother quoting what was said:
erik wrote:
> my $bandwidth_array;
I replied:
> That's a remarkably poor choice of a variable name. For one, you
> already have an array named "bandwidth_array". (Just because Perl
> allows this doesn't make it a good idea). For two, this isn't an
> array, it's a scalar.
you'd see that I did not say @bandwidth_array is a poor name. I said
that $bandwidth_array is a poor name. Those are two wholly unrelated
variables. They have nothing to do with one another. Naming the same
name implies that they do. Plus, naming a scalar variable
"something_array" is just a bad idea, I hope for obvious reasons.
Out of curiousity, have you read the posting guidelines for this group yet?
Paul Lalli
------------------------------
Date: 28 Mar 2005 14:54:04 -0800
From: "angell" <centuryinnovative@gmail.com>
Subject: Anyone with experience usging ADO for Oracle?
Message-Id: <1112050444.319703.160190@z14g2000cwz.googlegroups.com>
Gurus,
Please help. I am new to Active Perl. I downloaded Active Perl 5.6 to
my local PC(Win2000 professional). I installed DBI-Oracle and tried to
access database through DBI in a standalone perl program, it worked
fine.
Then I tried to use ADO in my asp pages.(I installed IIS as well and
set up the system DSN "sd11".) I copied the code from the documentation
and appended them to my asp page.
<%
$Conn = $Server->CreateObject("ADODB.Connection");
$Conn->Open("sd11");
$RS = $Conn->Execute("SELECT * from orders");
$count = $RS->Fields->{Count};
$Conn->Close();
%>
I keep getting this error message:
"Can't call method "Fields" on an undefined value ". It seems the $RS
object is not initiated. I don't have Access installed on my PC, so I
couldn't test out whether my system DSN is created. But my gut feeling
is that I'm missing sth else here.
Can someone please help me out?
------------------------------
Date: Mon, 28 Mar 2005 22:55:09 -0800
From: robic0@yahoo.com
Subject: Re: Anyone with experience usging ADO for Oracle?
Message-Id: <blth41h69tbp323s842g74pflb027qdl3k@4ax.com>
On 28 Mar 2005 14:54:04 -0800, "angell" <centuryinnovative@gmail.com>
wrote:
>Gurus,
>
>Please help. I am new to Active Perl. I downloaded Active Perl 5.6 to
>my local PC(Win2000 professional). I installed DBI-Oracle and tried to
>access database through DBI in a standalone perl program, it worked
>fine.
>
>Then I tried to use ADO in my asp pages.(I installed IIS as well and
>set up the system DSN "sd11".) I copied the code from the documentation
>and appended them to my asp page.
>
><%
> $Conn = $Server->CreateObject("ADODB.Connection");
>
> $Conn->Open("sd11");
>
> $RS = $Conn->Execute("SELECT * from orders");
>
> $count = $RS->Fields->{Count};
> $Conn->Close();
>%>
>
>I keep getting this error message:
>"Can't call method "Fields" on an undefined value ". It seems the $RS
>object is not initiated. I don't have Access installed on my PC, so I
>couldn't test out whether my system DSN is created. But my gut feeling
>is that I'm missing sth else here.
>
>Can someone please help me out?
How did you setup your ODBC service provider?
Post your udl...
What version ADO u got?
You should try to doing ADO inside ATL instead
of a script lang like perl or java.
I don't know if you understand ADO. Its ActiveX
Data Object. From script you should be calling
a com object and getting back a recordset to work on
instead of trying to do it all from script.
The ADO paradigm is too slow from script but if you are determined
MS has tons of ado (java) includes. As for Perl, I would doubt a
fractured lang such as this would be anywhere near complete.
-just my $.02
------------------------------
Date: Mon, 28 Mar 2005 23:00:49 -0800
From: robic0@yahoo.com
Subject: Re: Anyone with experience usging ADO for Oracle?
Message-Id: <t5vh41l5duoh4g9sdjrsrrkthqmlsett00@4ax.com>
On Mon, 28 Mar 2005 22:55:09 -0800, robic0@yahoo.com wrote:
>On 28 Mar 2005 14:54:04 -0800, "angell" <centuryinnovative@gmail.com>
>wrote:
>
>>Gurus,
>>
>>Please help. I am new to Active Perl. I downloaded Active Perl 5.6 to
>>my local PC(Win2000 professional). I installed DBI-Oracle and tried to
>>access database through DBI in a standalone perl program, it worked
>>fine.
>>
>>Then I tried to use ADO in my asp pages.(I installed IIS as well and
>>set up the system DSN "sd11".) I copied the code from the documentation
>>and appended them to my asp page.
>>
>><%
>> $Conn = $Server->CreateObject("ADODB.Connection");
>>
>> $Conn->Open("sd11");
>>
>> $RS = $Conn->Execute("SELECT * from orders");
>>
>> $count = $RS->Fields->{Count};
>> $Conn->Close();
>>%>
>>
>>I keep getting this error message:
>>"Can't call method "Fields" on an undefined value ". It seems the $RS
>>object is not initiated. I don't have Access installed on my PC, so I
>>couldn't test out whether my system DSN is created. But my gut feeling
>>is that I'm missing sth else here.
>>
>>Can someone please help me out?
>
>How did you setup your ODBC service provider?
>Post your udl...
>What version ADO u got?
>You should try to doing ADO inside ATL instead
>of a script lang like perl or java.
>I don't know if you understand ADO. Its ActiveX
>Data Object. From script you should be calling
>a com object and getting back a recordset to work on
>instead of trying to do it all from script.
>The ADO paradigm is too slow from script but if you are determined
>MS has tons of ado (java) includes. As for Perl, I would doubt a
>fractured lang such as this would be anywhere near complete.
>
>-just my $.02
>
I meant, as for Perl, I doubt a good ADO module could have been
written to encapsulate oledb et all....
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7909
***************************************