[22637] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4858 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 17 14:06:47 2003

Date: Thu, 17 Apr 2003 11:05:08 -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           Thu, 17 Apr 2003     Volume: 10 Number: 4858

Today's topics:
    Re: Accesing machines of a network (Bryan Castillo)
    Re: Can I die and also write to a log file? (Sherman Willden)
    Re: conditional 'use' <mark.seger@hp.com>
    Re: conditional 'use' (Lawrence Tierney)
    Re: foreach how do I get out of the loop? sthg like "br (Tad McClellan)
        GD::Graph axis font size (Valerie VANLERBERGHE)
    Re: How to read one line from a text file <noreply@gunnar.cc>
    Re: How to read one line from a text file <tzz@lifelogs.com>
    Re: How to read one line from a text file <john-s@moving-picture.com>
    Re: How to read one line from a text file <john-s@moving-picture.com>
    Re: How to read one line from a text file (Tad McClellan)
    Re: How to read one line from a text file <nobody@dev.null>
        Interpolation problem with DB execute object (Liberty Belle)
    Re: Interpolation problem with DB execute object <mbudash@sonic.net>
    Re: killing unix processes by name ... <tzz@lifelogs.com>
    Re: My 1st japh!! ctcgag@hotmail.com
        Need help with NDBM_File! <caotran@sbcglobal.net>
    Re: Need help with NDBM_File! <noreply@gunnar.cc>
    Re: Nesting tables with perl CGI <rbinn@shaw.ca>
    Re: slow/inefficient script: seeking help with multimat (Adam)
    Re: Stumped! (Sara)
        Using a pre-processor to generate POD <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: Using a pre-processor to generate POD <ubl@schaffhausen.de>
    Re: Using a pre-processor to generate POD <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Apr 2003 09:57:45 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: Accesing machines of a network
Message-Id: <1bff1830.0304170857.7130e10c@posting.google.com>

"Kasp" <kasp@epatra.com> wrote in message news:<b7jhe7$mli$1@newsreader.mailgate.org>...
> > # The function you should be interested in is
> > GetSharedResources(\@Resources,dwType,\%NetResource = NULL)
> 
> I am having some trouble with this one Bryan.
> 
> Documentation says: "The \%NetResource argument is optional. If it is not
> supplied, the root (that is, the topmost container) of the network is
> assumed, and all network resources available from the toplevel container
> will be enumerated."
> 
> Now I don't want to search from the top-level container. In my "Microsoft
> Windows Network", amongst many other domains I have a domain called
> "myDomain". And I want to search only this domain.
> 
> How can I search all the machines on a specific domain?

I couldn't figure out how search on a specific domain with
GetSharedResource,
however I tried what someone else (brian m) suggested; parsing net
view.

Here is a script I wrote to see what shares were out there on a
specific domain.

One you get the shares you should be able to use other directory
operations,
opendir, File::Find, etc...

