[23115] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5336 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 8 18:05:39 2003

Date: Fri, 8 Aug 2003 15:05:07 -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           Fri, 8 Aug 2003     Volume: 10 Number: 5336

Today's topics:
    Re: Any way to stop a kill? <tzz@lifelogs.com>
        data structure help (slash)
        FTP doesn't add Carriage Return from VMS to NT? (Mike O'Neal)
        Getting PERL to return info from an external 'command' (Ralph)
    Re: Getting PERL to return info from an external 'comma <pete@localho.st>
    Re: Getting PERL to return info from an external 'comma <nobull@mail.com>
    Re: Getting PERL to return info from an external 'comma <noreply@gunnar.cc>
    Re: Getting PERL to return info from an external 'comma <flavell@mail.cern.ch>
    Re: help needed making unicode entities <jidanni@jidanni.org>
    Re: How do I modify version number in XML doc - path to (Sherman Willden)
    Re: nested HTML parsing <tzz@lifelogs.com>
        Newbie: How to parse out a part of a file - in the midd (John Davis)
    Re: Newbie: How to parse out a part of a file - in the  <jkeen@concentric.net>
    Re: Newbie: How to parse out a part of a file - in the  <simon@unisolve.com.au>
    Re: parsing log in multiple passes (disco)
    Re: PATHS Problem <noreply@gunnar.cc>
    Re: undo the (?i) <krahnj@acm.org>
    Re: Useless use of private variable in void context ... <nobull@mail.com>
    Re: Useless use of private variable in void context ... <grg@umn.edu>
    Re: Useless use of private variable in void context ... (Tad McClellan)
    Re: Win32-OLE excel cell reference. <mikeflan@earthlink.net>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 08 Aug 2003 14:54:09 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Any way to stop a kill?
Message-Id: <4nn0ekyo8e.fsf@lockgroove.bwh.harvard.edu>

On Thu, 07 Aug 2003, mdudley@execonn.com wrote:

> After a customer orders something, emails get sent to me and the
> customer by a perl script.  Lately the server has been loaded more
> heavily than normal, and the sendmail is taking a while to complete
> and for control to return back to perl.  Unfortunatly some customers
> are either browsing elsewhere, or hitting stop while the sendmail is
> sending the email, and a kill is generated which kills the emails to
> me and the customer.
> 
> Is there any way to keep the process from being killed before the
> emails are sent out?  This is a rather serious problem for me right
> now.

Have you tried moving your mail server to another machine, and using
SMTP to relay through it?  You can also try an alternate MTA such as
qmail.

You can fork() and disassociate yourself from the parent process and
parent group, but then the web server won't catch your hung processes.
That's the reason for this reaping anyhow, and IMO is a good thing
generally...  You may want to keep that extra layer of protection.

Ted


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

Date: 8 Aug 2003 11:32:41 -0700
From: satishi@gwu.edu (slash)
Subject: data structure help
Message-Id: <30fe9f1e.0308081032.a1b045f@posting.google.com>

Hi,
I have been struggling with this for a while and could certainly use
some help.
I am using the Text::Table module for performing ngrams and trying to
add the corresponding filename information to whatever file that's
being processed. In other words, given a file.txt, i do my ngrams and
select to output specific columns. At the end of each line, I want to
add the text file name. Can someone please help me with how I should
go about this.
I have tried $tb->add($ARGV) inside the foreach loop but that simply
adds a new line at the end of each iteration. Something like this:

quick    brown   fox
brown    quick   .
                 fox.txt
brown    fox     jumped
fox      brown   quick
                 fox.txt

I don't want that. What I am trying to get so desperately is
precicesly this:

quick    brown   fox    fox.txt
brown    quick   .      fox.txt
brown    fox     jumped fox.txt
fox      brown   quick  fox.txt

My code is as follows:

use Text::Table;
undef $/;
        my @words = split /\W+/, <> ;
        my $line_number = 2; my $n;
        my $line_num = 2; my $n_cols = 5;
        my $col = { align => 'left'}; 
        my $tb = Text::Table->new( ( $col) x $n_cols);
        my @stack = ( '-1' ) x $n_cols;
        foreach $word ( @words ) {
            shift @stack;
            push @stack, $word;  
            $tb->add(@stack);          
    }
        my @lines = $tb->add("$stack[-4]", "$stack[-3]", "$stack[-2]",
"$stack[-1]", "*");
        my @lines = $tb->add("$stack[-3]", "$stack[-2]", "$stack[-1]",
"-1", "-1");
        my @lines = $tb->table($line_number, $n);

