[18816] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 984 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 25 06:05:36 2001

Date: Fri, 25 May 2001 03:05:09 -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: <990785109-v10-i984@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 25 May 2001     Volume: 10 Number: 984

Today's topics:
    Re: $? after close nobull@mail.com
    Re: 2 simple question on Getopt and Ftp <kennylim@techie.com>
        a newbie question: how to represent binary trees ?? <hamzay@telocity.nospam.com>
    Re: a newbie question: how to represent binary trees ?? <krahnj@acm.org>
    Re: Executing CGI on a Mac, help? <goldbb2@earthlink.net>
    Re: find executable files only <uri@sysarch.com>
        generates random text file (with structural framework)? <gokkog@yahoo.com>
    Re: Help slim down Perl code <uri@sysarch.com>
    Re: How to invoke another script in a CGI script? <superclear2000@yahoo.com>
    Re: installing libwww-perl on Win 95 <simon.andrews@bbsrc.ac.uk>
    Re: looping through text to get info <godzilla@stomp.stomp.tokyo>
    Re: Match Parsing Glitch <nospam@xx.com>
    Re: Match Parsing Glitch <nospam@xx.com>
    Re: Match Parsing Glitch <abe@ztreet.demon.nl>
    Re: Problem with scalar variables <uri@sysarch.com>
    Re: regexp for triming domainnames (Patrick Erler)
    Re: Search and replace text in a file based on a specif <clefevre%no-spam@redirect.to.invalid>
    Re: SET-UP (free) <uri@sysarch.com>
    Re: sounder <thunderbear@bigfoot.com>
        system() & background process <hansfn+news@mi.uib.no>
        This Is Probably A Newbie Error (Barry Allwood)
    Re: This Is Probably A Newbie Error <peter.sogaard@tjgroup.com>
        vestale.pl ascii animation (Alain)
    Re: wwwboard.pl - Taint and Use Strict <uri@sysarch.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 25 May 2001 08:48:08 +0100
From: nobull@mail.com
Subject: Re: $? after close
Message-Id: <u966ep6b8t.fsf@wcl-l.bham.ac.uk>

"Nicholas R. Markham" <nickmarkham@mailandnews.com> writes:

> It appears to me, however, that $? is actually 256 times the exit
> status.  Is this what's supposed to happen?

Yes, see the description of $? in "perldoc perlvar".

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


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

Date: Fri, 25 May 2001 01:30:15 -0700
From: "Student" <kennylim@techie.com>
Subject: Re: 2 simple question on Getopt and Ftp
Message-Id: <9el4t2$e4d$1@slb1.atl.mindspring.net>

Thanks Guys. Have a nice long weekend.

Kenny-


"Student" <kennylim@techie.com> wrote in message
news:9eihpu$b2t$1@nntp9.atl.mindspring.net...
> Hi Guys,
>
> I have 2 simple/straighforward questions
> and are wondering if anyone out
> there would be kind enough to point me
> to the correct directions.
>
> Any advise or pointers would be greatly appreciated.
>
> Thanks in advance.
>
> Kenny-
>
>
> Question 1:
> ========
>
> How can I parse a long arguments via the command lines
> (e.g. for a select statements) ?
>
> Snippets of a test example:
> -----------------------------
>
> getopts( 'q:');
> $Query = $opt_q ;
> print "$Query\n";
>
> perl t1.pl -q select col1, col2 from tableA where col1 = 100 and col2 =
200
> order by col1
>
> Question 2:
> =========
>
> How can I retrieve a filename without fully specifying the filename
> using Net::FTP module. So far this module seem to only recognize
> get and not mget and Get doesn't seem to accept wildcard. Is there
> a work around or have a package that accepts wildcard ?
>
> Snippets of an example:
> -----------------------------
>
>  $remotetracefile = "*$process_id.trc";
>  $localtracefile = "trace-$instance_name-$date-$process_id.trc";
>
>  $ftp->get($remotetracefile, $localtracefile)
>  or die "Cannot Get File!.\n";
>
> Note: I have a bunch of *.trc file and I would only like to retrieve the
> file based on the $process_id given.
> (e.g. *1234.trc and the complete filename is sun_trace_1234.trc)
>
>
>
>
>
>
>
>
>
>




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

Date: Thu, 24 May 2001 22:01:08 -0700
From: "mark" <hamzay@telocity.nospam.com>
Subject: a newbie question: how to represent binary trees ??
Message-Id: <EElP6.8890$ce.6922809@newsrump.sjc.telocity.net>

Hi all,

I have one newbie question: How can I represent binary trees in Perl.

thanx
mark




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

Date: Fri, 25 May 2001 06:15:09 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: a newbie question: how to represent binary trees ??
Message-Id: <3B0DF882.340E1AC7@acm.org>

mark wrote:
> 
> Hi all,

