[22787] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5008 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 03:05:48 2003

Date: Tue, 20 May 2003 00:05:17 -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           Tue, 20 May 2003     Volume: 10 Number: 5008

Today's topics:
        Can I put an object in an object? <mail@annuna.com>
    Re: Can I put an object in an object? <tassilo.parseval@rwth-aachen.de>
    Re: Code reference from a subclass (Jay Tilton)
    Re: how to unzip a file with perl? <willis_31_40@yahoo.com>
    Re: HTML formatting is wrong from my script.... (Philip Lees)
        Inserting a record into a table using a value from a se (Uma Mahesh)
    Re: making scalar variables from array elements, put in (Jay Tilton)
    Re: multiple sort subroutine (Veky)
        Newbie question. Lookup multiple DBI connections <thepotplants@yahoo.com>
    Re: Newbie question. Lookup multiple DBI connections (Veky)
        Newbie Questions: functions <thepotplants@yahoo.com>
    Re: Newbie Questions: functions <jkeen@concentric.net>
    Re: Newbie Questions: functions <willis_31_40@yahoo.com>
    Re: Perl 5.8 memory leak while using shared variables <willis_31_40@yahoo.com>
    Re: Perl based shopping cart - does anyone have a recom <willis_31_40@yahoo.com>
    Re: Perl code segment <willis_31_40@yahoo.com>
    Re: perl to FTP ? <andrew.rich@bigpond.com>
    Re: PHP or Perl ? <willis_31_40@yahoo.com>
    Re: regular expression converting "April, 2000" to "200 <willis_31_40@yahoo.com>
        Sending email with perl. <chip@afcoms.NOSPAM.com>
    Re: Sending email with perl. <palladium@spinn.net>
    Re: Sending email with perl. <andrew.rich@bigpond.com>
    Re: Sorting $array[0] <willis_31_40@yahoo.com>
    Re: Tough question for the guru's; Grep Once, Awk Twice (Agrapha)
        Wanted: Perl Programmers in Houston Texas <willis_31_40@yahoo.com>
    Re: Why do I get double line feeds <willis_31_40@yahoo.com>
    Re: win32 perl installation perl mans? <kalinabears@hdc.com.au>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 20 May 2003 01:26:27 -0500
From: Joe Creaney <mail@annuna.com>
Subject: Can I put an object in an object?
Message-Id: <3EC9CA93.9020300@annuna.com>

Can I put an object in an object like this?

$var->{something} = Package::new(var1,var2);

That worked but how do I print out

print "$var->{something}->?\n";

I promise I will bottom post if I thank you for your help.



------------------------------

Date: 20 May 2003 06:56:30 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Can I put an object in an object?
Message-Id: <bacjiu$596$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Joe Creaney:

> Can I put an object in an object like this?
> 
> $var->{something} = Package::new(var1,var2);

Yes, even though the above should probably read

    $var->{something} = Package->new(...);

Constructors belong into a package so they should be called as
class-methods. Be sure that new() treats the first argument it receives
as name of a package (or object from which the package can be retrieved
using ref()).

> That worked but how do I print out
> 
> print "$var->{something}->?\n";

If you have the quotes you can't easily call methods upon the objects.
But you can do

    print $var->{something}->method, "\n";

Accessing the internals of your object also works in double-quotish
context:

    print "$var->{something}->{member}\n";

If you really insist on interpolating method-calls in your strings, do

    # list-context
    print "@{[ $var->{something}->method ]}\n";

    # scalar-context
    print "${ \($var->{something}->method) }\n";

The latter wont always behave as expected, though.

> I promise I will bottom post if I thank you for your help.

Oh, good! :-)

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Tue, 20 May 2003 04:14:54 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Code reference from a subclass
Message-Id: <3ec92a40.29925573@news.erols.com>

Juan Francisco Fernandez Carrasco <juanf@lsi.upc.es> wrote:

: I have two classes which are like this: A is B's superclass. I also 
: have a method "newAddr" in A which gets the code reference from the 
: method "new". I thought this scheme would give  me the code reference 
: of B's "new" if I would call  "newAddr" from a B instance, but this is 
: not what happens. It gives me the code reference of A's "new" instead.
:
: The trivial solution, which is to put "newAddr" in class B is not
: possible.

