Re: Why does this code fail? - Sorry here are the line numbers..

2002-12-16 Thread Dave Storrs
On Sat, Dec 14, 2002 at 12:51:50PM -0500, [EMAIL PROTECTED] wrote: > Can somebody tell what is wrong with this. > > I tried single quote (') in place of double quote(") neither of them work. > > 184 for ($i = 0; $i < @clm_types; $i++) > 185 { > 186@temp_str = grep (/$_/,@env_desc); > 187@

Re: Net::SFTP causes script to exit if connection can't be made

2002-12-16 Thread Dave Storrs
Zentara is right about what you need to do, but a fuller explanation of the solution would have been: Net::SFTP is throwing an exception when it cannot make the connection. If the exception is not caught, it will cause your program to exit. The way you catch exceptions in Perl is to wrap the cod

context of function calls

2002-03-28 Thread Dave Storrs
Hey folks, Executive summary: It looks like, no matter what context foo() is called in, its arguments are always evaluated in list context. Is this correct? I had always understood that: - a function's arguments were evaluated in the same context as the context of the function (hmm...ac

Re: aritmetic operators

2002-03-25 Thread Dave Storrs
Hi Matthew, First of all, subtracting scalars is perfectly valid, so the actual error must be something else. Here are three things you should check. 1) First, you don't have a semicolon at the end of that line. 2) Second, if you are operating under 'use strict', you will need to predeclare yo

Re: Sort of Conceptual, Syntax, and modules related questions

2002-03-23 Thread Dave Storrs
Hi Connie, > On Sat, Mar 23, 2002 at 05:30:25AM +0800, Connie Chan wrote: > > 1. When I open a text file with *lines, however, I just want to read the > > first line, would this be a good idea ? open (FILE, "textfile.txt"); > > $firstline = ; close (FILE); would this process run till EOF, or > >

Re: tie/bless interactions?

2002-03-14 Thread Dave Storrs
was giving the APC::Event a "has-a" relationship with the Tie::DBI, and then delegating (through AUTOLOAD) calls to the Tie::DBI. It ended up working great! Dave Storrs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

tie/bless interactions?

2002-03-13 Thread Dave Storrs
olve this by doing this: my $rh_self = \%self; unshift @{$rh_self->ISA}, 'APC::Event'; 5) Given the above constructor code, am I likely to have any problems with circular references? Thanks in advance, Dave Storrs PS If you wanted to rewrite the code snippet in qu

Re: Test Automation

2001-11-27 Thread Dave Storrs
Check CPAN for: Test::Unit Test::Simple Test::More and a few others. Dave On Mon, 26 Nov 2001, Ahmed Moustafa Ibrahim Ahmed wrote: > Hi Everybody, > > How can I automate the process of testing my Perl script? > Is there a standard way to do? > Is there a tool for testing Perl scripts? > > Yo

Re: directories

2001-11-21 Thread Dave Storrs
Any of the following should work for you: if ( -e $dirpath && -d $dirpath ) { ...stuff...} if ( -e $dirpath && -d _ ) { ...stuff...} if ( -d $dirpath ) { ...stuff...} You can always substitute $dirpath for a literal string path in the above as well...e.g.: if ( -d '/usr/bin/home' ) { ... stuff

Re: capture song title

2001-11-16 Thread Dave Storrs
On Fri, 16 Nov 2001, KeN ClarK wrote: > I want to capture the title of the current song I have running on my box > through mpg123 and redirect it to a file. In this process, I don't want > the /long/path/to/song but just the song.mp3. Is it possible to capture > the song title this way? > > Ken

Re: Time Related

2001-11-16 Thread Dave Storrs
Here are two approaches: 1) Make sure that every record in the log file includes a timestamp. Parse all lines, locate the first timestamp that is >= (CT - 1 hour), using everything after that line. 2) Rename the log file every hour so that you start 24 separate logs each day, an

RE: Populating a referenced hash

2001-11-16 Thread Dave Storrs
On Fri, 16 Nov 2001, Tomasi, Chuck wrote: > Good point. I should be a little more imaginative. Sometimes making up > meaningful variable and function names is the hardest part of writing code. It is indeed! > Another thing I found about the references, the order of the parameters >

RE: Modules

2001-11-16 Thread Dave Storrs
> > In practical daily use, use(); is preferred as since it compiles the > > module as soon as it sees 'use Foo::Bar;' before moving on, this will > > catch errors and scope conflicts far sooner than if you use require(); > > There aren't many good reasons to use require, at least I > > can't thin

RE: Populating a referenced hash

2001-11-16 Thread Dave Storrs
This may or may not solve your problem, but Name your sub something other than 'ref'. Ref is a reserved word in Perl. (perldoc -f ref for details on what it does) Dave > > > --arg.pl--- > > > #/usr/plx/bin/perl -w > > > > > > use strict; > > > > > > sub ref > > > { >

Re: What is "bubble sort"?

2001-11-16 Thread Dave Storrs
On Fri, 16 Nov 2001, Pete Emerson wrote: > I got this from http://www.wikipedia.com/wiki/Radix_sort: > > QUOTE > Radix sort is a sort algorithm that operates in O(n) time. This algorithm was > orignally > used to sort punched cards in several passes. It has resurfaced as an > alternative to > o

Re: Updating a hash using a refernece?

2001-11-14 Thread Dave Storrs
On Tue, 13 Nov 2001, AMORE,JUAN (HP-Roseville,ex1) wrote: > How do I update the value pointed to by key "PAGER" from more to pg. > when using a reference only to the hash element for key "PAGER". > > > %Unix= ("SHELL" => "/bin/csh", >"PAGER" => "more", >"DB" => "mysql"); > > print "Val

RE: What was your first PERL script (was Off-Topic (200%) - Whereare you from?)

