[16700] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4112 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 23 21:10:38 2000

Date: Wed, 23 Aug 2000 18:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967079417-v9-i4112@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 Aug 2000     Volume: 9 Number: 4112

Today's topics:
    Re: newbie question - dont flame me <ren.maddox@tivoli.com>
    Re: Perl vs. other scripting languages <taboo@comcen.com.au>
    Re: Perl vs. other scripting languages (brian d foy)
    Re: Perl vs. other scripting languages (brian d foy)
        perl/Informix jblatz2@my-deja.com
        Remote Host Feedback? testversion1@hotmail.com
    Re: s''' not behaving as expected <rick.delaney@home.com>
        Self-Answering Questions (Was Re: Flipflop matching) <jeff@vpservices.com>
    Re: Self-Answering Questions (Was Re: Flipflop matching <lr@hpl.hp.com>
        Set @ARGV and ignore STDIN? philip.hibbs@tnt.co.uk
        To push or not to push <smerr612@mailandnews.com>
    Re: To push or not to push <uri@sysarch.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 23 Aug 2000 15:30:55 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: newbie question - dont flame me
Message-Id: <m3n1i37m9s.fsf@dhcp11-177.support.tivoli.com>

filosmith@my-deja.com writes:

> if I print it during the foreach below, it works fine. It goes through
> each server and makes a hash called $displayName with keys called
> $uName that have values called $uFName.
> 
> I guess it goes through each individual hash okay.
> 
> foreach $displayName (keys %serverList)
> {
> $adsDomain = Win32::OLE->GetObject($serverList{$displayName});
> $domainEnumerator = Win32::OLE::Enum->new($adsDomain);
> while (defined($domainObject = $domainEnumerator->Next))
> {
>   if ($domainObject->Class eq "User")
>   {
>   $uName = $domainObject->Name;
>   $uFName = $domainObject->FullName;
>   $displayName{$uName} = $uFName;
> ###############
> #### if i print at this point it comes out fine.
> ###############

I don't think this is doing what you think it is doing.  It is not, as
it seems you expect, creating separate hashes for each value of
$displayName.  Instead, it creates a single hash, %displayName, and
puts all of the data in that one hash.  I already posted the changes
that would be required to get what it appears you want.  Basically,
use $displayName{$displayName}{$uName}.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 23 Aug 2000 22:28:31 +1000
From: "Kiel" <taboo@comcen.com.au>
Subject: Re: Perl vs. other scripting languages
Message-Id: <39a3c36f$1_3@nexus.comcen.com.au>


"KN" <khayyam.noon@unisys.com> wrote:
>What are the pros and cons of using Perl versus other scripting languages?>
>Can anyone help and direct me to where I can find this information.
>
>
>
>
Try perl.org, pm.org or cpan.org


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

Date: Wed, 23 Aug 2000 21:02:57 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Perl vs. other scripting languages
Message-Id: <brian-ya02408000R2308002102570001@news.panix.com>

In article <39a3c36f$1_3@nexus.comcen.com.au>, "Kiel" <taboo@comcen.com.au> posted:

> "KN" <khayyam.noon@unisys.com> wrote:
> >What are the pros and cons of using Perl versus other scripting languages?>
> >Can anyone help and direct me to where I can find this information.

> Try perl.org, pm.org or cpan.org

i'm not sure what you'll find at any of those.  perl.org and pm.org
are just domains.  there are no machines or content to address.

www.perl.org doesn't advocate Perl at the expense of other tools.

www.pm.org is for Perl user groups.

if you dug around www.cpan.org long enough, you might find stuff.

if you want language comparisons, look for Tom Christiansen's
musing on various other languages.  be careful though - you 
might end up programming python ;)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Wed, 23 Aug 2000 21:03:30 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Perl vs. other scripting languages
Message-Id: <brian-ya02408000R2308002103300001@news.panix.com>

In article <m37l97ir6n.fsf@underlevel.underlevel.net>, Jordan Katz <katz@underlevel.net> posted:

>   1. Scripting: Higher Level Programming for the 21st Century
>      <http://www.scriptics.com/people/john.ousterhout/scripting.html>
> 
>   2. Comparing Python to Other Languages
>      <http://www.python.org/doc/essays/comparisons.html>
> 
> Although the second is Python-centric it contains some useful information.

but you didn't mention the Tcl bias of the first ;)

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Thu, 24 Aug 2000 00:20:29 GMT
From: jblatz2@my-deja.com
Subject: perl/Informix
Message-Id: <8o1pns$t9k$1@nnrp1.deja.com>

We are using perl to insert rows into an Informix table.  We are using:

  Online Dynamic Server ver 7.24
  Perl ver 5.004
  Unix on a Siemens platform

The database is non-logging.

When we run the program it inserts 2408 of 16,683 rows and then hangs.

'onstat -u' looks normal.

There are no messages in the online log or in any system logs
indicating a problem.

The machine that hangs at 2408 rows has 1.5 gig of memory.  When we
run the same program on another machine that has 3 gig of memory it
inserts more rows (about 3000 - it varies) but still ends up hanging.

Any ideas?  We have had very little experience with DBD::Informix and
we're stumped.

I'm wondering if there is some memory related variable that needs to
be changed in a perl module somewhere?

We have read all kinds of manuals and postings but we still can't
figure it out.

Help!!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 23:22:19 GMT
From: testversion1@hotmail.com
Subject: Remote Host Feedback?
Message-Id: <8o1mao$p9e$1@nnrp1.deja.com>

When creating an FTP, how do I get feedback from the remote host? For
example, when loging in on other FTPs, you get messages like:

>>>Welcome to Whereever.com!
>>>Please login

How do I get my FTP to get these responses?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 22:18:18 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: s''' not behaving as expected
Message-Id: <39A44FFC.5BF55335@home.com>