Hi Mark,

> I have one newbie question: How can I represent binary trees in Perl.

Chapter three of _Mastering Algorithms with Perl_ appears to cover
binary trees.
http://www.oreilly.com/catalog/maperl/
Click on the Examples link for the code (I assume.)

> thanx
> mark

Your welcome


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 25 May 2001 00:40:05 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Executing CGI on a Mac, help?
Message-Id: <3B0DE225.8797E70F@earthlink.net>

Kenneth Knight wrote:
> 
> I'm trying to get a relatively simple CGI applicaiton up and running
> on a system that uses a Macintosh to host its web sites. The CGI is
> written using MacPerl (v 5.2.0r4 - latest version I know of and that's
> pretty old). It runs fine if I serve it using something like Apple's
> Personal Web Sharing, but on this other machine I continually get
> "Error. Unable to launch ACGI application" messages. Can anyone
> suggest what might be going on. Here is the script code (admittedly
> not very pretty; I'm a Perl neophyte).

Well, the problem you have is not likely a perl problem, per se, since it
*does* run on at least one machine.  I can't offer you help with that.

However, your code does have some problems, especially with parameter
parsing.  You really really should be using the CGI module until you're
much more experienced with CGI and perl.  I don't think that your code
loads into the @ids array what you expect it to, and you certainly
aren't checking for when one id is a prefix of another.  Suppose you
have a query for the id "joe", and the database doesn't contain "joe",
but does contain "joeseph".  With your code, the record for "joeseph"
might be printed (assuming you fixed the parsing to initalize @ids
right).  Somehow, I don't think that printing "joeseph"'s record would
be what you really want done.

Setting the charset is a good idea if your code *uses* it, but is not
necessary otherwise.  And when it *is* set, it should be part of the
http header, in addition to being in the html head.

Using ""s around html parameters is rarely necessary, unless there are
spaces in the string.  So <P align=center> works just as well as
<P align="center">.  Eliminating them can make reading MUCH easier,
especially if the tag was already inside quotes, and had the quotes
escaped.  Using something other than "" for quoting (like q, qq, '', or
a here-document) will also allow you to avoid having to escape the ""
characters.

#! perl -w -T
use strict;
use diagnostics;

Always use warnings and strict.  Good code should run without any
warnings or errors when run with both these things turned on.  Always
have taint checks turned on when running a CGI program.  Use diagnostics
if you want to figure out what the wierd errors mean.


> # Get the input
> $buffer = $ENV{'QUERY_STRING'};

use CGI qw(:html4);
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new;

> 
> # Get working directory.
> $base = `pwd`;
> $base =~ s/CGI-Bin//;
> $base =~ tr/:/\//;

I would do this as:

use FindBin;
($base) = $FindBin::Bin =~ m[^(.*)[:/]];
$base =~ tr[:][/];

But I don't see where it's needed.

> 
> # Split the name-value pairs
> @ids = split(/&/, $buffer);
> 
> foreach $id (@ids) {
>    # Un-Webify plus signs and %-encoding
>    $id =~ tr/+/ /;
>    $id =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>    $id =~ s/<!--(.|\n)*-->//g;
> }

Not needed.  CGI.pm does this for you.  Well, it doesn't remove
<!--...--> thingies, but I don't see how those would get into your input.

In a normal situation, QUERY_STRING contains something like:
	key1=value1&key2=value2&key3=value3
Also, your @ids would now contain a bunch of key=value items.
You later try to use these directly.  Do the people in your file
*really* have names like "key1=value"?

Much more likely, you have a select field in your form, where you can
select multiple names.

my @ids = $cgi->param("ids");

> # Retrieve the contens of the table of contents.
> 
> open (FILE,"biographies.data") || die "Can't Open file: $!\n";
> @LINES=<FILE>;
> close(FILE);
> $SIZE = @LINES;
> 
> # make one big string.
> $data = "";
> for ($i=0;$i<=$SIZE;$i++) {
>   $data = $data . $LINES[$i];
> }

Why do you read and then join?  Also, isn't this the best place to
parse the contents of biographies.data?

my %data;
if( open( my $file, "<", "biographies.data" ) ) {
	while( defined $_ = <$file> ) {
		m/^id:/ or die "Malformed line line: $file: $.";
		my $y = <$data>;
		for(@x) { s/^[^:]*:// }  #remove id:
		for(@x,$y) { s/^\s*//; s/\s*$// } #trim whitespace
		$data{$x[0]} = [ @x[1,2], $y ];
	}
} else {
	die "Can't open 'biographies.data': $!\n";
}

Of course, it would probably be better to change the format of
biographies.data to something more easily parsable. I'll forgive you
for not doing that iff it is beyond your control.

> # Print the header of the table of contents file
> print "Content-type: text/html\n\n";

print $cgi->header;

> print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\t\t\t\"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n";
> print "<html><head>\n\t<title>BackpackingLight.Com Biogaphy</title>\n";
> print "\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
> print "\t<link rel=\"stylesheet\" href=\"stylesheets/article.css\" type=\"text/css\">\n";
> print "\t<meta name=\"generator\" content=\"BBEdit 5.1.1\">\n";
> print "\t<script language=\"javascript\" type=\"text/javascript\" src=\"functions.js\"></script>\n";
> #print "\t<base href=\"$base\">\n</head>\n"
> print "<body bgcolor=\"#FFFFFF\">\n";

Use a here-document.

Also, since this wasn't generated using BBEdit, you shouldn't have that
line there.  "generator" is when talking about html created by a word
processor which does markup in whatever it's internal format is, then
outputs in html.  So if you wrote a doc using M$word, with colors, sizes,
tables, etc, and then did save as html, m$word should stick in a mega
generator tag.  CGI scripts are generally made by someone editing the
code directly (ie, editing as a plain text file).  This should *not* have
a meta generator= tag.  If you had a program which produced perl source
code to use as a script (sourceforge or somesuch), then maybe it should
stick in a meta generator (maybe).

print (<<'HtmlHeader');
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head>
	<title>BackpackingLight.Com Biogaphy</title>
	<link rel=stylesheet href=stylesheets/article.css type=text/css>
	<script language=javascript type=text/javascript src=functions.js></script>
</head><body bgcolor="#FFFFFF">
HtmlHeader

> $i = 1;             # index variable

Why is this here?

> $numIDs = @ids;     # number of IDs
> if ($numIDs == 1) {
>   print "<table width=\"100%\" cellpadding=\"5\" border=\"1\">";
> } else {
>   print "<table width=\"100%\" cellpadding=\"5\" border=\"1\"><col width=\"50%\"><col width=\"50%\">\n";
> }

Why store the number of parameters in a variable, why not make the test directly?

print '<table width="100%" cellpadding=5 border=1>';
print '<col width="50%"><col width="50%">' if(@ids > 1);

> # if there is more than 2 ids and the last one is an odd numbered one it gets its own line. Flag it.
> if ( ( $numIDs >= 3) && ( ($numIDs % 2) == 1) ) {
>   $lastIDAlone = 1;
> } else {
>   $lastIDAlone = 0;
> }

@ids = grep { $data{$_} } @ids;
my $lastIDAlone = ((@ids >= 3) && (@ids % 2)) ? 1 : 0;

> # start processing each id
> foreach $id (@ids) {
> # Does the person exist?
>   if ( $data =~ /(.*?)id:[ \t]*?$id(.*?)\n(.*?)\n/ ) {

for my $i (0 .. $#ids-$lastidalone)) {
	my $id = $ids[$i];
	# next unless $data{$id); # not needed due to grep.

>     $theData = $&;
>     ($bioHeader, $bioData) = split(/\n/, $theData);
> 
>   # There is probably a better way to do this. But, this seems to work. Get the name and image info.
>   # If no image is present then "" is put in $image.
>     ($temp, $name, $image) = split(/;/, $bioHeader);
>     ($temp, $name) = split(/:/, $name);
>     ($temp, $image) = split(/:/, $image);
>     $name     =~ s/^\s*(.*?)\s*$/$1/;             # trim whitespace
>     $image    =~ s/^\s*(.*?)\s*$/$1/;             # trim whitespace
>     $bioData  =~ s/^\s*(.*?)\s*$/$1/;             # trim whitespace

	my ($name, $image, $biodata) = @$data{ $id };
	# all the data was parsed when the file was read in.

>   # if this is the last ID and $lastIDAlone is set then don't print this ID yet.
>     if ( ( ( $i == $numIDs ) && ( $lastIDAlone == 1) ) == false) {
>     # print out HTML code for each bio here.
>       if ( ($i % 2) == 1) {
>         print "\t<tr>\n";
>       }
>       print "\t\t<td valign=\"top\">\n\t\t\t<p class=\"title\">$name</p>\n";
>       if ( $image ne "" ) { print "\t\t\t<p><script language=\"javascript\" type=\"text/javascript\">".
>		"document.write(LoadBioImage(\"$image\",\"$name\" ))</script></p>\n"; }
>       print "\t\t\t$bioData\n";
>       print "\t\t</td>\n";
>       if ( ($i % 2) == 0) {
>         print "\t</tr>";
>       }
>     }

	print "\t<tr>\n" if( !($i % 2) );
	print "\t\t<td valign=top>\n\t\t\t<p class=title>$name</p>\n";
	print "\t\t\t<p><script language=javascript type=text/javascript>" .
		"document.write(LoadBioImage('$image','$name'))</script></p>\n" if $image;
	print "\t\t\t$bioData\n";
	print "\t\t</td>\n";
	print "\t</tr>\n" if( ($i % 2) );


>     $i = $i + 1;
>   }
> } # foreach
> if ( ( ($i - 1) % 2) == 1) {
>   print "\t</tr>";
> }

Not needed, since the </tr> is done in the loop.

> print "\n</table>";

print "</table>\n";

> 
> # do we have one ID left to print?
> if ($lastIDAlone == 1) {                    # yes
>   print "<table border=\"`\" cellpadding=\"5\" width=\"50%\" align=\"center\">\n\t<tr>\n\t\t<td valign=\"top\">\n";
>   print "\t\t\t<p class=\"title\">$name</p>\n";
>   if ( $image ne "" ) { print "\t\t\t<p><script language=\"javascript\" type=\"text/javascript\">".
>	"document.write(LoadBioImage(\"$image\",\"$name\" ))</script></p>\n"; }
>   print "\t\t\t$bioData\n";
>   print "\t\t</td>\n";
>   print "\t</tr>\n</table>";
> }
> print "</body></html>";

if( $lastIDAlone ) {
	my ($name, $image, $biodata) = @$data{ $ids[-1] };
	print "<table border=1 cellpadding=5 width=50% align=center>\n\t<tr>\n"
	print "\t\t<td valign=top>\n\t\t\t<p class=title>$name</p>\n";
	print "\t\t\t<p><script language=javascript type=text/javascript>" .
		"document.write(LoadBioImage('$image','$name'))</script></p>\n" if $image;
	print "\t\t\t$bioData\n";
	print "\t\t</td>\n\t</tr>\n</table>\n";
}

print "</body></html>\n";

NB the given pieces of code are untested.  Any followups or questions
*please* post to clpm, not my email.

-- 
Customer: "I would like to try on that suit in the window."
Salesman: "Sorry sir, you will have to use the dressing room."


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

Date: Fri, 25 May 2001 04:34:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: find executable files only
Message-Id: <x7ae422gj4.fsf@home.sysarch.com>

>>>>> "DE" == David Efflandt <see-sig@from.invalid> writes:

  DE> On Thu, 24 May 2001 16:34:06 -0400, Claudio Inglesi <cinglesi@puc.cl> wrote:
  >> Does anyone know how to use the find command so that it only finds files
  >> that are executable (files whose permissions are set as executable for the
  >> user, group or everybody).
  DE>     $file = $File::Find::name;
  DE>     $mode = (stat($_))[2];
  DE>     $mode = sprintf "%lo",$mode;	# convert to octal
  DE>     if ($mode =~ /^(\d)\d\d(\d)(\d)(\d)/) {
  DE>         return 0 unless $1 == 1;	# file?
  DE>         $owner = $2; $group = $3; $other = $4;
  DE>         return 0 unless ($owner & 1 || $group & 1 || $other & 1);
  DE>     } else { print "regex problem for $file $mode"; return 0; }
  DE>     print "$file $owner$group$other\n";

ever heard of -x?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 25 May 2001 16:27:51 +0800
From: "Wenjie ZHAO" <gokkog@yahoo.com>
Subject: generates random text file (with structural framework)?
Message-Id: <9el4ud$d4f$1@slbhw0.bln.sel.alcatel.de>

Hello perl people,


I right now got a task to prototyping some
XML merging,compressing and exporting taskes which the
performance is highly depending on the XML
file contents. I want to simulate the real
world more accurately and decided to use perl
program to generate those bulk files. I think
I select the correct tool, but then
I found I have little idea for random "plain
text" generation:? Some inputs from a Dictionary?
some Markov chain program?

I hope there is some simple solution somewhere.
And you could tell me.


Thanks a lot!
Best Regards,
wenjie




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

Date: Fri, 25 May 2001 04:19:10 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help slim down Perl code
Message-Id: <x7g0du2h8h.fsf@home.sysarch.com>

>>>>> "BG" == Benjamin Goldberg <goldbb2@earthlink.net> writes:

  BG> Uri Guttman wrote:

  >> i use symrefs in once case to install closure methods in an
  >> AUTOLOAD. but that is very isolated and stable.
  >> 
  >> seeing symrefs used (and promoted) for data structures is the biggest
  >> evil use as that is never needed.

  BG> My symref use was not for a data structure.  It was to load three files
  BG> with closely related names into three global variables with closely
  BG> related names.  Sure, it's fragile, but then again, so is hard coding
  BG> filenames into a script.

huh? hard coding filenames is fragile? that is done all the time and i
don't see complaints. 

  BG> All parts of the variable names came from within that block -- so
  BG> I *know* that nothing strange is getting in them.  It's when you
  BG> get the names nonlocally that problems can arise.

no, it can break as the vars are globals. you can't do symrefs with
lexicals so you are exposing those vars as well. double trouble.

  BG> I try to treat stuff going into symref names as carefully as I would
  BG> treat tainted data in a CGI script -- maybe even more carefully.  Hmm...

  BG> for( my ($key,$val) = each %ENV ) {
  BG> 	if( $key =~ s/^HTTP_([A-Z0-9_]+)$/\L$1/  && !defined &$key ) {
  BG> 		*{$key} = sub { $val };
  BG> 	}
  BG> }

  BG> Now the above *is* evil. *That* is the type of symref you should be
  BG> warning us about.  It's something that looks useful, but is very
  BG> dangerous.

you have it backwards.  installing subs is one of the few legit uses of
symrefs as you can't do it any other way. how you install them can be an
issue. but symrefs are never needed to mung data structures.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 25 May 2001 02:18:15 -0400
From: "Dan" <superclear2000@yahoo.com>
Subject: Re: How to invoke another script in a CGI script?
Message-Id: <9ektj7$tem$1@node21.cwnet.roc.gblx.net>

I believe this is what you are looking for.

http://www.perlconcepts.com/programs/callcgi/

Dan







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

Date: Fri, 25 May 2001 10:03:14 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: installing libwww-perl on Win 95
Message-Id: <3B0E1FD2.7F447618@bbsrc.ac.uk>

devs wrote:
> 
> Hi,
> I have ActiveState perl 5.6.0 running on Win 95.
> I am trying to install libwww-perl module.

Lib-www is part of the core distribution for Activestate 5.6.  You don't
need to install it - it's already there!

Simon.


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

Date: Thu, 24 May 2001 22:14:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: looping through text to get info
Message-Id: <3B0DEA2A.C52426EC@stomp.stomp.tokyo>

Gary wrote:
 
> Godzilla! wrote:
> > Gary wrote:

> > > I have a text file that looks like this:

> > > Database Name : database1

> > (snipped)

> > I am curious to know what software produces
> > this database.

> The database is SYBASE and the textfile is output from a DBCC command

I suspected this software is not top quality commercial
binary but rather allows user tampering beyond what would
be considered safe.

Look at your data structure. It is exceptionally illogical.
I have snipped out most leaving only that which is
of importance.


Database Name : database1
Type Code: 100030; Hard fault

Type Code: 100030; Hard fault


Database Name : database2
Type Code: 100030; Hard fault

Type Code: 100030; Hard fault


Your first record is labeled database1 and, the following
record is not, although it references database1 per your
stated parameters.

Same is true for your third and fourth record.

Why is this?


You ask how to sort your records by database number
yet structure your data with no database number
references for all records. This makes little sense.

This makes even less sense when adding new records
to your database. Clearly your program, whatever
program you are actually using, must differeniate
between databases, one and two. Why does your program
not print a database reference number for each and
every entry? Your database structure directly indicates
a first record is labeled but subsequent records are
not labeled. Otherwords, your software deliberately
removes database references for any records subsequent
to an initial first record.

To add a new record, your program must first find
an initial first record with a database reference,
move through records until it encounters an initial
first record with a different reference, then has to
backtrack to add a record in the right place. 

Your software knows which database it is working
with. Why does it remove database numerical references?

Even more senseless, why have you programmed your
software to do this?

Equally illogical is having to search a database
with records missing database references. Your
program must find an initial first record to
differentiate databases, then search records
until it encounters an initial first record
with a different database reference, then
backtrack just like it would to add a record.

Why are you not simply appending records each
with a clear database reference?

database3 - record
database1 - record
database4 - record
database2 - record
database1 - record
database4 - record

This above structure makes sense. Easy to search,
no need for backtracking, fast appending of records
and very easy to sort by criteria indexing.

What you display.. well.. hmm..

database1 - record
           -record
           -record

database2 - record
           -record
           -record

database3 - record
           -record
           -record

Do you see what is missing? What is missing is logic.

Give consideration to reworking your database into a
logically structured and easily managed database rather
than asking how to write code to deal with a poorly
structured database.

Godzilla!


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

Date: Fri, 25 May 2001 00:22:37 -0700
From: Eric <nospam@xx.com>
Subject: Re: Match Parsing Glitch
Message-Id: <3B0E083D.7B290D85@xx.com>

"E.Chang" wrote:
> You probably downloaded the "Build 626 Source Distribution" instead of
> the already compiled version.  The links on the ActiveState site are
> side by side.  Look again at
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/.  You want to
> download from the ActivePerl 5.6.1.626 table on the left.

Thanks, man...I'll go have another look.

Eric


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

Date: Fri, 25 May 2001 00:45:35 -0700
From: Eric <nospam@xx.com>
Subject: Re: Match Parsing Glitch
Message-Id: <3B0E0D9F.A8B54BBA@xx.com>

"E.Chang" wrote:
> You probably downloaded the "Build 626 Source Distribution" instead of
> the already compiled version.  The links on the ActiveState site are
> side by side.  Look again at
> http://aspn.activestate.com/ASPN/Downloads/ActivePerl/.  You want to
> download from the ActivePerl 5.6.1.626 table on the left.

OK...I looked again, but have no clue if I should get the MSI or AS
Package.
I've never seen an ".msi" extension before.  How in the #&^! is one
supposed to install such a thing???

Apparently, ActiveState has never heard of the tried & true ".exe"
self-executable format use by most on the planet????

Eric


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

Date: Fri, 25 May 2001 10:55:38 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Match Parsing Glitch
Message-Id: <ea2sgtg4qnp09od7nr1j7pfsqa6tip5rr1@4ax.com>

[ please do _not_ send stealth CC's ]
On Thu, 24 May 2001 14:05:13 -0700, Eric <nospam@xx.com> wrote:

> Abe Timmerman wrote:
> > 
> > Please, in future, use Copy/Paste if you want to show code here. People
> > can't see the difference between typo's and other mistakes.
> > 
> Abe -
> 
> OK...I plugged in your suggestions and have been scratching my head
> trying to figure out what's wrong.  I consolidated (hand-typed) the
> error messages and perhaps you can help me decipher what's wrong.  I #'d
> out the whole "for 3..12" at Line 27 but that didn't work.  I thought
> more about your other question and "Yes"...each record will ALWAYS have
> those lines which beging with 'SO' and/or 'LA' ... just the actual name
> fields could be blank once in a while so no biggie there.
> 
> Eric
> ----
> 
> ERRORS:
> Global symbol "R" requires specific package name at Line 3
> Global symbol filename require specific package name at Lines 5,8,9
> Global symbol datafile require specific package name at Line 7
> Variable "$filename" is not imported at Line 8,9

Descriptions of these errors can be found in perldiag.pod

	perldoc perldiag

You can also let perl do the lookup for you, if you put the line

	use diagnostics;

near the top of your program whilst developing.

It looks like you need to declare the variables with my() or the "use
vars" pragma.

	perldoc -f my
	perldoc vars

> Variable "$line" is not imported at Lines 17,21,23,25,28
> Global symbol "line" require specific package name at Lines
> 14,17,21,23,25,28

Well, it seems the my $line = <INPUT> declaration within the while
condition was introduced in Perl 5.004, I forgot you are running an
older Perl (5.003_07).

> syntax error at Line 28, near "<INPUT> for "

Ahh, that is also my mistake. I think that syntax was introduced in Perl
5.005.

[ sniped some code ]

> while ( my $line = <INPUT> ) 									

Rework that:

	my $line;
	while ( defined( $line = <INPUT> ) )

But you should try to upgrade your perl.

[ snipped some more code ]

>         $line = <INPUT> for 3..12; # skip some lines

Rework that line:

	for ( 3..12 ) { $line = <INPUT> }

-- 
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -e '$_=sub{split//,pop;print pop while@_};&$_("rekcah lreP rehtona tsuJ")'


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

Date: Fri, 25 May 2001 04:15:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Problem with scalar variables
Message-Id: <x7itiq2heb.fsf@home.sysarch.com>

>>>>> "SD" == Scott DiNitto <usenet@infracore.dyndns.org> writes:

  >>> Can anyone help me please?
  >> 
  >> Yes, I will help you by refusing to tell you the correct syntax to
  >> achive what you ask :-)

  SD> Wow your quite the asshole huh?

  SD> He won't tell you, so I will (besides I don't think he has the time to
  SD> take away from his realdoll from realdoll.com)

ooOO! such biting wit. i bet your code is spectacular to read too.

  SD> If I understand you correctly, eval will work:

and it will break too. will you fix his bugs later for him as well?

  SD> $variable = 3;

  SD> eval ("\@array$variable \= \("contents\"\);");

if that is a sample of your code, i think your wit is better.

and i will tell the OP that he gave you a bad answer. besides the
unneeded and broken escaping, eval for that is stupid. use a proper perl
data structure.

so you very well here. you showed little wit, even less perl skills and
advocated a bad technique for a simple problem. care to show some more
of your abilities?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 25 May 2001 10:11:22 +0200
From: perler@yahoo.com (Patrick Erler)
Subject: Re: regexp for triming domainnames
Message-Id: <Xns90AC67A6454ECfuyyehcesyrdx@62.153.159.134>

"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in news:3B0BD3EA.608FE209
@stomp.stomp.tokyo:

> Patrick Erler wrote:
> 
> 
> Rather oxymoronic email name.
> 
> (snipped)
> 
>> i have a regexp problem which is rather tricky, at least for me:
>  
>> i would like to strip from a domainname:
>  
>> www.test.com   or   foo.bar.test.com
> 
>> everything but "test".
> 
>> but i just get a smoking head her when i try to create the regexp..
> 
> 
> There is a good chance what you are smoking is contributing
> to your inability to write code for this.
thanks for your answer. please go and compare them to the answers posted by 
other people, compare them in style and prejudice from your side, and know 
why nobody in you neighbourhood realy wants to talk to you...

PAT


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

Date: 25 May 2001 06:19:12 +0200
From: Cyrille Lefevre <clefevre%no-spam@redirect.to.invalid>
Subject: Re: Search and replace text in a file based on a specific line
Message-Id: <7kz683i7.fsf@gits.dyndns.org>

"Daniel Robert" <drobert@caissepop.mb.ca> writes:

*please, answer to the bottom of messages you answer and only cite
what's needed. also, when you xpost, don't forget to put a fu2.*

> "Michael Heiming" <michael@heiming.de> wrote in message
> news:3B0D539C.932BF57A@heiming.de...
> > Daniel Robert wrote:
> > >
> > > Upon looking at it carefully, I noticed that the file does not get
> modified.
> > > The original file must containt the original lines but with the changes
> we
> > > specified.  This is where I had difficulty to start with.
> >
> > You didn't not mentioned this in your original post. Now I would use
> > awk:
> >
> > awk '{if ($0 ~ /line\ 6/) ((o=$0) &&  sub ("test\ \#..","test\
> > \#www",$0) && ($0=$0" "o))} {print $0 }' testfile > testfile2
> >
> > This is all on one line.

humm! I count two ugly lines :)

awk -v p="$1" -v s="$2" -v r="$3" '
BEGIN { s=sub("?",".") }
$0 ~ p { sub(s,r); print }
' testfile1 > testfile2

sed "/$1/s/`echo $2|sed 's/\?/./g'`/$3/" testfile1 > testfile2

ed - file << EOF
g/$1/s/`echo $2|sed 's/\?/./g'`/$3/
w
q
EOF

> This is what I meant by "replace"... which would actually do a
> search and replace in the file.

this wasn't clearly expressed, so, you've got what you asked for.

add "mv testfile2 testfile1" to the end of the above sed/awk scripts :P

Cyrille.
-- 
home: mailto:clefevre%no-spam@redirect.to.invalid    | UNIX is user-friendly;
work: mailto:Cyrille.Lefevre%no-spam@edf.fr.invalid  | it's just particular
Supprimer "%no-spam" et ".invalid" pour me repondre. | about who it chooses
Remove "%no-spam" and ".invalid" to answer me back.  | to be friends with.


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

Date: Fri, 25 May 2001 04:10:05 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: SET-UP (free)
Message-Id: <x7lmnm2how.fsf@home.sysarch.com>

>>>>> "BM" == Bob Moose <yogibearxx@bobmoose.com> writes:

  BM> Uri Guttman <uri@sysarch.com> wrote in message news:<x7itis6dyd.fsf@home.sysarch.com>...
  >> >>>>> "BM" == Bob Moose <yogibearxx@bobmoose.com> writes:
  >> 
  BM> Uri Guttman <uri@sysarch.com> wrote in message news:<x7elti6nuv.fsf@home.sysarch.com>...
  BM> Well, I'll ask again. Can somebody?
  >> >> 
  >> >> i will (for my definition of free which may not be yours. :)
  >> 
  BM> And what's your defenition of free?
  >> 
  >> not yours.
  >> 
  >> uri

  BM> WHAT IS IT

you tell me your definition first.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Fri, 25 May 2001 12:00:52 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: sounder
Message-Id: <3B0E3B64.46FDED80@bigfoot.com>

Todd Smith wrote:

> > How were you expecting to get your browser to say the noise you want?
> >
> > --
> 
> I don't know! That's why I asked.

You will need code in the browser.  Do your browser support Perl
client-side?

-- 
  Thorbjørn Ravn Andersen                "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

Date: Fri, 25 May 2001 10:26:16 +0200
From: "Hans Fredrik Nordhaug" <hansfn+news@mi.uib.no>
Subject: system() & background process
Message-Id: <9el4v8$2pm7$1@toralf.uib.no>

Hi,

I'm running perl 5.005_03 under HP-UX 10.20. I have a small perl script
that print out the text "Test" - perltest. I'm not able to run this script in the
background [system("... &"); ] even though it is in the path. Running it in
the foreground is no problem. Minimal test follows:

 > perl -e 'system("perltest")'
 > Test

 > perl -e 'system("perltest&")'
 > Can't open perl script "perltest": No such file or directory

I can't reproduce this behaviour under Linux.

Any comments anyone?

Hans

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

The script perltest contains the following:

    eval '(exit $?0)' && eval 'exec perl -w $0 ${1+"$@"}' && eval 'exec perl -w $0 $argv:q'
         if 0;
    # In stead of #!/path/to/perl -w
    print "Test\n";

The reason for starting the script with 'eval ...' in stead of '#!/path/to/perl -w'
is that the script have to run on two different platforms where perl is located
in different places.


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

Date: 25 May 2001 07:13:47 GMT
From: barryallwood@aol.com (Barry Allwood)
Subject: This Is Probably A Newbie Error
Message-Id: <20010525031347.14683.00001483@ng-cm1.aol.com>

Hey,

Im having a bit of trouble with this It keeps returning a "Premature end of
script headers error" , can someone check through the code please

Thanks,

Barry

#!/usr/bin/perl -w
use CGI;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 
@pairs = split(/&/, $buffer); 
foreach $pair (@pairs) { 
($name, $value) = split(/=/, $pair); 
$value =~ tr/+/ /; 
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $QUERY{$name} =
$value; 
} 

if ($QUERY{'CAT'} eq '') {
$file = "news.txt";
} else {
$file = "$QUERY{'CAT'}" . ".txt";
}

open(NEWS,"< $file");
$data = <NEWS>;
close(NEWS);
@lines = split(/:x:/,$data);
@lines = reverse(@lines)

#first part is if nothing is defined in the URL show all news (news.cgi)
if ($QUERY{'AID'} eq '') {
foreach $chunk (@lines) {
($AID, $BPTitle, $BPNews, $BPPosted, $BPDate, $Display) = split(/\|/,$chunk);
if ($Display eq 1) {
print "$BPTitle - $BPPosted - $BPDate\n $BPNews"
}
}
#Else, Print The Article chosen (news.cgi?CAT=News&AID=3)
} else {
foreach $chunk (@lines) {
($AID, $BPTitle, $BPNews, $BPPosted, $BPDate, $Display) = split(/\|/,$chunk);
if (($AID eq $QUERY{'AID'}) && ($Display eq '1')) {
print "$BPTitle - $BPPosted - $BPDate\n $BPNews"
}
}
}



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

Date: Fri, 25 May 2001 09:32:20 +0200
From: "Peter Søgaard" <peter.sogaard@tjgroup.com>
Subject: Re: This Is Probably A Newbie Error
Message-Id: <9el1r3$etq$1@news.inet.tele.dk>

"Barry Allwood" <barryallwood@aol.com> wrote in message
news:20010525031347.14683.00001483@ng-cm1.aol.com...
> Hey,
>
> Im having a bit of trouble with this It keeps returning a "Premature end
of
> script headers error" , can someone check through the code please
>
> Thanks,
>
> Barry
>
> #!/usr/bin/perl -w
> use CGI;
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $QUERY{$name}
=
> $value;
> }
>
> if ($QUERY{'CAT'} eq '') {
> $file = "news.txt";
> } else {
> $file = "$QUERY{'CAT'}" . ".txt";
> }
>
> open(NEWS,"< $file");
> $data = <NEWS>;
> close(NEWS);
> @lines = split(/:x:/,$data);
> @lines = reverse(@lines)

There, you lack a ; in the end of the above line

[snip]




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

Date: 25 May 2001 01:16:59 -0700
From: alain_s75@hotmail.com (Alain)
Subject: vestale.pl ascii animation
Message-Id: <329469e4.0105250016.56b597eb@posting.google.com>

Hello all,

I am looking for an ascii animation that was posted here around 94/95,
it was in the form of a simple VT file and of a self compressed 3 or 4
pages perl program.
The title of the animation was "vestale sous contraintes, exercice
ludique en courier 10", and the name of the perl program "vestale.pl".
I am the author of it and somehow I lost the files in the mess of my
disks !!!

If someone still has it, I would really be greatful if they could
forward it to me.
Thanks in advance.
alain_s75@hotmail.com


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

Date: Fri, 25 May 2001 04:23:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: wwwboard.pl - Taint and Use Strict
Message-Id: <x7d78y2h1f.fsf@home.sysarch.com>

>>>>> "S" == Scratchie  <AgitatorsBand@yahoo.com> writes:

  S> Uri Guttman <uri@sysarch.com> wrote:
  S> : someone posted he got that POS to be -w and -T clean. but he hasn't
  S> : posted it yet. and i bet it will still be a piece of shit.

  S> Gee, thanks for the vote of confidence. I'm sure lots of your code that
  S> I've never seen before sucks ass too.

you can't take a pile of manure and make it into art (unless you are in
the brooklyn museum). if you did make it into a decent program, you
probably did a complete rewrite. that is not fixing something. there is
no way you can just spend a day cleaning up a matt script to make it
pass -w, strict and -T and get something that is good quality. there are
deeper flaws in his code than just simple declaration issues. his
locking typically is flawed, he doesn't use decent data structures, the
design is not flexible, etc. i have examined many of his scripts (and
dozens of others based on his or which ripped off code and style from
his) and i would never touch them. they have to written correctly from
scratch (and maybe by scratchie).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

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


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