It's not just the trivial solution, it's the correct solution.
The method's code reference is essentially class data.  You are trying
to obtain that class data without using the class implementation.

: Could anybody help me with this?
: Why I get the to te code  reference of the superclass  (A) instead of
: that of the subclass (B)?

The newAddr method lives in package A.  Calling it from package B does
not magically put its code (and any symbols used in that code, like
&new) into package B.  Inheritance does not mean symbols are exported.

:  What is the way to access the right code reference withou moving
: "newAddr" from A?

Symbolically.

    sub newaddr{
        my $self = shift;
        my $res = \&{ref($self) . "::new"};
        return $res;
    }

I wonder why that doesn't violate "use strict 'refs';".
I'd bet it exploits the mechanism perl itself uses to symbolically
resolve method calls into the appropriate package.

When newaddr is called by an object from a subclass that has no new()
method, what would you expect to happen?

What could you use the constructor's coderef for, anyway?
It seems an odd thing to want, and would be of limited utility unless
you already know the package name.



------------------------------

Date: Tue, 20 May 2003 04:15:56 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: how to unzip a file with perl?
Message-Id: <mvajcvg2j5bk8lfgnptnirukclltt16os8@4ax.com>

On 17 May 2003 09:11:11 -0700, niudou@hotmail.com (niudou) wrote:

>Is there any module(pm files) to deal with the "unzip" process just as
>WINZIP or WINRAR does?
>
>Thanks in advance!


search.cpan.org


------------------------------

Date: Tue, 20 May 2003 06:20:51 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: HTML formatting is wrong from my script....
Message-Id: <3ec9c70f.61394687@news.grnet.gr>

On 19 May 2003 10:58:38 -0700, carterave@yahoo.com (Jim Carter) wrote:

>How can I get the exact output (from __DATA__ in the script) on the
>html page?

1. Check carefully that your data lines are as you expect them to be -
i.e. with the correct number of tabs on each line.

2. Add the lines

use strict;
use warnings;

at the start of your script.

3. Run the script from the command line and fix any errors that are
reported (hint: declare all variables with 'my').

4. If you're still not getting the result you want, strip out all the
excess HTML (e.g. the FONT tags) so you have the minimum code you need
for testing.

5. Alter the script to write its output to a file. Check the HTML in
that file to see if it's what it should be.

When you have it working from the command line, only then test it in a
Web environment. After that, you might start to wonder why you have 

use CGI ':standard'; 

at the beginning of the script when you don't use any of the
functionalities that that module provides.

Phil

-- 
Ignore coming events if you wish to send me e-mail


------------------------------

Date: 19 May 2003 22:41:28 -0700
From: uma@bluemartini.com (Uma Mahesh)
Subject: Inserting a record into a table using a value from a sequence
Message-Id: <e20faad0.0305192141.163f0b21@posting.google.com>

Hi there,

I want to insert a record into a database table with a value from a sequence.

When ever I try to do that I get a invalid number.

Any help or pointers are appreciated.

Thanks,
Uma


------------------------------

Date: Tue, 20 May 2003 04:27:19 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: making scalar variables from array elements, put into table
Message-Id: <3ec9abdd.63111378@news.erols.com>

lepore@brandeis.edu (bryan) wrote:

: here's an excerpt of the real code:
: ##-- begin excerpt --##
:           $SITE_B_X_COORD_1 = ($SITE_B_X_COORD);          
:           $SITE_B_Z_COORD_1 = ($SITE_B_Z_COORD);
[etc.]