[posted & mailed]

Ren Maddox wrote:
> 
> #!/usr/local/bin/perl -wl
> 
> $_='$foo';
> s'$foo'$bar';
> print;
> 
> Produces as output:
> $foo
> 
> Escaping $foo ( s'\$foo'$bar' ) results in:
> $bar

As expected.  "foo" can't be matched after end-of-line ($).  You must
escape $ for it to mean $ in a regexp.
 
> However, running each of these through -MO=Deparse results in:
> 
> $_ = '$foo';
> s/\$foo/\$bar/;
> print $_;
> 
> - syntax OK
> 
> I assume this is a bug.  Is it a known bug?

This is a bug in B::Deparse.  It is unknown to me but you can always
search http://bugs.perl.org/ before you file your bug report.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 23 Aug 2000 16:06:23 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <39A458EF.6F4840C2@vpservices.com>


how do I find the length of a string?

what operator do I use to match everything between 2 strings, e.g. A ..
B?

how do I make my variables local to a subroutine?

how do I sort a list?

how do I reverse the order of elements in a list?

how do I split a string into parts?

how do I print each element of a hash?

how do I read a binary file from disk?

how do I use a module?


More?

-- 
Jeff


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

Date: Wed, 23 Aug 2000 17:41:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Self-Answering Questions (Was Re: Flipflop matching)
Message-Id: <MPG.140e0f194d43d0b198acd1@nntp.hpl.hp.com>

In article <39A458EF.6F4840C2@vpservices.com> on Wed, 23 Aug 2000 
16:06:23 -0700, Jeff Zucker <jeff@vpservices.com> says...
> 
> how do I find the length of a string?
> 
> what operator do I use to match everything between 2 strings, e.g. A ..
> B?
> 
> how do I make my variables local to a subroutine?

Careful -- that can produce the less-than-best answer!  :-)
 
> how do I sort a list?
> 
> how do I reverse the order of elements in a list?
> 
> how do I split a string into parts?
> 
> how do I print each element of a hash?
> 
> how do I read a binary file from disk?
> 
> how do I use a module?
> 
> More?

Oh, that's much too easy.  But I've got some time to waste.

  How do I accept an incoming socket connection?
  How do I set up an alarm signal?
  How do I bind a network address to a socket?
  How do I identify the caller of a subroutine?
  How do I chop off the last character of a string?
  How do I close a file?
  How do I connect to a remote socket?
  How do I continue executing within a block?
  How do I find out if something is defined?
  How do I delete a hash element?
  How do I get my program to die with an error message?
  How do I dump core?
  How do I access each element of a hash?
  How do I determine if a hash element exists?
  How do I make my program exit?
  How do I declare a format for the write function?
  How do I import names from another module?
  How do I join a list of strings together?
  How do I get a list of the keys of a hash?
  How do I kill a process?
  How do I cause a statement to be the last one executed in a block?
  How do I create a link between two files?
  How do I listen on a socket?
  How do I declare special variables local to a block?
  How do I lock something from another thread?
  How do I log activities from my program?
      (Just checking to see if you were still awake :-)
  How do I map one list to another list?
  How do I force the next iteration of a loop?
  How do I make sure that no part of a module is used?
  How do I open a file?
  How do I pack variables into binary strings?
  How do I declare a pipe between processes?
  How do I pop the last element off the end of an array?
  How do I push an element onto the end of an array?
  How do I recover the prototype of a subroutine?
  How do I redo a block?
  How do I rename a file?
  How do I reset variables?
  How do I return from a subroutine?
  How do I force scalar context?
  How do I select an output filehandle?
  How do I send a message on a socket?
  How do I shift the first element from an array?
  How do I put my program to sleep?
  How do I open a socket?
  How do I get the operating system shell to execute a command?
  How do I tell where a file is positioned?
  How do I tie a variable to a class?
  How do I find out what the current time is?
  How do I find the system and user execution times of my process?
  How do I truncate a file?
  How do I unpack a binary string?
  How do I untie a variable from a class?
  How do I get a list of the values of a hash?
  How do I make my program wait for completion of a child process?
  How do I warn about a possible error?
  How do I write using a format?