[off-topic section]
(I ran this and couldn't believe how many people had C drives shared
out, checking later I found out many had them set to writable for
everyone :(
Is it considered hacking if people leave their systems wide-open?)
[end off-topic section]


use strict;
use warnings;
use Win32::NetResource qw{:DEFAULT GetSharedResources GetError};

sub die_win32 {
  my $win_err;
  GetError($win_err);
  die Win32::FormatMessage($win_err);
}

sub get_winhosts {
  my $domain = shift;
  local(*PIPE);
  open(PIPE, "net view /DOMAIN:$domain |") || 
      die "can't open pipe - $!\n";
  my @hosts;
  while (my $line = <PIPE>) {
    if ($line =~ /^\\\\(\S+)/) {
      push(@hosts, $1);
    }
  }
  close(PIPE);
  return @hosts;
}

sub get_shares {
  my $host = shift;
  my @resources;
  GetSharedResources(\@resources, RESOURCETYPE_DISK,{
    RemoteName => '\\\\' . $host
  }) || die_win32;
  my @shares;
  foreach my $res (@resources) {
    push(@shares, $res->{RemoteName});
  }
  return @shares;
}

# I don't why but I have to do this with Perl 5.8 on windows now
# to exit on Control-C
$SIG{INT} = sub { exit(1); };

$|=1; # auto-flush

foreach my $host (sort(get_winhosts("dds"))) {
  eval {
    print $host, "\n";
    foreach my $share (sort(get_shares($host))) {
      print "  $share\n";
    }
  };
  #print "Error: getting info for $host - $@\n" if ($@);
}



> Thanks.


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

Date: 17 Apr 2003 06:07:19 -0700
From: sherman.willden@hp.com (Sherman Willden)
Subject: Re: Can I die and also write to a log file?
Message-Id: <3a80d8d6.0304170507.5568b73b@posting.google.com>

Thanks for your replies. You helped me get something that works.

Sherman


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

Date: Thu, 17 Apr 2003 10:34:05 -0400
From: Mark Seger <mark.seger@hp.com>
Subject: Re: conditional 'use'
Message-Id: <3E9EBB5D.9446AA88@hp.com>

thanks for the help.  this technique works great.  what I decided to do is the
following

$flag=eval {include "foo" or die; } ? 1 : 0;

and then I can use the flag elsewhere to make any conditional decisions.

-mark




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

Date: 17 Apr 2003 08:58:45 -0700
From: lawrence.tierney@bipcontracts.com (Lawrence Tierney)
Subject: Re: conditional 'use'
Message-Id: <17e88dbe.0304170758.2f57f7dd@posting.google.com>

> > Basically I have a script that uses 'Compress::Zlib' when it's there but
> > I don't want to use it when it's not.  Since you can't conditionalize a
> > "use", I assume you use a "require" instead.
> > 

You may want to have a look at
http://www.perl.com/pub/a/2003/03/18/only.html then again maybe
not.......


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

Date: Thu, 17 Apr 2003 09:16:23 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: foreach how do I get out of the loop? sthg like "break;" exists?
Message-Id: <slrnb9tdpn.6cp.tadmc@magna.augustmail.com>

milka <milka5000@yahoo.com> wrote:

> I only want to read the first line of the file but I
> don't know what to replace "foreach" with! 


The reading of the file is not done in the code that you posted,
so we cannot show you how to change the reading of the file.

We _can_ show you how to process only the first element of
the array though.


> if I'm using the wrap command correctly


There is no built-in named wrap().

So I don't know if you are using it correctly or not.

Where does that function come from?


> sub view_pick {
> $viewcnt=1;
> $cnt=0;
> foreach $st (@PAPER) 
> {


To remove the loop and process only the first element of @PAPER,
replace the 2 lines above with:

   $st = $PAPER[0];

and remove the corresponding closing curly brace.


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


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

Date: 17 Apr 2003 09:38:28 -0700
From: valerie_vanlerberghe@yahoo.fr (Valerie VANLERBERGHE)
Subject: GD::Graph axis font size
Message-Id: <609f743a.0304170838.12064998@posting.google.com>

Is there a way to set x axis font size without changing font type??

I tried $graph->set_y_axis_font(35); but it doesn't change anything...

Thanks for help

Valérie VANLERBERGHE


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

Date: Thu, 17 Apr 2003 15:01:25 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to read one line from a text file
Message-Id: <b7m948$2an4h$1@ID-184292.news.dfncis.de>

Francesco Moi wrote:
> I'm trying to read one unique line from a text file.
> 
> Until know, I've succeeded in performing this by
> making a loop:
> 
> $filename= 'foo.txt';
> $count = trim(str_replace($filename,'',`wc -l $filename`));
> open (F, $filename);
> $linenumber = 1;
> while(<F>) 
> {
> 	@Field = split '\\t';
>   	if ($linenumber = $count)
>   	{  	
>   		print "$Field[4]\n";	
>   	}
>   	$linenumber++;
> }
> 
> It works, but I consider it wastes too many resources, doesn`t
> it?

It appears to me as if there is no reason to split each line, but only 
the particular line # you want to print from. Also, you can interrupt 
the loop when it has found what it's looking for.

     $linenumber = 1;
     while(<F>)
     {
   	if ($linenumber = $count)
   	{
		@Field = split '\\t';
   		print "$Field[4]\n";
		last;
   	}
   	$linenumber++;
     }

/ Gunnar

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



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

Date: Thu, 17 Apr 2003 10:10:42 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to read one line from a text file
Message-Id: <4n7k9t5i59.fsf@holmes.bwh.harvard.edu>

On Thu, 17 Apr 2003, noreply@gunnar.cc wrote:
> 
> It appears to me as if there is no reason to split each line, but
> only the particular line # you want to print from. Also, you can
> interrupt the loop when it has found what it's looking for.
> 
>      $linenumber = 1;
>      while(<F>)
>      {
>    	if ($linenumber = $count)
>    	{
> 		@Field = split '\\t';
>    		print "$Field[4]\n";
> 		last;
>    	}
>    	$linenumber++;
>      }

This works fine, but $. gives you the current input line number for
free - no need to keep $linenumber updated.

Ted


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

Date: Thu, 17 Apr 2003 15:31:30 +0100
From: John Strauss <john-s@moving-picture.com>
Subject: Re: How to read one line from a text file
Message-Id: <20030417153130.0bac8dc5.john-s@moving-picture.com>

On Thu, 17 Apr 2003 10:10:42 -0400
Ted Zlatanov <tzz@lifelogs.com> wrote:
>
> On Thu, 17 Apr 2003, noreply@gunnar.cc wrote:
> > 
> > It appears to me as if there is no reason to split each line, but
> > only the particular line # you want to print from. Also, you can
> > interrupt the loop when it has found what it's looking for.
> > 
> >      $linenumber = 1;
> >      while(<F>)
> >      {
> >    	if ($linenumber = $count)
> >    	{
> > 		@Field = split '\\t';
> >    		print "$Field[4]\n";
> > 		last;
> >    	}
> >    	$linenumber++;
> >      }
> 
> This works fine, but $. gives you the current input line number for
> free - no need to keep $linenumber updated.
> 
> Ted

and, i think you might want to replace your assignment with a test? as in:
if ($linenumber == $count)
                ^^

so now you've got
while(<F>)
{
    if ($. == $count)
    {
        @Field = split '\\t';
        print "$Field[4]\n";
        last;
    }
}


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

Date: Thu, 17 Apr 2003 15:38:56 +0100
From: John Strauss <john-s@moving-picture.com>
Subject: Re: How to read one line from a text file
Message-Id: <20030417153856.29e295ae.john-s@moving-picture.com>

On Thu, 17 Apr 2003 10:10:42 -0400
Ted Zlatanov <tzz@lifelogs.com> wrote:
>
> On Thu, 17 Apr 2003, noreply@gunnar.cc wrote:
> > 
> > It appears to me as if there is no reason to split each line, but
> > only the particular line # you want to print from. Also, you can
> > interrupt the loop when it has found what it's looking for.
> > 
> >      $linenumber = 1;
> >      while(<F>)
> >      {
> >    	if ($linenumber = $count)
> >    	{
> > 		@Field = split '\\t';
> >    		print "$Field[4]\n";
> > 		last;
> >    	}
> >    	$linenumber++;
> >      }
> 
> This works fine, but $. gives you the current input line number for
> free - no need to keep $linenumber updated.
> 
> Ted

oops, my bad... i wrote:
"and, i think you might want to replace your assignment with a test?"

when i meant:
"and, i think you might want to test equality rather than assignment?"

if ($linenumber == $count)
                ^^


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

Date: Thu, 17 Apr 2003 09:26:53 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to read one line from a text file
Message-Id: <slrnb9tedd.6i6.tadmc@magna.augustmail.com>

Francesco Moi <francescomoi@europe.com> wrote:

> open (F, $filename);


You should always, yes *always*, check the return value from open():

   open (F, $filename) or die "could not open '$filename'  $!";


> $linenumber = 1;


The $. Perl variable already has the line number in it, there's no
need for your own variable containing the same value.


> 	@Field = split '\\t';


A pattern should *look like* a pattern:

   @Field = split /\t/;


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


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

Date: Thu, 17 Apr 2003 15:33:21 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How to read one line from a text file
Message-Id: <3E9EC91D.20601@dev.null>



Francesco Moi wrote:

[snip]
> I'm trying to read one unique line from a text file.

It's not entirely clear to me what line you are trying to read.



> $filename= 'foo.txt';
> $count = trim(str_replace($filename,'',`wc -l $filename`));


What is this trim() and str_replace() business? Are those functions 
defined elsewhere? Anyway, it looks like you are trying to put the 
number of lines in foo.txt into $count. You are using wc -l to determine 
the number of lines, but wc -l will return something like

      782 foo.txt

and you just want $count to be 782. Luckily, you don't need all that 
hocus-pocus with trim and str_replace: once you use '  782 foo.txt' as a 
number, perl will ignore the non-numeric stuff and just interpret that 
as 782. For example:

my $baz='  782 foo.txt';
print $baz+1;

will print 783.

On the other hand, if you use wc -l to find the number of lines, you 
restrict your program to Unix-type systems. There is a pure Perl way to 
count lines described in perlfaq5; you might want to consider using that.


> open (F, $filename);

It's good practice to check whether the file actually opened. Not much 
point in continuing if the open failed. Do it like this:

open (F, $filename) or die "Can't open $filename: $!";


> $linenumber = 1;

You don't have to keep track of your line numbers; perl does it for you 
in the $. special variable.

Try running this for kicks:

open F, 'reduced.txt';
while(<F>){
	print "$.\n";
};


> while(<F>) 
> {
> 	@Field = split '\\t';
>   	if ($linenumber = $count)


I'm almost certain you meant

	if ($linenumber == $count)


>   	{  	
>   		print "$Field[4]\n";	
>   	}
>   	$linenumber++;
> }
> 
> It works, but I consider it wastes too many resources, doesn`t
> it? 
> 
> Does anybody know a faster way to read one line? Thanx.
> 



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

Date: 17 Apr 2003 09:37:08 -0700
From: libertybelle2112@yahoo.com (Liberty Belle)
Subject: Interpolation problem with DB execute object
Message-Id: <d9cbd61e.0304170837.2b2aa42a@posting.google.com>

Working on a little program which will extract N number of column 
headers, as well as N data values for each header from a page of 
text. I then concatenate each to its own var($columnheads and 
$inputdata below), separating with a comma. Additionally, I get a 
var of comma separated question marks, all this to build my $sth 
prepare statement. However, when I run this I get an error:

"st execute failed: called with 1 bind variables when 5 are needed"

The problem is that it interpolates as I want it to in the prepare 
statement, but it does not in the execute. Thus it sees the var as 
its component text, column names separated by commas in the prepare, 
but only one variable in the execute, though it too is values 
separated by commas.

Any help would be appreciated.

Code as follows:

#!/usr/bin/perl

use DBI;

$dbh = DBI->connect('dbi:ODBC:financials') || die "DBI could not 
connect\n";

$columnheads = 'head1, head2, head3, head4, head5';
$columnqmks = '?,?,?,?,?,';
$inputdata = 'row1, 14, 150.34, 238.00, 12.50';

$sth_loadstmt = $dbh->prepare(qq{ INSERT INTO Table1 ( 
$columnheads ) VALUES ($columnqmks) }) || die "sth loadstmt prepare 
failed\n";

$sth_loadstmt->execute($inputdata);


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

Date: Thu, 17 Apr 2003 17:30:40 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Interpolation problem with DB execute object
Message-Id: <mbudash-E59B7C.10303817042003@typhoon.sonic.net>

In article <d9cbd61e.0304170837.2b2aa42a@posting.google.com>,
 libertybelle2112@yahoo.com (Liberty Belle) wrote:

> Working on a little program which will extract N number of column 
> headers, as well as N data values for each header from a page of 
> text. I then concatenate each to its own var($columnheads and 
> $inputdata below), separating with a comma. Additionally, I get a 
> var of comma separated question marks, all this to build my $sth 
> prepare statement. However, when I run this I get an error:
> 
> "st execute failed: called with 1 bind variables when 5 are needed"
> 
> The problem is that it interpolates as I want it to in the prepare 
> statement, but it does not in the execute. Thus it sees the var as 
> its component text, column names separated by commas in the prepare, 
> but only one variable in the execute, though it too is values 
> separated by commas.
> 
> Any help would be appreciated.
> 
> Code as follows:
> 
> #!/usr/bin/perl
> 
> use DBI;
> 
> $dbh = DBI->connect('dbi:ODBC:financials') || die "DBI could not 
> connect\n";
> 
> $columnheads = 'head1, head2, head3, head4, head5';
> $columnqmks = '?,?,?,?,?,';

this will get you an SQL error... drop the final ','...

> $inputdata = 'row1, 14, 150.34, 238.00, 12.50';

@inputdata = qw/row1 14 150.34 238.00 12.50/;

> $sth_loadstmt = $dbh->prepare(qq{ INSERT INTO Table1 ( 
> $columnheads ) VALUES ($columnqmks) }) || die "sth loadstmt prepare 
> failed\n";
> 
> $sth_loadstmt->execute($inputdata);

$sth_loadstmt->execute(@inputdata);

hth-

-- 
Michael Budash


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

Date: Thu, 17 Apr 2003 10:12:02 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: killing unix processes by name ...
Message-Id: <4n4r4x5i31.fsf@holmes.bwh.harvard.edu>

On Thu, 17 Apr 2003, as@hotmail.com wrote:
> Can any one suggest how *nix processes can be killed by name using
> perl scripts ???  thanks

Use Proc::ProcessTable from CPAN.

> this same question has been sent to other groups :-)

Crosspost, don't post multiple copies.

Ted


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

Date: 17 Apr 2003 15:15:21 GMT
From: ctcgag@hotmail.com
Subject: Re: My 1st japh!!
Message-Id: <20030417111521.653$P5@newsreader.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On 16 Apr 2003 23:46:42 GMT, ctcgag@hotmail.com wrote:
>
> >Well, the problem is that the string "12AC" isn't packed, so
> >unpack isn't the right tool for that particular job.  (Not
>
> OK, so I won't bother any more...
>
> >that someone couldn't use unpack to do it, just that it's not
> >the obvious way!)
> >
> >map hex, split //, "12AC";
>
> If you look at my japh, you'll see that's exactly what I'm doing. The
> real problem is that as I said I can't really understand the use of
> (un)pack().

I think the key is what context you are trying to understand pack and
unpack in.  I also found it hard to understand when I just wanted to know
out of curiousity, but once I actually needed them (for passing data to
and from Inline::C and XSub code), I found them easy to understand in that
context.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Thu, 17 Apr 2003 10:42:07 GMT
From: "Cao Tran" <caotran@sbcglobal.net>
Subject: Need help with NDBM_File!
Message-Id: <3yvna.985$%_3.794725@newssrv26.news.prodigy.com>


  I understand most of DB such as NDBM, ODBM, SDBM, have key+value < 1k
bytes.  When you store key+value exceed 1k you get this error message:
ndbm returned -1: error 28 at "key" chunck "";

Is there way around this such use trap to add key+value < 1024 byte and stop
add?

here is portion of my code:

dbmopen (%pages, pages, 0644);
open (LS, "ls *.txt |");
while (<LS>){
($urd, $funct, $id) = unpack(x3a4x3a4x3a5, $_);
$pages{$urd} .= ":$id"  unless $pg{$urd,$id};
$pg{$urd,$id}++
}

Because the system I use is restricted, I can't install Berkely DB module.

thanks




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

Date: Thu, 17 Apr 2003 17:13:09 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Need help with NDBM_File!
Message-Id: <b7mgru$2dh5e$1@ID-184292.news.dfncis.de>

Cao Tran wrote:
> I understand most of DB such as NDBM, ODBM, SDBM, have key+value
> < 1k bytes.

NDBM has a 4k limit. Could GDBM (no size limit) possibly be an
alternative for you?

See the comparison table at
http://search.cpan.org/author/JHI/perl-5.8.0/lib/AnyDBM_File.pm

/ Gunnar

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



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

Date: Thu, 17 Apr 2003 15:18:18 GMT
From: rob <rbinn@shaw.ca>
Subject: Re: Nesting tables with perl CGI
Message-Id: <3E9EB8F4.64AD5C2C@shaw.ca>

This is a multi-part message in MIME format.
--------------0F9B52D34F420690DEF4D3A6
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Andrew McGregor wrote:

> rob wrote:
> > Hello,
> >   I need help nesting tables within a 1 row 2 - 3 column table . The
> > tables to be nested are generated from mysql queries. If someone could
> > give me a brief demonstration I am sure I would be able to figure out my
> > mistakes. I could post the code if needed, but I think it is a standard
> > issue.
> > Thanks for any help offered...
> > Rob
> >
>
> Code would be good as I'm not sure where you are having problems, but:
>
> http://stein.cshl.org/WWW/software/CGI/
>
> Special Forms for Importing HTML-Tag Functions
>
> Example:
>
>    use CGI qw/:standard *table start_ul/;
>
> In this example, the following functions are generated in addition to
> the standard ones:
>
>     1. start_table() (generates a <TABLE> tag)
>     2. end_table() (generates a </TABLE> tag)
>     3. start_ul() (generates a <UL> tag)
>     4. end_ul() (generates a </UL> tag)

Thanks for your reply,
  Here is the code. Mr. Stein's link would seem to contain the answer. But in
my case I need a pointer...
Rob

--------------0F9B52D34F420690DEF4D3A6
Content-Type: text/plain; charset=us-ascii;
 name="compare3.cgi"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="compare3.cgi"

#! /usr/bin/perl -w


use strict;
use lib qw(/usr/local/apache/lib/perl);
use CGI qw(:standard escapeHTML);
use WebDB;

print header(),  start_html(-title=>"Team Comparison", -h1=>"Compare Individual Teams",-bgcolor=>"#666699",-text=>"#FFFFFF");






if (param()) { 
 my ($rs_ref,$rs_ref1, $row_ref,$row_ref1, @table_row, @table_row1);
   my $table1= uc param("ID_1");
   my $table2 =param ("ID_2");
  
     my  $dbh = DBI->connect ("DBI:mysql:host=192.168.1.4;database=draft2003",
			    "xxxxx", "yyyyyyy",
			    {PrintError => 0, RaiseError => 1});
     my $sth = $dbh-> prepare("SELECT draftees.ID,draftees.name,draftees.Player,Players.Team,Players.points,Players.Injury_report FROM draftees LEFT JOIN Players ON(draftees.Player=Players.Player) WHERE ID=$table1 ORDER BY draftees.ID" );
       $sth->execute ();
       
     $rs_ref = $dbh->selectall_arrayref ("SELECT draftees.ID,draftees.name,draftees.Player,Players.Team,Players.points,Players.Injury_report FROM draftees LEFT JOIN Players ON(draftees.Player=Players.Player) WHERE ID=$table1 ORDER BY draftees.ID");

                                            
     
      


   push (@table_row,Tr (th (""), th (" ID "), th (" NAME "), th (" PLAYER "),th (" TEAM "),th (" Points "),th (" Injury Report ")));

	                                         foreach $row_ref (@{$rs_ref})
	                  {
		                                #my $label = $map_ref->{$row_ref->[0]};	# map name to descriptive label
                                                my $label = $row_ref->[0];	# map name to descriptive label

		                    push (@table_row, Tr (
				        td (escapeHTML ($label)),
				        td ({-align => "centre"}, $row_ref->[0]),
                                        td ({-align => "center"}, $row_ref->[1]),	
				        td ({-align => "center"}, $row_ref->[2]),
                                        td ({-align => "center"}, $row_ref->[3]),
                                        td ({-align => "centre"}, $row_ref->[4]),
                                        td ({-align => "centre"}, $row_ref->[5]),
                                       td ({-align=> "centre"}, $row_ref1->[6])
			                   ));
	                                                   }
	                      print table ({-border =>10},@table_row);

 my $sth1 = $dbh-> prepare("SELECT draftees.ID,draftees.name,draftees.Player,Players.Team,Players.points,Players.Injury_report FROM draftees LEFT JOIN Players ON(draftees.Player=Players.Player) WHERE  ID=$table2 ORDER BY draftees.ID" );
       $sth->execute ();
       
     $rs_ref1 = $dbh->selectall_arrayref ("SELECT draftees.ID,draftees.name,draftees.Player,Players.Team,Players.points,Players.Injury_report FROM draftees LEFT JOIN Players ON(draftees.Player=Players.Player) WHERE ID=$table2 ORDER BY draftees.ID");

                                               push (@table_row1,Tr (th (""), th (" ID "), th (" NAME "), th (" PLAYER "),th (" TEAM "),th (" Points "),th (" Injury Report " )));
	                                         foreach $row_ref1 (@{$rs_ref1})
	                  {
		                                #my $label = $map_ref->{$row_ref->[0]};	# map name to descriptive label
                                                my $label1 = $row_ref1->[0];	# map name to descriptive label

		                    push (@table_row1, Tr (
				        td (escapeHTML ($label1)),
				        td ({-align => "centre"}, $row_ref1->[0]),
                                        td ({-align => "center"}, $row_ref1->[1]),	# tally
				        td ({-align => "center"}, $row_ref1->[2]),
                                        td ({-align => "center"}, $row_ref1->[3]),
                                        td ({-align => "centre"}, $row_ref1->[4]),
                                        td ({-align => "centre"}, $row_ref1->[5]),
							   td ({-align=> "centre"}, $row_ref1->[6]) 
                                      
			                   ));
	                                                   }
	                      print table ({-border =>10},@table_row1);


}else {
  print start_form();
print p("To compare 2 teams just enter the ID number in each field, or to view your own team enter your ID in both fields.");
  print br();
  print p ("Enter your ID number",textfield("ID_1"));
  print p ("Enter ID to compare with ",textfield("ID_2"));
  print p( submit("Search"),reset("Clear"));
  print end_form();
}

exit (0);

--------------0F9B52D34F420690DEF4D3A6--



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

Date: Thu, 17 Apr 2003 15:32:34 GMT
From: pls@post.here (Adam)
Subject: Re: slow/inefficient script: seeking help with multimatch/multipass pattern matching
Message-Id: <n9ht9vk1h9jfk61ig17jm07nuqh01v8bfl@4ax.com>

Brian McCauley <nobull@mail.com> wrote:
>Using package variables rather than lexicals is slightly slower but I
>doubt it's all that significant.

[ lots of other great advice snipped ]

Yes, I added "use strict" and converted my package variables to
lexicals.

>> @mailpats   = map { qr/\b$_\b/i } @mailids;
>
>You probably meant: 
>
> my @mailpats   = map { qr/\b\Q$_\E\b/i } @mailids;

I actually ended up using "map { qr/$_/i } @mailids;" as I wasn't sure
I needed the anchors.

>To:
>  $mailids{$1} = 1;

I'll try a hash.  I had considered it but  I guess I was following the
FAQ's (@popstates) and perldoc examples I was using too closely.  

>Perhaps because you really want to say..
>
>         print "$logline_hash{$_}\n";

Yes it was probably a typo/omission since I was going through so many
versions of the script and even the next day (Sunday) the script
changed a lot.   I'll post a newer copy once I've tried some of your
suggestions.

By the way, the one thing that cut the processing time to 1/3 was
another omission.  I *thought* I was using /o (compile once) in this
line:
>  next unless /$date.*?]: \w+?: (from|to)/i ;