#select columns
     	 my $t1 = $tb->select(0,1, {is_sep => 2, body => "  "}, 2, 
	                           {is_sep => 2, body   => "\n"}, 
	                      3,4, {is_sep => 2, body => "  "}, 2);
         my $input = $t1->table($line_num, $n);
         print $input;

This generates the following output for file.txt (quick brown fox
jumped)

 .       .      quick   brown  fox
 .       quick  brown   fox    jumped
quick   brown  fox     jumped .
brown   fox    jumped  .

but I select the following columns for output:
quick    brown   fox
brown    quick   .
brown    fox     jumped
fox      brown   quick
fox      jumped  .
jumped   fox     brown
jumped   .

Can someone please look through my code to suggest any improvements or
ways of doing what I am trying to get. I could really use some help.

Thanks,
Slash


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

Date: 8 Aug 2003 13:56:03 -0700
From: mjoneal@bpa.gov (Mike O'Neal)
Subject: FTP doesn't add Carriage Return from VMS to NT?
Message-Id: <594ddf47.0308081256.5a76906@posting.google.com>

When I try to use NET::FTP to transfer text files from VMS to NT (GET
command using ASCII mode,) FTP will add the Linefeed, but not the
required carriage return.  As is clearly stated all over the
newsgroup, NT/2000 requires the CR/LF at the end of each line.  VMS
uses neither.  Side-note, when I transfer the files in binary, NO line
terminations are added, as expected.  I'm using Windows 2000 with the
ActiveState Perl vers 5.8.  I've reloaded the W2k system and Perl with
the same results.

I've located what appears to be the module that performs the transfer
at perl\lib\net\ftp\A.pm but it seems to substitute \n with 015 and
012.  I would have expected 013 and 010 (decimal for CR/LF) so now I'm
really confused.  Changing them makes no difference, so I guess I'm
way off base.

Anyone have suggestions why I'm not getting my CR/LF as expected?


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

Date: 8 Aug 2003 11:51:35 -0700
From: ralphlos@hotmail.com (Ralph)
Subject: Getting PERL to return info from an external 'command'
Message-Id: <6ed45fb2.0308081051.31bce2a1@posting.google.com>

Hi, I have a particular task I need perl to accomplish, but I'm not
sure how to do it, or what the code involved would be...

Given a list (end-of-line separated) of server names (NetBIOS), I need
PERL to run through the file, and do an NSLOOKUP $_ on the server
name.  The return looks like this:

Server:  blah.blah.blah.com
Address:  1.2.3.4

Name:    ServerIWant.company.com
Address:  4.3.2.1

I want to be able to extract the ServerIWant.company.com from the
output of the DOS command, and stick it into a variable which I can
then write to a text file, essentially replacing the NetBIOS names
with DNS names...to make it simple.

Can anyone give me a quick example, or help throw some code together?

 ./Ralph


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

Date: Fri, 08 Aug 2003 20:06:53 +0000
From: pete <pete@localho.st>
Subject: Re: Getting PERL to return info from an external 'command'
Message-Id: <UvSYa.1155$rQ.374891@newsfep1-win.server.ntli.net>

Ralph wrote:

> Hi, I have a particular task I need perl to accomplish, but I'm not
> sure how to do it, or what the code involved would be...
> 
> Given a list (end-of-line separated) of server names (NetBIOS), I need
> PERL to run through the file, and do an NSLOOKUP $_ on the server
> name.  The return looks like this:
> 
> Server:  blah.blah.blah.com
> Address:  1.2.3.4
> 
> Name:    ServerIWant.company.com
> Address:  4.3.2.1
> 
> I want to be able to extract the ServerIWant.company.com from the
> output of the DOS command, and stick it into a variable which I can
> then write to a text file, essentially replacing the NetBIOS names
> with DNS names...to make it simple.
> 
> Can anyone give me a quick example, or help throw some code together?
> 
> ./Ralph

There maybe be a cpan module for doing lookups. One way would be something
along the lines of ...

        open (IN, "< filename");
        while (<IN>) {
                chomp;
                @result = `nslookup $_`;

                foreach (@result) {
                        if (/Address:(.*?)/) {
                                print "Address is : $1\n";
                        }
                }
        }
        close IN;


(AOL Keyword: "backtick operator")

Cheers,

pete


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

Date: 08 Aug 2003 20:02:45 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Getting PERL to return info from an external 'command'
Message-Id: <u9oez0q8fe.fsf@wcl-l.bham.ac.uk>

ralphlos@hotmail.com (Ralph) writes:

> Hi, I have a particular task I need perl to accomplish, but I'm not
> sure how to do it, or what the code involved would be...
> 
> Given a list (end-of-line separated) of server names (NetBIOS), I need
> PERL to run through the file, and do an NSLOOKUP $_ on the server
> name.

No problem just do it.

But... does NSLOOKUP, even on Win32, look up netbios names?  I thought
it only looked up DNS names anyhow.

If you want to look up DNS names you could just use gethostbyname().

> The return looks like this:
> 
> Server:  blah.blah.blah.com
> Address:  1.2.3.4
> 
> Name:    ServerIWant.company.com
> Address:  4.3.2.1
> 
> I want to be able to extract the ServerIWant.company.com from the
> output of the DOS command, and stick it into a variable which I can
> then write to a text file, essentially replacing the NetBIOS names
> with DNS names...to make it simple.

my ($server) = `nslookup $_` =~ /^Name:\s+(.*)/m;

Of course I'm asuming here you are happy to ignore all errors and just
get $server=undef is anything goes wrong.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 08 Aug 2003 21:16:54 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting PERL to return info from an external 'command'
Message-Id: <bh0t29$thcg9$1@ID-184292.news.uni-berlin.de>

Ralph wrote:
> Hi, I have a particular task I need perl to accomplish, but I'm not
> sure how to do it, or what the code involved would be...
> 
> Given a list (end-of-line separated) of server names (NetBIOS), I
> need PERL to run through the file, and do an NSLOOKUP $_ on the
> server name.  The return looks like this:
> 
> Server:  blah.blah.blah.com
> Address:  1.2.3.4
> 
> Name:    ServerIWant.company.com
> Address:  4.3.2.1
> 
> I want to be able to extract the ServerIWant.company.com from the 
> output of the DOS command, and stick it into a variable which I can
> then write to a text file, essentially replacing the NetBIOS names
> with DNS names...to make it simple.

Do you really need help with _all_ the steps involved? In that case,
you'd better start by learning some basic Perl coding:

     http://learn.perl.org/

Then you should at least do _something_ by yourself, and come back
here only after that, provided that you get stuck with a particular
detail.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 8 Aug 2003 22:04:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Getting PERL to return info from an external 'command'
Message-Id: <Pine.LNX.4.53.0308082150580.14573@lxplus090.cern.ch>

On Fri, Aug 8, pete inscribed on the eternal scroll:

> > I want to be able to extract the ServerIWant.company.com from the
> > output of the DOS command, and stick it into a variable which I can
> > then write to a text file, essentially replacing the NetBIOS names
> > with DNS names...to make it simple.

> There maybe be a cpan module for doing lookups.

I use Net::DNS for the DNS part of the question, but I haven't
a clue (and don't really want one) about the NetBIOS names.

>         open (IN, "< filename");
>         while (<IN>) {
>                 chomp;
>                 @result = `nslookup $_`;

The overhead on that it going to be quite something, I suspect.

Keep in mind that DNS lookups actually need some real network
activity, and some of them might take a while.  And that's on top of
your spawning a new process every time.  And, by the way, you have the
capacity for feeding tainted data to your backticked command - I
really couldn't recommend that for robust programming style.

If time doesn't matter, then you can query each one sequentially, but
I'd still want to avoid the overhead of spawning a fresh command for
every lookup.

But if time is of the essence, Net::DNS has the ability to issue
several queries in parallel, and you can either process them in the
order in which the queries are satisfied, or at least by the time
you've waited for the first you issued, there's a chance that others
have also arrived.

Its documentation has plenty of examples.   See
http://www.net-dns.org/docs/Net/DNS.html or CPAN.


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

Date: Fri, 08 Aug 2003 16:38:23 +0800
From: Dan Jacobson <jidanni@jidanni.org>
Subject: Re: help needed making unicode entities
Message-Id: <87u18sv91c.fsf@jidanni.org>

Alan> (with :utf8 in effect, of course);  and then use ord()

Ah,
$ echo [my name in big5 chinese]|
iconv -f big5 -t utf8|PERLIO=:utf8 perl -wple 's/./"&#".ord($&).";"/eg'
&#31309;&#20025;&#23612;
Works! That was pleasant.
Never did figure out how to move the :utf8 inside the program whilst
maintaining the -ple. perldoc -f open doesn't enlighten.
P.S. what is the pro way to do this, not disturbing ascii, and still
as a batch job (no mozilla)?  Certainly there is a ready made solution?
Yes, I can move iconv inside the program, later.


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

Date: 8 Aug 2003 13:43:57 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: Re: How do I modify version number in XML doc - path to pass to Twig?
Message-Id: <3a80d8d6.0308081243.1405fcfc@posting.google.com>

I have it now and my apologies to Michel Rodriguez if I gave any
indication that it didn't work.

I was comparing the look and file size of the output file which were
different from the original file since I was using record_c. After
posting this I ran a parser and the file was xml compliant. After I
used indented_c the file size and appearance was the same as the
original file.

Sherman


sherman.willden@hp.com (Sherman Willden) wrote in message news:<3a80d8d6.0308080754.ddebbb6@posting.google.com>...
> Thanks, Michael, for your response earlier and the code works, the
> values are modified, and the text stream is output to the screen.
> 
> My question is how do I get a well-formed XML document from the
> results? I tried printing to a file handle ( C:\temp\twig_tmp.xml )
> but that didn't work. Below is the code that outputs the results to
> the screen.
> 
> To further explain, I have file xyz.xml. I want to modify one value in
> the xyz.xml file and have a working xyz.xml file after the
> modification.
> 
> I am sure that I missed the answer when reading Michael's site, Perl
> and XML, and the twig documentation. Can someone provide a reference
> to the paragraph(s) that explains what I missed?
> 
> Thanks;
> 
> Sherman
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use XML::XPath;
> use XML::XPath::XMLParser;
> use XML::Twig;
> 
> my $field= 'string';
> my $old_value = '2.20.0.0';
> my $new_value = '2.20.0.12';
> 
> if ( -f "C:/temp/twig_tmp.xml" ) {
>     chmod(0777, "C:/temp/twig_tmp.xml");
>     unlink("C:/temp/twig_tmp.xml");
> }
> 
> #open(TMPFLE, ">>c:/temp/twig_tmp.xml");
> 
> my $t = new XML::Twig( twig_handlers =>
>     { qq{$field\[string() = "$old_value"] } => \&update, # process 
>     __default__ => sub { $_[0]->flush; },             # flush anything
> else
>                     },
>     pretty_print => 'record_c',);
> $t->parsefile( 'BC_HA.iap_xml' );
> #$t->print( \*TMPFLE );
> $t->flush;
> 
> #close(TMPFLE);
> 
> sub update
> {
>     my( $t, $field_elt)= @_;
>     # if you want the version number to be in a CDATA section
>     # then set_content is not enough
>     if( my $cdata= $field_elt->first_child_is( '#CDATA'))
>       { $cdata->set_cdata( $new_value); }
>     else 
>       { $field_elt->set_text( $new_value); }
> }


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

Date: Fri, 08 Aug 2003 14:41:57 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: nested HTML parsing
Message-Id: <4nr83wyosq.fsf@lockgroove.bwh.harvard.edu>

On Thu, 7 Aug 2003, tadmc@augustmail.com wrote:

Ted Zlatanov <tzz@lifelogs.com> wrote:
> 
>> invalid HTML.
> 
> 
> There really is no such thing.
> 
> If it is invalid, then it is not HTML at all, just some
> angle-brackety text.

Please don't be pedantic.  The original text is also invalid Lisp and
invalid Bulgarian.

Thanks
Ted


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

Date: 8 Aug 2003 14:10:32 -0700
From: tudmuf2b@onebox.com (John Davis)
Subject: Newbie: How to parse out a part of a file - in the middle?
Message-Id: <7167a8d.0308081310.769a0751@posting.google.com>

So far I have a short script as follows:

#!/usr/bin/perl -w

open (LYNX, "lynx -dump http://mlp02:7580/service_detail?8200 |" ) ||
die "ca
nnot find command: $!";

while (<LYNX>) {
  next if (! /Inbound Rates/ );
  print;
}

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

The script opens up and dumps a lynx session for output from a web
server. I want to cycle thru that output and process the data -
probably using split to get the fields I need.

Where I'm stuck is...

What I want to do is to skip everything from the output BEFORE Inbound
Rates and BEFORE the line that starts with REFERENCES and go from
there. Is the a way in Perl to do this easily? Thanks! :)

   .....

   Inbound Rates (per second)    Outbound Rates (per second)
   msgs  bytes        pkts       msgs bytes        pkts
   83.6 14296.3       34.1       8.7  1187.7        8.7
                   Inbound Totals
    msgs    bytes    pkts  missed lost MC lost PTP
   930893 159428443 378502   25      0       0
                 Outbound Totals
   msgs   bytes   pkts  retrans lost MC lost PTP
   98288 13607181 98273   24       0       0
              Information Alerts
   15:58:50 : Outbound retransmission sent.
   15:58:40 : Inbound data packets missed.
   15:58:30 : Outbound retransmission sent.

 
   REFERENCES

    ....


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

Date: 08 Aug 2003 21:50:46 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Newbie: How to parse out a part of a file - in the middle?
Message-Id: <bh15vm$an1@dispatch.concentric.net>


"John Davis" <tudmuf2b@onebox.com> wrote in message
news:7167a8d.0308081310.769a0751@posting.google.com...
> So far I have a short script as follows:
>
> #!/usr/bin/perl -w
>
> open (LYNX, "lynx -dump http://mlp02:7580/service_detail?8200 |" ) ||
> die "ca
> nnot find command: $!";
>
> while (<LYNX>) {
>   next if (! /Inbound Rates/ );
>   print;
> }
>
> --------------
>
> The script opens up and dumps a lynx session for output from a web
> server. I want to cycle thru that output and process the data -
> probably using split to get the fields I need.
>
> Where I'm stuck is...
>
> What I want to do is to skip everything from the output BEFORE Inbound
> Rates and BEFORE the line that starts with REFERENCES and go from
> there. Is the a way in Perl to do this easily? Thanks! :)
>
>    .....
>
>    Inbound Rates (per second)    Outbound Rates (per second)
>    msgs  bytes        pkts       msgs bytes        pkts
>    83.6 14296.3       34.1       8.7  1187.7        8.7
>                    Inbound Totals
>     msgs    bytes    pkts  missed lost MC lost PTP
>    930893 159428443 378502   25      0       0
>                  Outbound Totals
>    msgs   bytes   pkts  retrans lost MC lost PTP
>    98288 13607181 98273   24       0       0
>               Information Alerts
>    15:58:50 : Outbound retransmission sent.
>    15:58:40 : Inbound data packets missed.
>    15:58:30 : Outbound retransmission sent.
>
>
>    REFERENCES
>
>     ....

Crude, but it will get you started:

    my (@lines);
    while (<DATA>) {
        chomp;
        push(@lines, $_) if (/^Inbound Rates/ .. /REFERENCES/);
    }

You can get rid of the line containing REFERENCES yourself and proceed from
there.  Cf. 'perldoc perlop' section on range operator in scalar context.
HTH

Jim Keenan




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

Date: Sat, 09 Aug 2003 07:57:53 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: Newbie: How to parse out a part of a file - in the middle?
Message-Id: <bh16fn$1rpm$1@otis.netspace.net.au>

John Davis wrote:

> So far I have a short script as follows:
> 
> #!/usr/bin/perl -w
> 
> open (LYNX, "lynx -dump http://mlp02:7580/service_detail?8200 |" ) ||
> die "ca
> nnot find command: $!";
> 
> while (<LYNX>) {
>   next if (! /Inbound Rates/ );
>   print;
> }
> 
> --------------
> 
> The script opens up and dumps a lynx session for output from a web
> server. I want to cycle thru that output and process the data -
> probably using split to get the fields I need.
> 
> Where I'm stuck is...
> 
> What I want to do is to skip everything from the output BEFORE Inbound
> Rates and BEFORE the line that starts with REFERENCES and go from
> there. Is the a way in Perl to do this easily? Thanks! :)