More?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 23 Aug 2000 23:21:54 GMT
From: philip.hibbs@tnt.co.uk
Subject: Set @ARGV and ignore STDIN?
Message-Id: <8o1m9v$p99$1@nnrp1.deja.com>

Here's my code:

#!/usr/bin/perl

use Text::Wrap;

# @files = sort {-M $a <=> -M $b} <*.txt>; # sort files by age
# $file = shift @files;                   # get the first (newest)
# undef @files;                          # free up memory
# @ARGV = ($file);                      # set list of files to process
# print @ARGV;

$match = shift;

while (<>) {
    chomp;
    print "\r".$_ if m/[0-9]{4}/i;
    print wrap("\n "," ",$_)."\n" if m/$match/i;
}
__CODE__

It works as is if I supply the file name on the command line, but I want
the four commented-out lines to find the most recent .txt file and
process that instead. It gets the file name into @ARGV, but doesn't
process it, it reads from STDIN instead. Help!

Phil.

PS. Using ActiveState Perl v5.6.0 build 616


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 22:32:19 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: To push or not to push
Message-Id: <8o1jdj$lsd$1@nnrp1.deja.com>

That is the question.

Here is my code, it fills the variables fine, but when I try to test and
see if they are all filled for a particular record iteration, and ready
to push onto my array of records, I can't seem to get the test to
succeed.

sub Parse_LogLines{

foreach $_ (@LogLines){

# Is the current line the header for the record, containing
# date and time information, operator and status?

     if (/^\+>*/) {

#If this is the first line of a record, we'll clear the current record
#placeholder hash

       $Record = {};

#  Snag the timestamp, positions 3-20

       $Record-> {Timestamp} = substr($_, 2, 17);
#      print $Record-> {Timestamp};

#  Split the rest of the first line to get the operator(s)
#  and status


       ($Record-> {Oper}, $Record-> {Status}) = split /Status: /,
substr($_, 22);

# Since the status field is younger than the oldest record we'll process
# we need to deal with it if there isn't one there.

       if (! $Record-> {Status} ) {
           $Record-> {Status} = "None";
           }

# And since we've got some legacy field which is in some records which
# no one uses and no one cares about, kill it if it's there

        if (/Transaction: Phone/){
           $Record-> {Oper} =~ s/Transaction: Phone\s+//;
           }
        chomp $Record-> {Oper};
#        print $Record-> {Oper}, "  ";
#        print $Record-> {Status}, "\n";
        }

#  That takes care of the top line, now we need to get
#  the data in the other fields.  From the format of the
#  data file, we need to get SR, Applid, Ref_Phone, Ref_Party
#  Pegasys/EER Ticket number, and the description of what was done

        elsif (/^\s+Release:*/) {
          $Record-> {SR} = $_;
#          print $Record-> {SR};
          }
          elsif (/^\s+Application:*/) {
             $Record-> {Applid} = $_;
#             print $Record-> {Applid};
             }
             elsif (/^\s+Environment:*/) {
                $Record-> {Environ} = $_;
#                print $Record-> {Environ};
                }
                 elsif (/^\s+Referencing Phone:*/) {
                    $Record-> {Ref_Phone} = $_;
#                    print $Record-> {Ref_Phone};
                    }
                    elsif (/^\s+Referencing Party:*/) {
                       $Record-> {Ref_Party} = $_;
#                       print $Record-> {Ref_Party};
                       }
                       elsif (/^\s+Pegasys\/EER Ticket:*/) {
                          $Record-> {Pegasys_EER} = $_;
#                          print $Record-> {Pegasys_EER};
                       }
                          elsif (/\S/) {
                             $Desc = $_;

                             foreach $_ (@LogLines){
                               last if (/^\s\n/);
                               $Desc .= $_;
                               }
                               $Record-> {Desc} = $Desc;
#                            print $Record-> {Desc};
                             }

if (defined($Record-> {Timestamp}) && defined($Record-> {Status}) &&
defined($Record-> {Applid}) && defined($Record-> {Environ}) &&
defined($Record-> {SR}) && defined($Record-> {Name})
      && defined($Record-> {Pegasys_EER}) && defined($Record-> {Desc})){

  print "foobar";

  push @Recs, $Record;
  }

#print "barfoo";

}

print @Recs;

}