: @equivalent_positions = (
:           $SITE_B_X_COORD_1,    
:           $SITE_B_Z_COORD_1,
[etc.]

: 			    );
: foreach $i (@equivalent_positions){
:     if ( $i < 0  ) {
: 	$i_alternate = (1+$i);
: 	}
:     else {
: 	$i_alternate = (-1+$i);
:     }
: ##--- end excerpt ---##

One closing curly brace too early.  The rest of the loop would be of
interest.  Most interesting would be the section of code where the
table is actually printed.

: so the array elements are "$SITE_B_X_COORD" etc.,

More accurately, the array elements are the values of $SITE_B_X_COORD
etc.

: and the scalar variables are in the foreach loop.

You have two scalar variables in the foreach loop, $i and 
$i_alternate.  The important one seems to be $i_alternate.

:  so i THINK i want to initialize
: some scalar variables by performing an operation on array elements.  i
: want the scalar variables to be read into a table.

The explanation is on the edge of clarity.

When the code creates the table, is it using the value in $i, the
value in $i_alternate, or the values in $SITE_B_X_COORD_1 etc?  Or
something else entirely?

: but still, it's as if the loop isn't getting parsed or
: something.  but the loop in fact does the correct calculations, 

I see.  Restating the problem:  Where does that correctly calculated
value end up, and how is that different from where you are looking for
it?  The answer to neither part of that question is obvious from the
code snippet above.

: and... vide supra.

Heh.  I mistook the unfamiliar term for a catastrophic typo, but
looked it up anyway.  I am mortified for not recognizing Latin.
"see above."

:                   --> the simple question <--
: so i guess the simple question is, can i make scalar variables from
: array elements?

Yes.  In the same way you assigned a list of scalar values to an
array, i.e.

     @equivalent_positions = ($foo, $bar, $baz);

you may assign the array's values to a list of scalars.

    ($foo, $bar, $baz) = @equivalent_positions;
 
: btw, i just bought "programming perl", and i'll have to look at
: "scope"

Simply, a variable's "scope" is the section of program where it can
accessed by name.  Apparently, your program uses package (i.e. global)
variables exclusively[1].  Variable scoping is likely not the issue.

That's not to say scoping is not an important concept to grasp.
Understanding variable scoping and how to control it is a vital first
step to proficiency.

[1]Here's where somebody will knot your brain by mentioning that the
foreach loop localizes the value of $i, giving it a completely
different kind of scope.



------------------------------

Date: Tue, 20 May 2003 00:58:43 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: multiple sort subroutine
Message-Id: <babuk3$f5p$1@bagan.srce.hr>

Dok je Veky citao comp.lang.perl.misc, 
pod PIDom 13196 (290357 off, 10 to go...),
primijetio je kreaturu zvanu 
quantum_mechanic_1964@yahoo.com (Quantum Mechanic),
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:

|Ahh, thanks, I had forgotten about that.
|Then I just need to remember to use $; outside of hash key context, such as:
|  # %x has keys like $x{$y$z}...
|  $k = 'something';
|  @keys_i_want = grep /$;$k/, keys %x;
|[although I probably shouldn't index %x this way.]

Probably. :-)

-- 
\#{%	Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...


------------------------------

Date: Tue, 20 May 2003 13:53:52 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Newbie question. Lookup multiple DBI connections
Message-Id: <eVfya.13815$3t6.149439@news.xtra.co.nz>

I want my program to store multiple database connection strings in a flat
file.

So when a user wants to connect to a particular application they pass a
variable $app for example $app = sap
I want my programme to 'lookup' the row and return the connection string,
username and password.

My program should conect using:
$dbh = DBI->connect('$constring, '$uid', '$pwd')

I want my file to look like:
sap|'DBI:oracle:databas1'| 'usernam1'| 'pwdx'
fin |'DBI:sybase:database'| 'usernam2'| 'pwdx'
hr  |'DBI:oracle:database3'| 'usernam5'| 'pwdx'

Questions:
1: What s the best way to refer to an external file that is only used for
'lookups'.

2:  How do I get a row in a flat file back as several variables?
  eg is my user selects 'fin' I want $constring, $uid and $pwd from the
file.







------------------------------

Date: Tue, 20 May 2003 02:00:17 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: Newbie question. Lookup multiple DBI connections
Message-Id: <bac27h$a3j$1@bagan.srce.hr>

Dok je Veky citao comp.lang.perl.misc, pod PIDom 13784 (290371 off, 0 to go...),
primijetio je kreaturu zvanu "ThePotPlants" <thepotplants@yahoo.com>,
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:

|1: What s the best way to refer to an external file that is only used for
|'lookups'.

tie .

|2:  How do I get a row in a flat file back as several variables?
|  eg is my user selects 'fin' I want $constring, $uid and $pwd from the
|file.

split .

-- 
\#{%	Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...


------------------------------

Date: Tue, 20 May 2003 14:04:12 +1200
From: "ThePotPlants" <thepotplants@yahoo.com>
Subject: Newbie Questions: functions
Message-Id: <W2gya.13838$3t6.149554@news.xtra.co.nz>

I want to write my programme as functions and call them from a main
programme.

I've seen you can call subroutines, and pass variables. how do I do this if
it is a seperate file?

Also, I want the subroutine/function to chew through a list, can I pass
multiple values to a subroutine?
eg.call subroutine copy_table $taskname %table
(and $table could be 10 tables.)







------------------------------

Date: 20 May 2003 02:39:41 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Newbie Questions: functions
Message-Id: <bac4hd$7d3@dispatch.concentric.net>


"ThePotPlants" <thepotplants@yahoo.com> wrote in message
news:W2gya.13838$3t6.149554@news.xtra.co.nz...
> I want to write my programme as functions and call them from a main
> programme.
>
> I've seen you can call subroutines, and pass variables. how do I do this
if
> it is a seperate file?
>
> Also, I want the subroutine/function to chew through a list, can I pass
> multiple values to a subroutine?
> eg.call subroutine copy_table $taskname %table
> (and $table could be 10 tables.)
>
Read the documentation:
perldoc perlsub
perldoc perlmod




------------------------------

Date: Tue, 20 May 2003 04:10:55 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Newbie Questions: functions
Message-Id: <0lajcvkmhmvckeaaln5lpthv0uds2f43sm@4ax.com>

You are talking about writing a module.

Read this... http://perlmonks.com/index.pl?node_id=102347

w i l l



On Tue, 20 May 2003 14:04:12 +1200, "ThePotPlants"
<thepotplants@yahoo.com> wrote:

>I want to write my programme as functions and call them from a main
>programme.
>
>I've seen you can call subroutines, and pass variables. how do I do this if
>it is a seperate file?
>
>Also, I want the subroutine/function to chew through a list, can I pass
>multiple values to a subroutine?
>eg.call subroutine copy_table $taskname %table
>(and $table could be 10 tables.)
>
>
>
>



------------------------------

Date: Tue, 20 May 2003 04:18:41 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Perl 5.8 memory leak while using shared variables
Message-Id: <h2bjcv0eib5lf6nev9m453sim4325i453e@4ax.com>

On 19 May 2003 02:17:05 -0700, prakashpms@hotmail.com (Prakash) wrote:

>I am writing a threaded application using perl 5.8. I am having a
>shared array which shared between the threads. While using shared
>array, it results in memory leaks. Seems like this is a known problem.
>I saw from the newsgroup that Elizabeth   Mattijsen had faced the same
>problem and could workaround the problem by rewriting a new module
>Forks.pm which emulates threads. But, we are looking at offical patch
>release kind of stuff. Is there any patch or workarcound for this?
>
>Thanks
>Best Regards
>Prakash


Are there any specific modules you're using?


------------------------------

Date: Tue, 20 May 2003 04:13:30 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Perl based shopping cart - does anyone have a recommendation?
Message-Id: <8qajcvs8bccpecth09cte4kmmqn0o76lip@4ax.com>

On Mon, 19 May 2003 13:43:59 -0600, "Rodney" <palladium@spinn.net>
wrote:

>"Steinar Kjærnsrød" <kjaernsr@online.no> wrote in message
>news:G01ya.13564$8g5.213590@news2.e.nsc.no...
>> While it might be fun to reinvent this wheel, I don't have the time, and
>was
>> wondering if anyone has recommendations on Perl based shopping
>> carts/shopping systems? My problem is certainly not that I can't find any,
>> but rather the opposite! There seem to be lots of such systems around and
>> it's difficult to get a grasp on the pros and cons by just reading the
>> announcements and basic documentation.
>>
>> The system I'm looking for need not be freeware/GPL based, but should
>> preferrably cost no more than ~300-600$.
>>
>> I'm not looking for fully fledged e-commerce systems/application servers.
>> The system/modules/scripts should as a minimum offer/implement this:
>>
>> + easy to interface to a product database/inventory, preferrably through
>DBI
>> or through generic interfaces
>> + the same goes for the customer database
>> + stateful shopping basket, tracking the customers shopping in each
>session
>> (client side code OK, i.e. Javascript ++). The shopping basket should
>allow
>> for easy adding and removal of items, changing the number of items,
>checkout
>> etc
>> + HTML (Javascript ok) based GUI through templates, preferrably through
>the
>> Template TK
>>
>> Any hints, tips and experiences with such software will be appreciated.
>> Thanks in advance,
>>
>> --
>> Steinar Kjærnsrød kjaernsr@online.no
>>
>>
>How about RedHat's Interchange on Linux?
>
It was after investigating Interchange that I decided to roll my own
:)

w i l l


------------------------------

Date: Tue, 20 May 2003 04:15:40 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Perl code segment
Message-Id: <3tajcvcppqsg9u8ba1ll9864tjskspvbc2@4ax.com>

On Sat, 17 May 2003 12:31:30 +1000, "Bob" <bigbadbob@yahoo.com> wrote:

>Can anyone assist in helpiing decode this code fragment ?
>Or tell me what it might be doing ?
>
>($level, $group, $status, $failed) = ($line =~
>/^NetWorker\s+Savegroup:\s+\((\w+)\)\s(.*)\s(\w+),\s+\d+\sclient\(s\)\s\((.*
>)\)\n$/);
>
>
>


There is a variable called $line that get's split on different
criteria and then shoved into 4 different variables, $level, $group,
$status, and $failed.

at least that's what it looks like to me :)

w i l l


------------------------------

Date: Tue, 20 May 2003 16:21:57 +1000
From: "Andrew Rich" <andrew.rich@bigpond.com>
Subject: Re: perl to FTP ?
Message-Id: <pan.2003.05.20.06.21.57.830143@bigpond.com>

#!/usr/bin/perl
    use Net::FTP;
    $ftp = Net::FTP->new("192.168.0.3", Debug => 1);
    $ftp->login("user",'pass');
    $ftp->type("I");
    $ftp->get("file");
    $ftp->quit;




------------------------------

Date: Tue, 20 May 2003 04:16:47 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: PHP or Perl ?
Message-Id: <s0bjcvcjhlh0tqdjeach17so29coepkolk@4ax.com>

On 18 May 2003 07:01:58 GMT, "Tassilo v. Parseval"
<tassilo.parseval@rwth-aachen.de> wrote:

>Also sprach Dieter D'Hoker:
>
>> How would you advice someone who wants to start learning a programmign
>> language for developping websites ?
>> learning PHP or Perl ?
>
>Depends on your ambitions. Considering the fact that PHP is quite good
>for website development while Perl is an all-purpose language, learn PHP
>if all you ever want to do is going to happen in web context. You'll
>only regret this decision when you suddenly realize you want to do more.
>
>But why not have a glance at both of them? Then pick the one that is
>more to your liking.
>
>> Or maybe somethign else like Coldfusion , or java servlets , Python ?
>> 
>> and why ?
>
>What I wrote in the first paragraph is actually a little simplistic. PHP
>has a particular view on web-sites (HTML mangled with PHP code). In Perl
>it is often the other way round (a complete Perl script that generates
>the HTML code). However, Perl can also be used in the very same way as
>PHP (namely through Embperl which embeds Perl into HTML). As a rule of
>thumb: Perl has many ways of integrating programming logic and HTML.
>This is 'less' true for PHP.
>
>Tassilo


PHP or Perl?

yes.


------------------------------

Date: Tue, 20 May 2003 04:34:53 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: regular expression converting "April, 2000" to "2000-04" - help!
Message-Id: <qubjcvkoad7lsj24n10jki4k27ejre4b2f@4ax.com>

On 16 May 2003 00:57:01 -0700, leifwessman@hotmail.com (Leif Wessman)
wrote:

>I have two types of strings that I would like to convert to dates
>
>"04 April, 2000" and "March, 2000"
>
>should be converted to
>
>"2000-04-04" and "2000-03"
>
>Can someone give me a hint of one regular expression that does what I want?
>
>If it's not possible, then how should I do it?
>
>Leif




put the month names and corresponding values, into a hash.

my %hash = (
april => 04,
 ...
);

then do a simple match and substitution.

w  i l l


------------------------------

Date: Tue, 20 May 2003 02:41:04 GMT
From: "Chip" <chip@afcoms.NOSPAM.com>
Subject: Sending email with perl.
Message-Id: <4Bgya.1313$7S2.1028589@news1.news.adelphia.net>

I am trying to have a simple script email me when a
server is not responding to ping.

I can run mailx from the command line and it works
fine but the script never sends mail.

I also tried Net::smtp with no luck.



#!/usr/bin/perl
#
use Net::Ping;

@hosts = ("192.168.0.1", "192.168.0.2", "192.168.0.3");

while (1)
  {
    $p = Net::Ping->new();
    foreach (@hosts)
      {
        if ($p->ping($_))
          {
            print "$_ is alive\n";
          }
        else
          {
            print "$_ is DOWN!.\n";
            system("mailx administrator@host.com", "Alert", "Server $_ is
down", ".", " ");
          }
        $p->close();
        sleep 15;
      }
  }

Any and all help is greatly appriceated,
Chip




------------------------------

Date: Mon, 19 May 2003 20:25:49 -0600
From: "Rodney" <palladium@spinn.net>
Subject: Re: Sending email with perl.
Message-Id: <vcj95q6k95fn8d@corp.supernews.com>

"Chip" <chip@afcoms.NOSPAM.com> wrote in message
news:4Bgya.1313$7S2.1028589@news1.news.adelphia.net...
> I am trying to have a simple script email me when a
> server is not responding to ping.
>
> I can run mailx from the command line and it works
> fine but the script never sends mail.
>
> I also tried Net::smtp with no luck.
>
>
>
> #!/usr/bin/perl
> #
> use Net::Ping;
>
> @hosts = ("192.168.0.1", "192.168.0.2", "192.168.0.3");
>
> while (1)
>   {
>     $p = Net::Ping->new();
>     foreach (@hosts)
>       {
>         if ($p->ping($_))
>           {
>             print "$_ is alive\n";
>           }
>         else
>           {
>             print "$_ is DOWN!.\n";
>             system("mailx administrator@host.com", "Alert", "Server $_ is
> down", ".", " ");
>           }
>         $p->close();
>         sleep 15;
>       }
>   }
>
> Any and all help is greatly appriceated,
> Chip
>
>
How about Mail::Mailer or Net::SMTP ?





------------------------------

Date: Tue, 20 May 2003 16:18:04 +1000
From: "Andrew Rich" <andrew.rich@bigpond.com>
Subject: Re: Sending email with perl.
Message-Id: <pan.2003.05.20.06.18.04.557063@bigpond.com>

#!/usr/bin/perl
    use Net::Ping;
    $host="192.168.0.3";
    $p = Net::Ping->new();
    if ($p->ping($host))
    {
    print "$host is alive.\n";
    }
    else
    {
    system ("mail -v -s HOST_DOWN email@address");
    }
    $p->close();














#!/usr/bin/perl
foreach my $file (<*.pl>)
{
next unless -f $file;
open FILE, $file or die "Can not open $file $!\n";
print "Processing ".$file." ......\n";
system ("mail -v -s $file email@address < $file ");
system ("mail -v -s $file email@address < $file ");
sleep 2;
}



------------------------------

Date: Tue, 20 May 2003 04:32:06 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Sorting $array[0]
Message-Id: <vtbjcvkdi31hvnj3qv93n67mutjmspufvu@4ax.com>

On 15 May 2003 13:51:19 -0700, leftshoe06@yahoo.com (nbh) wrote:

>Given
>
>@a1 = qw(17 abc);
>@a2 = qw(9 zya);
>@a3 = qw(44 asdff);
>
>$array[0] = \@a1;
>$array[1] = \@a2;
>$array[2] = \@a3;
>
>
>
>How to sort $array by the first element and maintain the connection with 17 to abc?




http://www.google.com/search?q=schwartzian+transform






------------------------------

Date: 20 May 2003 00:02:08 -0700
From: brian@box201.com (Agrapha)
Subject: Re: Tough question for the guru's; Grep Once, Awk Twice (or more)
Message-Id: <11aabb15.0305192302.40c57223@posting.google.com>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<b8iqr3$g6r$1@nets3.rz.RWTH-Aachen.DE>...

> Same here. Also, you only ever access the fourth and eigth element of
> the list returned by split. You can make that explicit:
> 

first quick question, if I load my hash array with data, when I print
it to the screen how do I sort only on the key and not the value?

>     foreach (@badcalls) {
>         my ($users, $code) = (split)[3,7];
>         $error_codes{ $code }++;
>         $error_users{ $users }++;
>         $err_per_usr{ "$users:$code" }++;
>     }
> 
> For $err_per_usr you could also use a nested data-structure, a hash of
> hashes probably:
> 
>     $err_per_usr{ $user }->{ $code }++;
>     

these hashes are hard for me to understand how to manipulate.

> > #####
> > # this one is broke I am supposed to get the 3 columns but
> > # I dont know how to do that yet
> > ###
> >         print "\nNumber / Error / Totals\n";
> >         print "-----------------------\n";
> >         foreach my $key (keys %err_per_usr) {
> >                 print "$key\t\/\t$err_per_usr{$key}\n";
> >         }
> 
> This is because %err_per_usr wasn't properly created. If it is a
> two-dimensional hash, it could look like:
> 
>     while (my ($user, $val) = each %err_per_usr) {
>         # $val is now a hash-ref
>         my %errors = %$val;
>         # proceed
>     }
> 

I have tried a few different renditions but my hashes are not working.
I think a hash of hashes is what I am looking for but I can't work out
the correct syntax.

Each line of my file has a phone number and an error-code. (column 4
and 8) what I would like to do is count how many times each phone
number returns each error code. The data output should look something
like:
number       error   qty
2005551313 - 101,4 - 23
2005551313 - 63,44 - 42
2005551700 - 60,42 - 10

so my question is, Am I trying to do a hash of hashes?


------------------------------

Date: Tue, 20 May 2003 04:09:27 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Wanted: Perl Programmers in Houston Texas
Message-Id: <0dajcv41km7vmsama1fknri59fvp3pg378@4ax.com>

The Houston (Texas) Perl Mongers group is being resurrected. Please,
if you are in the area and enjoy hanging around chatting about perl
with other geeks then join us.

We meet every 4th Friday of the month from 7pm-?? at HAL-PC.

HAL-PC: http://www.hal-pc.org/
Perl Mongers: http://www.pm.org/

w i l l


------------------------------

Date: Tue, 20 May 2003 04:29:55 GMT
From: w i l l <willis_31_40@yahoo.com>
Subject: Re: Why do I get double line feeds
Message-Id: <4kbjcvg7u5i6p1rkps2vlkbtmcapflprq0@4ax.com>

On Wed, 14 May 2003 01:50:47 GMT, "Travis" <dingdongy2k@hotmail.com>
wrote:

>print MEMCHK "$used_timein[$j]\n";
>
>I am writing to file and simply want to get each line with a single line
>feed.
>
>For some reason I get the single line feed when I leave off the \n and I get
>a double line feed when
>I leave it in?
>
>Any ideas?
>

the string, or rather scalar, $used_timein[$1], ends with a "\n". I'd
either chomp() the variable value, or do a substitution on the value
brfore printing to MEMCHK.

chomp($used_timein[$j]);
print MEMCHK "$used_timein[$j]\n";

should work fine

or something *like*

$used_timein[$j] =~ s/\n+?//g; 

this code is untested, try it before you buy it :)

w i l l


------------------------------

Date: Tue, 20 May 2003 13:28:54 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: win32 perl installation perl mans?
Message-Id: <3ec9a201$0$22129@echo-01.iinet.net.au>


"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:2_9ya.17185$NC4.76203@news1.mts.net...
> "Ryan & Treena Carrier" <ryanc@nci1.net> wrote in message
>  news:ac1c94bd16ceabec96638efbdbe77bde@TeraNews...
> > I'm running ActiveState's perl engine.  When a module is not available
> > through ppm, and I get it from CPAN, I install using the perl
Makefile.PL,
> > nmake, nmake test, nmake install method.  Is there a way (from the
> > command line, maybe?) to get to the man pages (pods)?  When a
> > module is installed through ppm, it automagically installs the man
> > pages within the 'documentation' web page.
>
> Assuming you're referring to the html docs generated from
> the pods, and not the unix man pages, what you could do
> within the distribution's source directory is generate the
> html pages from the pods of the distribution, copy them to
> blib/html/, make a .ppd file through 'nmake ppd', make a .tar.gz
> archive of the blib/ directory, and then do a 'ppm install
> Name_of_local_ppd_file.ppd' - this will, in addition to what is
> done by 'nmake install', also copy the html docs to the relevant
> location on your system and update the table of contents
> accordingly. The PPM::Make module on CPAN can help
> with a number of these steps.
>
> best regards,
> randy kobes
>
>
>

Not sure that the op is aware of perl's pod2html utility.
That being the case, see 'perldoc pod2html'.

Cheers,
Rob




------------------------------

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 5008
***************************************


home help back first fref pref prev next nref lref last post