[snip]

Depending on your needs, you *could* do something like this:

#!/usr/bin/perl -w

use strict;
undef $/;               # Enable 'slurp' mode
open (LYNX, "lynx -dump http://mlp02:7580/service_detail?8200 |" ) ||
     die "cannot find command: $!";

my $file = <LYNX>;          # Whole file here now...
my ($stuff_that_interests_me) =
     ($file =~ m/.*?Inbound Rates.*?REFERENCES(.*)/s;
print "$stuff_that_interests_me\n";

But have you considered using the HTML::Parser module to examine the 
html from your web server, rather than the formatted output from lynx?

Again, depending on your needs, it may be more appropriate. TMTOWTDI ;-)

Hope this helps,

Simon Taylor





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

Date: 8 Aug 2003 13:13:20 -0700
From: jpdiscover@hotmail.com (disco)
Subject: Re: parsing log in multiple passes
Message-Id: <9b579c86.0308081213.c7e3ecb@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message > 
> If you need the data in a hash this will do it.
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> use Data::Dumper;
> 
> my $file = 'cli.log';
> open my $fh, '<', $file or die "Cannot open $file: $!";
> 
> local $/ = '';   # paragraph mode
> my %data;
> while ( <$fh> ) {
>     my %temp = grep [ s/^\s+//, s/\s+$// ], split /:|\n/;
> 
>     my ( @keys, @ports );
>     for my $port ( 1 .. $temp{ 'Number of Ports' } ) {
>         push @ports, { grep [ s/^\s+//, s/\s+$// ], split /:|\n/, <$fh> };
>         push @keys, $ports[ -1 ]{ 'Port Id' };
>         }
>     @keys = sort @keys;
> 
>     if ( $temp{ 'Node Id' } == 0 ) {
>         $data{ $keys[ 0 ] } = { %temp, map { $_, $ports[ $_ ] } 0 .. $#ports };
>         }
>     else {
>         $data{ $temp{ 'Node Id' } } = { %temp, map { $_, $ports[ $_ ] } 0 .. $#ports };
>         }
>     }
> 
> print Dumper( \%data );
> 
> __END__
> 
> 
> 
> John

Hi John,

Thanks for your ideas and feedback.  I have gotten some good ideas and
learned some new concepts already.

I cannot run either of your examples with warnings turned on and the
results are not correct. I cut and pasted your code onto my
workstation. Is this the correct version of your code?

I would like to get the second example working.  This is what I get:

Use of uninitialized value in sort at c:\temp\example2.pl line 19,
 <$fh> chunk 1.
Use of uninitialized value in sort at c:\temp\example2.pl line 19,
 <$fh> chunk 1.
Use of uninitialized value in sort at c:\temp\example2.pl line 19,
 <$fh> chunk 1.
Use of uninitialized value in sort at c:\temp\example2.pl line 19,
 <$fh> chunk 1.
Use of uninitialized value in hash element at c:\temp\example2.pl
line 21, <$fh> chunk 1.
Use of uninitialized value in hash element at c:\temp\example2.pl
line 21, <$fh> chunk 1.
$VAR1 = {
          '' => {
                  '' => 'Card name',
                  'Firmware Version' => '4.234',
                  'BitBlaster' => 'Firmware Version',
                  'Driver Version' => '7.2345',
                  'Alpha' => 'Port type',
                  'Ethernet' => 'Port speed',
                  '5.000' => 'Driver Version',
                  '24550' => 'Number of Ports',
                  'Card name' => 'SuperWombat',
                  'Node Id' => '00000',
                  'Number of Ports' => 2,
                  '0' => {},
                  '1' => {},
                  'Port name' => 'GigE1',
                  '10' => '',
                  '8.000 rel 5.02' => 'Node Id',
                  'Port type' => 'Ethernet',
                  'Port speed' => '1000',
                  'Port Id' => '10200',
                  '1a3c5f' => 'Port name'
                }
        };
Press any key to continue . . .

I was hoping for:

1a3c5f -> Card name -> SuperWombat
1a3c5f -> Firmware Version -> 4.234
1a3c5f -> Driver Version -> 7.2345
1a3c5f -> Node Id -> 00000
1a3c5f -> Number of Ports -> 2
1a3c5f -> 0 -> Port Id -> 1a3c5f
1a3c5f -> 0 -> Port name -> Alpha
1a3c5f -> 0 -> Port type -> Ethernet
1a3c5f -> 0 -> Port speed -> 10
1a3c5f -> 1 -> Port Id -> af2c2d2
1a3c5f -> 1 -> Port name -> Alpha2
1a3c5f -> 1 -> Port type -> Scsi
1a3c5f -> 1 -> Port speed -> 1gig
24550 -> Card name -> BitBlaster
24550 -> Firmware Version -> 5.000
24550 -> Driver Version -> 8.000 rel 5.02
24550 -> Node Id -> 24550
24550 -> Number of Ports -> 1
24550 -> 0 -> Port Id -> 10200
24550 -> 0 -> Port name -> GigE1
24550 -> 0 -> Port type -> Ethernet
24550 -> 0 -> Port speed -> 1000

Note there are 2 separate cards and the special routine I can't figure
out is for the card named "Super Wombat".

Would there be any disadvatage to making "data" an anonymous hash? I
like to use anonymous hashes because they are easy to add onto later.

Thanks for your help,
Disco


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

Date: 8 Aug 2003 20:10:04 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: PATHS Problem
Message-Id: <bh1021$sp61g$1@ID-184292.news.uni-berlin.de>

Jim Rendant wrote:
> I have created a perl script that lives in the cgi-bin directory.
> It builds web pages on the fly but it doesn't find the CSS style
> sheet located in the .../html/ directory.

"It doesn't find?" Is that another way to say that you didn't state
the correct URL to the style sheet?

> I have used the http://ipaddress/html/ path name

Something starting with 'http://' is not a "path name" - it's a URL.

> and it works.

Does it work? So, what's the problem?

> When I transfer this to another server I will have to reconfigure all
> the absolute path names for that server.

Please forget about "path names". Style sheets are accessed via URLs!

Using _relative_ or _absolute_ URLs (not paths) may work without a
need to modify the script. Something like:

<link rel="StyleSheet" href="/yourstylesheet.css" type="text/css" />

> I AM SURE I AM MISSING SOMETHING HERE!

You seem to be mixing up paths and URLs. Use Google or something to
learn about the difference. ;-)

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


-- 
PLEASE NOTE: comp.infosystems.www.authoring.cgi is a
SELF-MODERATED newsgroup. aa.net and boutell.com are
NOT the originators of the articles and are NOT responsible
for their content.

HOW TO POST to comp.infosystems.www.authoring.cgi:
http://www.thinkspot.net/ciwac/howtopost.html



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

Date: Fri, 08 Aug 2003 18:36:05 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: undo the (?i)
Message-Id: <3F33ED94.B049E8E@acm.org>

joeri wrote:
> 
> I have an RE where I use the (?i) somewhere, but I want to undo that effect
> further on in the RE.
> Here's an example:
> 
> $var="(?i)(forty|fifty)";

Change that to:

$var = '(?i:forty|fifty)';

Which will limit the effects of case insensitivity to the enclosing
parenthesis.


> $input = "Forty-ninth ST";
> if ($input =~ /$var(\-ninth)\s[S|s]t/) {
                                ^^^^^
Your character class is trying to match a 'S' or a '|' or a 's'.  Do you
really want to match a vertical bar here?  The hyphen is not special in
regular expressions, there is no need to backslash it.


>     print "$&\n";
> }


John
-- 
use Perl;
program
fulfillment


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

Date: 08 Aug 2003 19:47:37 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Useless use of private variable in void context ... ?
Message-Id: <u9smocq94m.fsf@wcl-l.bham.ac.uk>

"George R. Gonzalez" <grg@umn.edu> writes:

> Useless use of private variable in void context at b.pl line 588,
> which is the last line of this sub, '$A", the returned value.

No it isn't.  Look again at your code again.  The {...} in the
fragment you post are mismatched.  But, assuming your whole program
compiles at all, there is a complementary mismatch further on.

We say in the posting guidelines:

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

We were not kidding.  We really mean this.  It really works.

What I did to find your mistake is _exactly_ what the guidelines above
told you to do before you posted (I didn't count the {...} by hand).

Had you followed the guidelines you would, indeed, have found the
solution for yourself.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 8 Aug 2003 14:06:34 -0500
From: "George R. Gonzalez" <grg@umn.edu>
Subject: Re: Useless use of private variable in void context ... ?
Message-Id: <bh0sbo$ns1$1@lenny.tc.umn.edu>


"Brian McCauley" <nobull@mail.com> wrote in message
news:u9smocq94m.fsf@wcl-l.bham.ac.uk...

> What I did to find your mistake is _exactly_ what the guidelines above
> told you to do before you posted (I didn't count the {...} by hand).
>
> Had you followed the guidelines you would, indeed, have found the
> solution for yourself.

As my DC cabriver said, You're Right!  You're Right!

I did try inserting an extra "}" after the sub, and it complained about the
extra right "}".  But I DIDNT notice it was complaining about the extra
right "}" that was much further on in the code.   That's why I was stumped,
the sub seemed to be ended properly.   Anythor reminder to indent one's code
properly.

Regards,

George







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

Date: Fri, 8 Aug 2003 14:44:06 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Useless use of private variable in void context ... ?
Message-Id: <slrnbj7vc6.3om.tadmc@magna.augustmail.com>

George R. Gonzalez <grg@umn.edu> wrote:

> Useless use of private variable in void context at b.pl line 588,
> which is the last line of this sub, '$A", the returned value.
> 
> The weird thing is this has been working fine for weeks,
> now it starts to complain!
> 
> Any ideas?


If you truly have not changed anything then we have entered 
the Twilight Zone.

I'm guessing that _something_ got changed.


> sub LookForDirLo{ my( $pat, $Base ) = @_;  my( @D, $f, $fn, $A );
>  $A = '';
>     ##print "lookfordirlo of '$Base'\n";
>  if( $Base =~ /$pat/i ) { $A = $Base;  print "Setting A to '$A'" }
>  else {
>  if( -d $Base ) {
>   if( -r $Base ) {
>    if( opendir( DIR, $Base ) ) {
>     @D = readdir( DIR ); closedir( DIR );
>     if( scalar @D == 0  ) { Warn "Empty directory info returned for
> '$Base'" }
> 
>     foreach $f ( @D ) {
>       if( $A eq '' ) {
>      if( $f eq '.' or $f eq '..' ) { }
>      else {
>       $fn = "$Base\\$f";
>       if( -d $fn ) { $A = LookForDirLo( $pat, $fn ) }
>      }
>       }
>     }
> 
>    }
>    else { Warn "opendir failed: Cant grovel in folder '$Base', System said:
> '$!'" }
>   } else { Warn "LookForDirLo found that '$Base' is not readable!" }
>  } else { Warn "LookForDirLo found that '$Base' is not a directory!" }
> $A;
> }


Your code it too horribly formatted to be given serious review.

Indent blocks and line up the curlies properly, and you will see
that the final "}" that you show above is NOT the one that closes
the subroutine block. 

It closes one of the else blocks (which else block it is will
become obvious once you indent properly).

Your lack of discipline in formatting your code, has cost you
much more time than what would have been required to line things 
up in the first place.

The cause of your program would be obvious if you'd write your 
code well.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 08 Aug 2003 20:23:19 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: Win32-OLE excel cell reference.
Message-Id: <3F340747.401851FA@earthlink.net>


Richard S Beckett wrote:

> Guys,
>
> I'm struggling with the syntax to point to the cells that I want to use in
> Excel.
>
> It seems that the Range command likes data like (A14), or (A14:B26), and I
> am happy with this.
>
> My problem occurrs when I only have numeric data to work with, because of
> incremented counters, or Count commands.
>
> I have had success with Cells(1,14), but I cannot for the life of me work
> out how to reference an area of cells like this...
>
> Cells(1,14:5,28)
>
> Can anyone help me with the correct syntax, please?

I can't answer your question directly, but it seems like it
would be an easy thing to change the numeric column data
to alpha.  e.g. 1>A, 2>B, 3>C, etc.


Mike




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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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