It goes through the loop, that much we can see if we uncomment the print
barfoo line.  It just never tests true.  None of the fields will be
empty once a full record has been read.  They all print when we look at
them individually.  I've tried just if ($Record->{fieldname} &&
$Record-> {fieldname2} &&...)  and I've tried if (exists $Record->
{Fieldname} && exists $Record-> {Fieldname2} ...)

Is there some kind of dereferencing I need here?  And I'm sure there's
an easier way to do the test instead of typing out everything and
"anding" it.  I've been working with the perl debugger, but it's pretty
cryptic so far, I'll keep at it, hopefully I'll grok it soon and not
have such pithy questions.  I'm using the docs on perl.com for the
debugger, any others I should look at?  I don't have the tutorial that I
heard comes with the docs for 5.6, any online mirrors?

Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 23 Aug 2000 23:24:38 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: To push or not to push
Message-Id: <x766ortvbd.fsf@home.sysarch.com>

>>>>> "SM" == Steven Merritt <smerr612@mailandnews.com> writes:

  SM> sub Parse_LogLines{

  SM> foreach $_ (@LogLines){

$_ is the default variable in foreach loop so that is redundant.

  SM> # Is the current line the header for the record, containing
  SM> # date and time information, operator and status?

  SM>      if (/^\+>*/) {

  SM> #If this is the first line of a record, we'll clear the current record
  SM> #placeholder hash

  SM>        $Record = {};


  SM>        if (! $Record-> {Status} ) {
  SM>            $Record-> {Status} = "None";
  SM>            }

		$Record->{Status} ||= "None";

is cleaner. also lose the space after ->. it is ugly.

  SM>        ($Record-> {Oper}, $Record-> {Status}) = split /Status: /,
  SM> substr($_, 22);

  SM>         if (/Transaction: Phone/){
  SM>            $Record-> {Oper} =~ s/Transaction: Phone\s+//;
  SM>            }
  SM>         chomp $Record-> {Oper};

since the oper field comes before the end of the line according to your
split, it can't have a newline so the chomp is useless.

  SM>         }

  SM>         elsif (/^\s+Release:*/) {
  SM>           $Record-> {SR} = $_;
  SM> #          print $Record-> {SR};
  SM>           }
  SM>           elsif (/^\s+Application:*/) {

these elsif's are not nested, so don't indent them progressively which
is misleading. they are really at the same level.

  SM>                        elsif (/^\s+Pegasys\/EER Ticket:*/) {

use alternative delimiters so you don't need to backwhack the /

  SM>                              foreach $_ (@LogLines){

that line is odd. you can't loop over the same set of lines here as you
do in the main loop. you are starting over here and overlapping
with lines you have parsed already.

this style is better done with:

	while( @LogLines ) {

		$line = shift @LogLines ;

then you can slurp in more lines in an inner loop using the same code
and you will always get the next line no matter where you are. or don't
have all the lines read in to the array and use <FILE> to get them.


  SM>                                last if (/^\s\n/);
  SM>                                $Desc .= $_;
  SM>                                }
  SM>                                $Record-> {Desc} = $Desc;
  SM> #                            print $Record-> {Desc};

so here you have a good record according to your comments. you
push it here to keep it and let your main loop allocate a fresh record.

  SM>                              }

at this point i think you are past the main if statement. fixing the
indenting will help a lot.

  SM> if (defined($Record-> {Timestamp}) && defined($Record-> {Status}) &&
  SM> defined($Record-> {Applid}) && defined($Record-> {Environ}) &&
  SM> defined($Record-> {SR}) && defined($Record-> {Name})
  SM>       && defined($Record-> {Pegasys_EER}) && defined($Record-> {Desc})){

are you sure all the fields are defined? why not do some print test here
as well. if you push the record when you detect the end of record above
you will have no problems.


uri


-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4112
**************************************


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