Re: math module and array manipulation

2006-08-15 Thread David Greenberg
I'm sure there's an easier/better way of doing this, but in the interest of simplicity, let's look at this approach: First, a red flag goes up when you say that you have an array of 12 numbers. Will it always be twelve? The second red flag is that you are splitting the array into quarters based

Re: Problem com var on a require...

2004-11-09 Thread David Greenberg
I don't want to begin to understand why you're doing this, but if you make a.pl read: #!/usr/bin/perl $test = 'World!'; require 'b.def'; print $abacus; it should work. If you mean for b.def to define some standard functionality, try defining subs in it instead. -David On Tue, 9 Nov 2004 17:48:

Re: Passing shell variables to PERL

2004-10-05 Thread David Greenberg
$ENV{"ABC"} This works for me, but I don't have a good understanding of what is going on to make it work. HTH, David On Tue, 5 Oct 2004 14:32:27 -0400, Willy Perez <[EMAIL PROTECTED]> wrote: > > Hi, > > Is there a method to pass a shell assigned variable to perl? > > For ex: > > ABC=xyc > >

Re: String to Numeric of an Array

2004-09-14 Thread David Greenberg
In a few circumstances, such as binding parameters to a database, you may need to do this, but on the whole, as everyone else has pointed out, Perl will do this for you. If you are using this for one of those few cases, you can change them explicitly like this: @array = ('1','2','3'); @arrayNum =

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
etc. -David On Fri, 10 Sep 2004 14:37:28 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote: > On Fri, 10 Sep 2004 15:01:34 -0400, David Greenberg > <[EMAIL PROTECTED]> wrote: > > Opps, I missed that. Instead of: > > @results = map { my $line = $_; chomp $line; $line =~

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
Opps, I missed that. Instead of: @results = map { my $line = $_; chomp $line; $line =~ s/\s+//g; $line } (@data); try: my @newresults = map { my $line = $_; chomp $line; $line =~ s/\s+//g; shift (@results) . $line } (@data); @results = @newresults; -David On Fri, 10 Sep 2004 13:40:04 -0500, Erri

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
ith a foreach loop, it would be: my @results = (); foreach () { my $line = $_; chomp $line; $line =~ s/\s+//g; push (@results, $line); #appends $line to the @results list } Hope this helps. -David On Fri, 10 Sep 2004 11:58:30 -0500, Errin Larsen <[EMAIL PROTECTED]> wro

Re: How to dynamically taking the multiple input arguments?

2004-09-10 Thread David Greenberg
>foreach( @ARGV ) { > open IN, $_ or die "Couldn't open $_: $!\n"; > chomp( my @data = ); > close IN; > foreach( @data ) { s/\s+//g; } > foreach( 0..$#data ) { $results[$_] .= $data[$_]; } >} This is a little shorter and saves on iterations: for my $file (@ARGV) {

Re: Is my DB code bad?

2004-09-01 Thread David Greenberg
On Wed, 1 Sep 2004 15:42:16 -0500, Dave Kettmann <[EMAIL PROTECTED]> wrote: > First off, Thanks to Jenda and Wiggins for their quick response. I have found the > answer to my question in Jenda's help (the missing "'"'s) > I strongly suggest you take Jenda's advice about using placeholders instea

Re: Sed-type-function

2004-08-23 Thread David Greenberg
$str =~ s/Auth.notice: //; $str =~ s/\[[\]]*\]//; print $str; I'm not sure if there's a way to put it all in one line, but this should do it nonetheless. -David On Mon, 23 Aug 2004 14:31:01 -0500, Dave Kettmann <[EMAIL PROTECTED]> wrote: > Ok ... I'm going to try to confuse everyone again becau

Re: Data comparision analysis

2004-08-18 Thread David Greenberg
#!/usr/bin/perl use strict; open (GROUPFH, ") { chomp ($line); push (@groups, $line); } close (GROUPFH); open (USERFH, "File2"); my %group_to_users = (); while (my $line = ) { chomp ($line); my ($user, @user_groups) = split ('\s+', $line); for my $group (@user_groups) {

Re: globals

2004-08-17 Thread David Greenberg
If you really want to use a BAD method, which you should NOT use: while (...) { $total = $row[0]; ... } print $total . "\n"; What you SHOULD do is: use strict; ... my $total = ""; while (...) { $total = $row[0]; ... } print $total . "\n"; -David On Tue, 17 Aug 2004 10:55:25

Re: date calculations

2004-08-17 Thread David Greenberg
Date::Manip from CPAN -David On Tue, 17 Aug 2004 12:50:16 -0400, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > All, > > If I wanted to subtract 1 from a date on the 1st of any month what module > will reflect the correct date? For example, system time is 09.01.04 and I > want data from 08.31.0

Re: Sending Email

2004-08-16 Thread David Greenberg
Mail::Send and Mail::Mailer are a couple, though I'm sure there are others. -David On Mon, 16 Aug 2004 09:00:33 -0700, Fontenot, Paul <[EMAIL PROTECTED]> wrote: > I'm in need of a way to send the output of a script from a windows > server via email and I'm drawing a blank. What is the module call

Re: awk like question

2004-08-13 Thread David Greenberg
#!/usr/bin/perl use strict; open FH "filename.txt"; my %myhash = (); while (my $line = ) { if ($line =~ /(\S+)\s+(\S+)\s+\S+.*/) { $myhash{$1} = $2; } } ... __END__ -David On Fri, 13 Aug 2004 12:05:16 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote: > ok. I'm not getting my question across

Re: Here is the URL for Beginning Perl

2004-08-13 Thread David Greenberg
> > > I am sure the server is running, but typing in the ip address keeps > getting me a connection refused message. Hence, I think somewhere I need > to make myself an acceptable client. > Can you ping 127.0.0.1 or access ftp through that IP. If so, it probably is an http configuration. If not,

Re: Translate sed / Perl

2004-08-13 Thread David Greenberg
Hi Errin, Try something like this: #!/usr/bin/perl use strict; my $file = 'filename'; open FH "<$fh"; my $text = ""; while (my $line = and $line !~ /System Temperatures/) {} while (my $line = and $line !~ /==*/) { $text .= $line; } print $text; __END__ It may not be elegant, but it should wor