Anyhow I removed that line entirely and recreated the "if $match" with
an && condition like you show (using the /o for the pattern) but just
not using a hash.    And that sped it up considerably.   It now works
ok when there aren't a ton of patterns but still bogs down horribly
when there are so I still have a strong incentive to study your
suggestions so I get it right. 

thanks again for taking the time to respond and explain,

Adam


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

Date: 17 Apr 2003 08:06:48 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Stumped!
Message-Id: <776e0325.0304170706.6a52ace2@posting.google.com>

pooba53 <delautenschl@[nospam]wisc.edu> wrote in message news:<b7k9ae$84n$1@news.doit.wisc.edu>...
> With the following code:
> 
> while (($key,$aref) = each (%AllGenes))  {
>      @unique = grep !$seen2{$_}++, map $_, $aref;
> 
>      print "Unique elements for $key is: @{$unique[0]}\n\n";
> 
> 
> }
> 
> I do get something to print out, but I cannot figure out how to print 
> all of the @unique list instead of the first element.
> 
> Thanks.
> -Dan

Remember Perl makes difficult things easy and the impossible possible.
Or something like that. Anyhow- it appears you made an easy thing
difficult. Toss all of the greps and maps and increments etc... When
you say you want to extract the unique elements in the arrays, that
screams "HASH!". Just populate a hash with the arrays and botta-bing
you have the unique ones. Sort it if order is important. In fact,
store the sorted keys in an array if that's important..

 #!/usr/bin/perl -wd

 my @a1= (1, 2, 3);
 my @a2 = (3, 4, 5);

 my %h;
 @h{@a1,@a2}= ();