2001-11-14 Thread Dave Storrs
Mine was to write a document-management system for Paine Webber. Of course, I had the advantage of working with two or three other Perl programmers, all of whom were substantially skilled. Still, that was how I first got exposed to the language. (AFAIK, PW is still using that system; they hire

Re: installing modules

2001-11-13 Thread Dave Storrs
On Tue, 13 Nov 2001, Rahul Garg wrote: > i have actually got the solution. > if i have the module Bar.pm in directory '/usr/home/rahul/myMod' > then in the perl script that uses this module i have to include the > statement > > use lib '/usr/home/rahul/myMod' ; > use Bar ; > > Thanks, > Rahul

Re: Off-Topic (200%) - Where are you from?

2001-11-13 Thread Dave Storrs
At the moment, New York, a.k.a. "Terrorist Target Number #1" :/ Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: SecureCRT + Perl

2001-11-09 Thread Dave Storrs
Ah. Ok, now I understand. Sorry, no experience with such things. Dave On Fri, 9 Nov 2001, A. Rivera wrote: > I'm talking about using scripts in the tradition of clients like Telemate, > Telix, ZOC. Where the script rests on the client side, and it is used to > interact with the remote sess

Re: installing modules

2001-11-09 Thread Dave Storrs
Since I suspect your next question would be "Ok, then how do I install the CPAN module?" let me head this one off. The CPAN module (CPAN.pm) comes with the basic distro of Perl, so you should already have it. Say you want to install the "CGI.pm" module from CPAN. At your command line, you typ

Re: SecureCRT + Perl

2001-11-09 Thread Dave Storrs
Um...not sure what you're asking for here. I use SecureCRT all the time (using it right now, in fact), and I do in fact write Perl while securely telnetted into various machines. What do you want to do? Dave On Thu, 8 Nov 2001, A. Rivera wrote: > Has anyone tried to use SecureCRT with Perl

Re: vars as key/value in a hash

2001-11-09 Thread Dave Storrs
FYI, Tyler, the reason that this will do what you want is because you're original program wasn't doing what you thought. %stations = ( $names[0] => $names[1] ); This creates a list of two elements and assigns it to the hash named %stations. Therefore, $names[0] becomes the one and only

Re: regexp with $ARGV

2001-11-08 Thread Dave Storrs
On Mon, 5 Nov 2001, Martin Karlsson wrote: > Thanks a lot for your help and your time! I think I've got it solved > now. You're welcome. :> > Could any of you recommend a good book for (learning) Perl? There seems > to be quite a few to choose from... Oddly enough, that's w

(Slightly OT) RE: terminating input

2001-11-04 Thread Dave Storrs
On Sun, 4 Nov 2001, Gary L. Armstrong wrote: > I am amazed. How does someone figure out that you can do this sort of thing? > > chomp($value[++$i] = ); > > I mean, $value[++$i]? That really works? Crazy. [...] Well, that's mostly a C-style issue (and yes, it is crazy). C programme

Re: regexp with $ARGV

2001-11-04 Thread Dave Storrs
Martin, I'm not entirely clear on what you're trying to do here, so if this doesn't help, let me know and I'll try again. I think the problem is that you're doing this: s/$ARGV[0]/\($ARGV[0]\)/g ...when you want to affect $ARGV[0]. But remember that s/// and m// are, b

OT: dB pooling in Perl (was Re: Perl with Java)

2001-11-04 Thread Dave Storrs
On this subject: I am currently trying to sell Perl in my (highly Java-biased) shop, and having an uphill battle of it. One of the things that the brass wants to see is support for database connection pooling in a multi threaded environment. Now, I'm sure that Perl can do this, but it isn't som

Re: HOw do I create a package:

2001-11-03 Thread Dave Storrs
With all due respect, this list is here to help beginner perl programmers deal with programming problems, not to do people's homework for them. (The 'hp.com' address (which prominently dispalys an ad for "hp's online university") is a bit of a giveaway.) Read this: perldoc perlmod Dave On Sa

Re: merging two hashes together?

2001-11-03 Thread Dave Storrs
In the example you provide, this will work: -START %h1 = ("one" => 1, "two" => 2, "three" => 3); %h2 = ("four" => 4, "five" => 5, "six" => 6); # Note that the '&' on function calls is optional, unlike $, @, and % $ref_h3 = mergehash(_, _); sub mergehash { m

Re: Access MS SQL using DBI / DBD

2001-11-01 Thread Dave Storrs
Hi Pathi, There is an excellent book from O'Reilly _Programming the Perl DBI_. It has a leopard on the cover, and it should answer every question you could possibly desire concerning the DBI. HTH, Dave On Tue, 30 Oct 2001, Erramilli, Pathi (P.) wrote: > Hi, > > I am new to

Re: Unable to display output

2001-10-18 Thread Dave Storrs
On Wed, 17 Oct 2001, nafiseh saberi wrote: > in perl , > if u want see in screen must write : > print "\n"; > before things you want to to print. > I mean that you must print one empty line and then > print things u wants > __ > Best regards .

Re: XMLParser and Perl

2001-10-18 Thread Dave Storrs
Go to http://search.cpan.org/ and type "XML" into the search box. There are a whole bunch of XML modules that will make your life much easier. In general, "go to CPAN and look for a module" is the answer to most problems in Perl...the number of modules is HUGE, and no matter what you need, there

RE: Anyone know to how use subroutines to add or multiply numbers :How would I modify my file:

2001-10-18 Thread Dave Storrs
y( @ARGV ); > print "The product is :$rtn"; > } > > sub add { > my @list = @_; > my $sum = 0; > $sum += $_ foreach (@list); } # <= This was missing > > sub multiply { > my @list = @_; > my $prod = 1; > $prod *= $_ foreach (@l