and %h is populated with the unique array values (the keys that is-
the hash values we're ignoring..).


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

Date: Thu, 17 Apr 2003 17:24:07 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Using a pre-processor to generate POD
Message-Id: <newscache$7suhdh$s02$1@news.emea.compuware.com>


Hello all,

I am currently working on a cpp look-a-like to generate my inline POD
documentation. The reason is that I have a base class from which I stem
numerous (30) other classes. Due to the shared base class, many methods are
the same. And as I don't want to write the same POD over and over again, I
was trying to have cpp generate the POD for me. But cpp has it's
limitations (tokens, terms, balanced quotes, etc). 

With popproc (POD Processor) I can now say:

--- House.pm ---
#define PACKAGE_NAME    House
#define OBJECT_NAME     house
#define OBJECT_VAR      $house
#include new.pod

--- Car.pm ---
#define PACKAGE_NAME    Car
#define OBJECT_NAME     car
#define OBJECT_VAR      $car
#include new.pod



---- new.pod ---

=item new()

Creates and returns a new OBJECT_NAME object. Once such an object is
created, you can call other object methods against it. Example:

    my OBJECT_VAR = PACKAGE_NAME->new();




This will now generate all the POD required and I only have to change stuff
in one place. Let me know if you find this interesting. Due to time
constraints I am not going to publish it. If someone likes it enough to
adopt it for CPAN publication or alike, I'll gladly hand it over.

Cheers,
-- 
KP



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

Date: Thu, 17 Apr 2003 17:31:12 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Using a pre-processor to generate POD
Message-Id: <b7mkhb$qi6$1@news.dtag.de>

Koos Pol wrote:
> Hello all,
> 
> I am currently working on a cpp look-a-like to generate my inline POD
> documentation. The reason is that I have a base class from which I stem
> numerous (30) other classes. Due to the shared base class, many methods are
> the same. And as I don't want to write the same POD over and over again, I
> was trying to have cpp generate the POD for me. But cpp has it's
> limitations (tokens, terms, balanced quotes, etc). 

Looks like YATM (yet another template module). Whats the advantage 
compared to Template Toolkit?

malte



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

Date: Thu, 17 Apr 2003 17:40:44 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Using a pre-processor to generate POD
Message-Id: <newscache$wjvhdh$o22$1@news.emea.compuware.com>

Malte Ubl wrote (Thursday 17 April 2003 17:31):

> Looks like YATM (yet another template module). Whats the advantage
> compared to Template Toolkit?
> 
> malte


I have no idea. I haven't looked at it. I can only this should be a
preprocessor. Not a templating mechanism. But that perhaps is also a matter
of definition.

-- 
KP



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

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


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