[6909] in Perl-Users-Digest
Perl-Users Digest, Issue: 534 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 28 19:08:20 1997
Date: Wed, 28 May 97 16:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 28 May 1997 Volume: 8 Number: 534
Today's topics:
Assistance with using Data Files with an Array. (Diffe (Mark Bainter)
Re: Assistance with using Data Files with an Array. (D (Tim Smith)
Re: Associate This! (Tung-chiang Yang)
Re: Associate This! (Tim Smith)
Code Snippet Wanted (Jim McCullars)
Re: extracting columns (Andrew M. Langmead)
GET THIS WHILE U CAN! y5e12sty@fia.net
Re: How old is my file??? <rra@stanford.edu>
Re: How old is my file??? (Tung-chiang Yang)
Re: listing of Filenames under a directory (Tung-chiang Yang)
new() method inside other packages? (Ken Williams)
PERL Programmer's: What's It Like? <bradenb@ibm.net>
Re: print \@ slices (Ken Williams)
Re: printing 2 dimentinal Hash table <allenjs@nic.techops.lmco.com>
Problems building 5.004 & Tk402.000 on Solaris 2.5 (John A. Murphy)
Re: PURE PERL .gif creating library needed; not in @#$ (Ronald L. Parker)
Re: reading hashes from a file (Chipmunk)
Search results problem is making me crazy (A. M. Schaer)
Re: Search results problem is making me crazy (Tim Smith)
Re: Standalone web database for Perl? <guess@somewhere.com>
Re: subroutine call as lvalue (was: Re: questions about <jesse@ginger.sig.bsh.com>
Re: types <jesse@ginger.sig.bsh.com>
Re: types (Ken Williams)
Re: Using hash, appending and dbm (Chipmunk)
Re: Variables In Data Structures. (Ken Williams)
Re: Where can I get Net::FTP? (Nathan V. Patwardhan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 May 1997 21:30:54 GMT
From: mark@michiana.net (Mark Bainter)
Subject: Assistance with using Data Files with an Array. (Differences when writing back out)
Message-Id: <338c9dd1.1232414207@news.michiana.net>
I'm attempting to write a perl script to modify an alias file, so that
we don't have to give direct access to the file to various employees.
I am admittedly still learning perl, so this will likely be an easy
question. (I have the Programming perl book, but the Learning Perl
book isn't out yet. :( Otherwise, I could probably figure this one
out on my own. I just couldn't find the answer I was looking for in
the PP book.)
Please note, I'm not asking for a script to solve my problem. I'm
sure there is one already written, etc, but I'm partially doing this
for the learning experience, so all I'm looking for is the answer to
my stated questions.
I have this script so far:
#!/usr/local/bin/perl5 -Tw
#
# dialup -r <username> Remove User from alias
# dialup -a <username> Add user to alias
# dialup -v View Alias Listing
# dialup -c <username> Check if a username exists
#
#
#
#Variable Declaration:
&Fill_Array;
&Display_Array;
&Write_Array;
sub Fill_Array
{
$ALIASFILE = "/usr/acct/mark/smw/dialup.list";
open(ALIASFILE) or die "Cannot open data";
while ( $tmp = <ALIASFILE> )
{
chop($alias[scalar(@alias)]=$tmp);
}
close ALIASFILE;
}
sub Display_Array
{
for $i (0 .. scalar(@alias))
{
print "$alias[$i]\n";
}
}
sub Write_Array
{
$NEWFILE = ">/usr/acct/mark/smw/alias.new";
open(NEWFILE) or die("Unable to create file");
select NEWFILE;
for $i (0 .. scalar(@alias))
{
print $alias[$i],"\n";
}
select STDOUT;
close STDOUT;
}
The file 'dialup.list' is a text file with names in it, one to a line.
for example:
John
Doe
Charlie
Argus
When I execute this script, it echoes all the names just fine, and
then I get this:
Use of uninitialized value at dialup.pl line 32.
Use of uninitialized value at dialup.pl line 44.
Lines 33 and 45 are the print statements in Display_Array and
Write_Array. I tried defining @alias, but it didn't help. I still
get the errors. I don't get it in Fill_Array, which I'm sure is
linked to the fact I'm assigning values to the array there. However,
I'm not sure how to fix this. I tried looking up the error in the PP
book, but it wasn't much help in this case (I did try defining the
variables, it didn't work)
The second question I have is related to writing the values to the
file. It worked just fine, except that the files aren't the same
size. I ran a `cmp dialup.list alias.new` and it came back saying
that the difference was that I had an EOF in dialup.list. Any ideas
on how to duplicate this when I write the file back out. I need it to
be exactly the same.
Thanks for your time,
Mark
---
Mark A. Bainter MCP, A+
Technical Engineer mailto:mark@turnergroup.com
Turner Group WWW: http://www.turnergroup.com
2707 Middlebury St. Phone: 219-295-4290
Elkhart, IN 46516 Fax: 219-522-2964
--------------------------------------------------------------------------------------
ex abusu non arguitur in usum
(the abuse of a thing is no argument against its use)
--------------------------------------------------------------------------------------
------------------------------
Date: 28 May 1997 15:48:34 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: Assistance with using Data Files with an Array. (Differences when writing back out)
Message-Id: <5mico2$ofd@web.azstarnet.com>
- CC'd to poster -
In article <338c9dd1.1232414207@news.michiana.net>,
Mark Bainter <I.retaliate@gainst.spammers.com> wrote:
Mark,
I think your problem is in the for loop:
>sub Display_Array
>{
> for $i (0 .. scalar(@alias))
> {
> print "$alias[$i]\n";
> }
>}
scalar(@alias) is the length of the array, not the last index. You should
use $#alias instead of scalar(@alias):
for $i (0 .. $#alias)
Or, better yet, why not use a normal for loop? Like this:
for ($i = 0; $i < @alias; ++$i) {
...
}
Notice that the comparison $i < @alias automatically forces scalar context,
so you don't need the scalar() operator.
Or, better yet, why not use a normal foreach loop? Like this;
foreach (@alias) {
print "$_\n";
}
Enjoy,
Tim
------------------------------
Date: Wed, 28 May 1997 21:12:29 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Associate This!
Message-Id: <tcyangEAwtKt.6o6@netcom.com>
I am a Perl newbie, but.....
Steven T. Zydek (stzydek@rs6000.cmp.ilstu.edu) wrote:
: #!/usr/local/bin/perl -w
: $FriendsHeight("Greg") = "6 ft 7";
: $FriendsHeight("Pete") = "7 ft 1";
: $FriendsHeight("Joe") = "5 ft 3";
: $FriendsHeight("Jack") = "6 ft 7";
For associative array, do you use $FriendsHeight{"Greg"}?
: delete ($FriendsHeight("Joe");
: # Now how would I list the existing friend's height's in a way
: # that I could also count how many friend's heights I have left
: # in the array?
: # I have tried this:
: foreach (%FriendsHeight) {
: $x++;
: print "$_\n";
: }
What is $x? I guess "-w" will tell you you are using an uninitialized
variable.
You might want to use foreach $key (keys(%FriendsHeight)){} instead.
Besides, I don't think
print "$_\n";
does what you want it to do. print $FriendsHeight{$key} maybe.
: # but this adds the name of each element (i.e. Greg, Pete, Jack...)
: # as if it were a height? Is there some sort of command that simply
: # flushes out the name of the element and it's contents as ONE entry?
: # Tell me what you think!
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: 28 May 1997 15:39:43 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: Associate This!
Message-Id: <5mic7f$lbd@web.azstarnet.com>
In article <5mi43p$qgu@thor.cmp.ilstu.edu>,
Steven T. Zydek <stzydek@rs6000.cmp.ilstu.edu> wrote:
>Hello,
>
>I just wanted to know what the most efficient way to "clean" out the
>existing elements of an associative array. Here's my dilemma:
If you want to just get rid of all the elements in a hash, you can do
this:
undef %FriendsHeight;
or:
%FriendsHeight = ();
>-------------------------cut here ------------------------------------
>$FriendsHeight("Greg") = "6 ft 7";
Ouch. Try this instead:
$FriendsHeight{"Greg"} = "6 ft 7";
>$FriendsHeight("Pete") = "7 ft 1";
>$FriendsHeight("Joe") = "5 ft 3";
>$FriendsHeight("Jack") = "6 ft 7";
Or, better yet, do this to initialize a hash:
%friendsHeight = (
'Greg' => '6 ft 7',
'Pete' => '7 ft 1',
'Joe' => '5 ft 3',
'Jack' => '6 ft 7',
);
>delete ($FriendsHeight("Joe");
You're missing a ')'. And again, the syntax is wrong. Try this:
delete $FriendsHeight{'Joe'};
># Now how would I list the existing friend's height's in a way
># that I could also count how many friend's heights I have left
># in the array?
># I have tried this:
>
>foreach (%FriendsHeight) {
This puts %FriendsHeight in a LIST context, which returns a list of
(Key1, Value1, Key2, Value2). Notice that these are NOT in any (usable)
order.
> $x++;
> print "$_\n";
> }
>
># but this adds the name of each element (i.e. Greg, Pete, Jack...)
># as if it were a height?
If you don't care whose height you're listing, use values:
@heights = values %FriendsHeight;
print "There are ", scalar(@heights), " heights: @heights\n";
If you need the friend, too, then use each.
Tim
------------------------------
Date: 28 May 1997 16:48:51 -0500
From: jim@info.uah.edu (Jim McCullars)
Subject: Code Snippet Wanted
Message-Id: <5mi983$2ma$1@info.uah.edu>
Greetings!
I am in the process of cleaning up my web site, in which inline
graphical images are duplicated all over the place. I will be moving
many of the universal .gif and .jpg files to a single images directory
and am looking for a way to change the pages that reference these images
without editing each one manually (there are hundreds). What I want to do
is this:
find a line that may contain any of the following:
<img src="uah_bar.gif"> or
<img src="/uah_bar.gif"> or
<img src="../uah_bar.gif"> or
<img src="../../uah_bar.gif"> or even
<img src="http://www.uah.edu/uah_bar.gif">
and change that line so that only the part in quotes would be changed to:
/images/uah_bar.gif
So what I'm really looking for is something that will look for a
string I will provide (uah_bar.gif) and if that string is in quotes
(which I think I can assume it will be every time) change whatever is
in the quotes to just that file name pre-pended with a slash.
Thanks in advance, and I hope this sort of question isn't considered
to be in poor taste.
Jim
*-------------------------------------------------------------------------*
* James H. McCullars I Phone: (205) 890-6347 x238 *
* Director of Systems & Operations I Fax: (205) 890-6643 *
* Information Services I Internet: mccullj@email.uah.edu *
* The University of Alabama I -----------------------------------*
* in Huntsville I *
* Huntsville, AL 35899 I This space for rent - CHEAP! *
*-------------------------------------------------------------------------*
------------------------------
Date: Wed, 28 May 1997 14:12:13 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: extracting columns
Message-Id: <EAwA4D.L8n@world.std.com>
Vijay Telang <vijay.telang@citicorp.com> writes:
>Can someone give me some idea about how to cut/change a column from a
>ascii file. I extarct an ASCII file from one of my systems and need to
>change dat in specific columns, such as a date field etc.
>In shell script I would be using cut to do the job. SO what would be
>equevelent to cut.
The perl equivilent of cut would either be unpack() with the "A"
template option (for fixed fields processed with the "-c" option) or
split() (for delimited fields processed with the "-f" option.)
--
Andrew Langmead
------------------------------
Date: 28 May 1997 22:48:37 GMT
From: y5e12sty@fia.net
Subject: GET THIS WHILE U CAN!
Message-Id: <5mico5$31m@news1-alterdial.uu.net>
27 MILLION EMAIL ADDRESSES... Plus GREAT Bonuses...
EARN INSANE PROFITS WITH THE RIGHT FORMULA
If you have a product, service, or message that you would like to get
out to Thousands, Hundreds of Thousands, or even Millions of people,
you have several options. Traditional methods include print advertising,
direct mail, radio, and television advertising. They are all effective,
but they all have two catches: They're EXPENSIVE and TIME CONSUMING.
Not only that, you only get ONE SHOT at making your message heard, by
the right people.
The INTERNET, the "Global Communications Frontier" has changed
this dramatically, including making countless individuals wealthy.
"Electronic Marketing," as it's commonly referred to, has effectively
leveled the playing fields of all types businesses.
Don't even hesitate on this one or you will miss out on the most
effective way to market anywhere..PERIOD!
HERE'S THE BOTTOM LINE
AND
WHAT WE CAN DO FOR YOU
Here is what you get when you order today!
>> 27 Million Email Addresses... 1 per line in simple text format on a CD.
Multiple files of 250,000 or greater (no codes needed to open files).
You will receive email addresses of the following domains... AOL,
PRODIGY, COMPUSERVE, DELPHI, GENIE, JUNO, PIPELINE,
INTERAMP, MSN, MCI, and 5 MILLION OTHER MIXED EMAIL
ADDRESSES (.com, .net). All names listed above are seperated
in files by domain name for your convenience.
PLUS THESE SUPER BONUS SPECIALS...
>> The BEST Software for Bulk Email today... called Stealth. You'll get
a 10 day fully functioning version that sends up to 250,000 messages per
hour with a 28.8 connection. This is the HOTTEST bulk email software
available anywhere and you get 10 Full Days to use it!!!
>> Super Note Pad... This software will help manage your large text
files for you.
>> Winzip Self Extractor... This program will be needed when
de-compressing a compressed file. It will come in handy when
dealing with files of zip format.
>> Over 5,000 Places To Advertise For Free!
Plus Yet Another Bonus...
>> "Profits 2500 Series"... 7 manuals that will teach you how to market
on the internet and what offers work and which ones to stay clear of.
Also we will show you where to find web designers for free and much,
much more!
YOU GET EVERYTHING FOR ONLY $495...
***UPDATE... SAVE $200 AND ORDER WITH 10 DAYS!***
>>> NOW ONLY $295!
The seven manuals alone have sold for over $200. Now you can have the
complete package for the low price of only $295!
All lists are completely free of any Duplicates. We also on a continual
basis, add New Names and Remove Undeliverables and Remove
Requests.
The result is the Cleanest Email Addresses Available Anywhere to use over
and over again, for a FRACTION of the cost that other companies charge.
Typical rates for acquiring email lists are from 1 cent to as high as 3
cents per email address - that's "INFORMATION HIGHWAY" ROBBERY!.
Start earning mega money and get started now!
If you have any further questions call our Marketing Department at:
714-288-6225
To order our email package, simply print out the EZ ORDER FORM
below and fax or mail it to our office today.
We accept Visa, Mastercard, AMEX, Checks by Mail.
_________________
EZ Order Form
_____Yes! I would like to order your 27,000,000 email addresses
Plus all the bonuses for only $295. I understand NO REFUNDS are
possible. If the CD is damaged it will be replace FREE upon returning
the original.
*Please select one of the following for shipping..
____I would like to receive my package OVERNIGHT. I'm including
$15 for shipping.
____I would like to receive my package 2 DAY delivery. I'm including
$10 for shipping.
DATE_____________________________________________________
NAME____________________________________________________
ADDRESS_________________________________________________
CITY, STATE, ZIP__________________________________________
PHONE NUMBERS_________________________________________
FAX NUMBERS____________________________________________
EMAIL ADDRESS__________________________________________
TYPE OF CREDIT CARD:
______VISA _____MASTERCARD _____AMEX
CREDIT CARD# __________________________________________
EXPIRATION DATE________________________________________
NAME ON CARD___________________________________________
AMOUNT $____________________
(Required) SIGNATURE:x________________________
DATE:x__________________
You may fax your order to us at: 1-714-288-6233
If you feel more comfortable sending payment through the mail,
please send all forms and Cashiers Check or Money Order to:
(Company or Personal Checks allow 2-3 weeks for delivery)
Gateway Advertising
4341 E. Chapman Ave #205
Orange CA 92869
(714) 288-6225
------------------------------
Date: 28 May 1997 14:47:05 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How old is my file???
Message-Id: <m3enare0bq.fsf@windlord.Stanford.EDU>
Buzz <shommel@gnu.uvm.edu> writes:
> Hello, can anyone tell me the easiest way to have perl inform me of the
> creation date of a file?
Unix doesn't store or remember the creation date of a file, so there's no
way for Perl to tell you it.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Wed, 28 May 1997 21:40:47 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: How old is my file???
Message-Id: <tcyangEAwuw0.8Es@netcom.com>
I don't think Perl and Unix can handle that. Maybe another OS stores
the file creation date somewhere :)
If the creation date is so important, use it (or an encoded version)
as part of your filename, or, say, the first line of your file.
=============================
Buzz (shommel@gnu.uvm.edu) wrote:
: Hello, can anyone tell me the easiest way to
: have perl inform me of the creation date of a file?
: Let's say I have a file called "foo.bar" in my directory.
: How can I read the creation date into a variable?
: I tried 'stat' but that's not what I am looking for.
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Wed, 28 May 1997 21:12:23 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: listing of Filenames under a directory
Message-Id: <tcyangEAwtKn.6n7@netcom.com>
You said you would use "readdir", "opendir" but in your code you used
"open" and "close" ......
"readdir" will also read all the directory names for the handle opened
by opendir -- among them '.' and '..' should be removed before processing
the files in c:/whatever/dir/.
==============================
Cornelius Griffin (EScrubb@worldnet.att.net) wrote:
: Not sure if you really need a module for this. Would readdir() combined
: with opendir() accomplish what you are trying to do. E.g.
: untested script---imported from Camel book>>>>>>>
: open(SOMEDIR, "c:/whatever/dir/") or die("Could not open dir $!");
: @allfiles = grep /^\.ls/, readdir SOMEDIR;
: close(SOMEDIR);
: end script>>>>>>
: If it doesn't work or if it doesn't help, let me know.
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Wed, 28 May 1997 17:08:30 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: new() method inside other packages?
Message-Id: <ken-2805971708300001@news.swarthmore.edu>
Hi-
I FINALLY figured out how to write a nice small test program that
demonstrates my problem. Here it is:
> #!/usr/bin/perl
> use lib "/forum/taco/lib";
> use Field;
>
> $class_name = "Field";
>
> $field = new $class_name ("db");
This instantiation works just fine.
>
> package Other;
>
> sub new {
> my $pack = shift;
> return bless({}, $pack);
> }
>
> sub other {
> my $class_name = "Field";
> my $field;
>
> $field = new $class_name ("db");
This one generates a syntax error.
> }
>From my investigation, it looks like it's trying to compile to use the
Other::new method rather than the Field::new method - if you (the
compiler) think that's the syntax I'm (the programmer) trying to use, then
it is indeed a syntax error.
If I get rid of the Other::new method, then everything compiles fine.
In my real program (as opposed to my test program), $class_name is passed
around as a variable, so I can't just change it to $field = new
Field("db");.
I did figure out one way to get around this problem, but it's REALLY
ugly. If I change the line
$field = new $class_name ("db");
to
$field = &{$class_name . "::new"}($class_name, "db");
then it seems to work. But to me, this construction is really nasty. Can
someone out there help me come up with a better one?
Also, how do folks feel about passing the name of a class around in a
variable? Do you have other ways of achieving polymorphism that you like
better? If you do, I'm all eyes.
Thanks,
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: 28 May 97 22:09:01 GMT
From: "Jerome Bradenbaugh" <bradenb@ibm.net>
Subject: PERL Programmer's: What's It Like?
Message-Id: <01bc45f9$fec7a000$525248a6@default>
I'm considering working as a PERL programmer. Please explain what that
involves. For example, what types of programs would an employer want? In
what fields of employment do you find PERL programmers?
Please tell me anything you can about the employment aspects and
requirements.
Regards,
--
Jerry Bradenbaugh
HotSyte Webmaster
bradenb@ibm.net
The Connection to that which is JavaScript
http://www.serve.com/hotsyte
------------------------------
Date: Wed, 28 May 1997 17:51:31 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: print \@ slices
Message-Id: <ken-2805971751310001@news.swarthmore.edu>
Hi-
You can do your slice like this:
print "@{$refar}[1,2,3]\n";
That dereferences $refar explicitly as an array, then takes a slice of
that array.
In article <338905DC.4148@bender.com>, alex
<alex.t.silverstein@bender.com> wrote:
> I can't seem to find the documentation
> on how to print, say, the 0th thru 3rd
> elements of a ref to an array. This is
> as far as I got, but it only prints one
> element. Is the answer in one
> of the texts (I own a few)?
>
> #!/usr/local/gnu/bin/perl -w
> @refarrr= (130, 150, 2, 1);
> $refar = \@refarrr;
> print "$refar->[2]\n";
>
> --
> just what are people for? K.V.
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: Wed, 28 May 1997 15:41:47 -0700
From: Jay Allen <allenjs@nic.techops.lmco.com>
To: Allon Henig <ahenig@iil.intel.com>
Subject: Re: printing 2 dimentinal Hash table
Message-Id: <338CB4AB.D31@nic.techops.lmco.com>
What's your application? Do you mean an array of hashes (like rows of
a table?) or a hash of arrays (like a name referencing a list of
things). I often use the former in database applications. For example:
A table like this:
Col1 Col2 Col3 Col4 Col5
1 data data data data data
2 data data data data data
3 data data data data data
4 data data data data data
5 data data data data data
would equate to a Perl-like structure (i.e. not syntactically correct)
like this:
$Records = { 1 => Col1 => data
Col2 => data
Col3 => data
etc
2 => Col1 => data
Col2 => data
etc etc}
The snippet below shows the printing out of this data with HTML table
markup inlcuded (at least the tr(ow)s and td(ata)s...
(NOTE2: @Fieldnames contain the order in which I want the columns to
appear.)
for $i (0 .. $#Records) {
print "<tr>";
my $name = ();
foreach $name (@FieldNames) {
if ($name =~ /Description/) {
print "<td width = 450>$Records[$i]{$name}</td>"
} else {
print "<td>$Records[$i]{$name}</td>"
}
}
print "</tr>\n";
}
Hope that's what you were looking for. If not, someone can use this
snippet to better the world...
-j-
---------
Jay Allen
allenjs@nic.techops.lmco.com
ICYRA-Internet Coordinator
Lockheed-Martin - Web Page Lead
The Maxim Group - Sr. Programmer/Analyst
(w) (310) 727-1086
(h) (562) 433-7727
Allon Henig wrote:
> Hi,
> how is it possible to print each value of a 2 dimentional Hash table ?
> It Should be something like:
>
> foreach $key (keys %HashTable) {
> ...do something..
> }
>
> but this is a >>2<< dimentional HT?!
>
> Thanks, ALLon
------------------------------
Date: 28 May 1997 16:59:01 -0400
From: jam@philabs.research.philips.com (John A. Murphy)
Subject: Problems building 5.004 & Tk402.000 on Solaris 2.5
Message-Id: <5mi6al$quh@frank.philabs.research.philips.com>
I ran into a problem building perl 5.004 and Tk402.000 under Solaris 2.5.
I first built perl (with the regex patch), using very vanilla/recommended
settings (gcc 2.7.2 and gnu make), and everything went fine, it passed
all tests, and I installed it.
Then I went and got Tk, configured it, built it. Seems fine, but
when it tries to run the demo I get:
/bin/perl -I./blib/arch -I./blib/lib demos/widget
libc internal error: _rmutex_unlock: rmutex not held.
gmake: *** [test_dynamic] Abort
Now I scratched some old brain cells and I remember "Oh yeah, under
Solaris you had to compile perl with -lthread if you wanted to use Tk".
I go back and check my 5.003 settings and sure enough -lthread was added
to the libs line.
So I redo Configure and rebuild perl, but this time perl fails on
the following tests:
io/pipe...........FAILED on test 8
lib/io_pipe.......FAILED on test 10
After following the advice of the test and running harness I get:
io/pipe.............Confused test output: test 7 answered after
test 8
ok
op/magic............Confused test output: test 5 answered after
test 5
FAILED tests 3, 5
Failed 2/28 tests, 92.86% okay
lib/io_pipe.........Confused test output: test 9 answered after
test 10
FAILED tests 9-10
Failed 2/10 tests, 80.00% okay
Failed Test Status Wstat Total Fail Failed List of failed
-----------------------------------------------------------------
lib/io_pipe.t 10 2 20.00% 9-10
op/magic.t 28 2 7.14% 3, 5
Failed 2/152 test scripts, 98.68% okay. 1/4366 subtests failed,
99.98% okay.
Ok, so we continue on, first trying the individual tests
./perl io/pipe.t
1..10
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 8
ok 7
ok 9
ok 10
8 comes before 7, but seems ok. lib/io_pipe.t gives something similar:
./perl lib/io_pipe.t
1..10
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 10
ok 9
10, before 9, but doesn't seem to care. Bigger problems arise with op/magic.t:
./perl op/magic.t
1..28
ok 1
ok 2
ok 4
not ok
ok 5
ok 6
etc.
I don't have any of the LC environment variables set, but setting them
to C seems to have no effect. I tried redoing the entire perl build
from scratch while still specifying the extra -lthread lib, rebuilt
listing -lthread first instead of last, but still got the same result
each time.
The build under SunOS was uneventful and everything works fine.
I checked FAQs and READMEs but didn't find any mention of similar behavior.
Anybody else seen similar behavior under Solaris? Any ideas, tips,
or things to try? Am I doing something dumb?
Thanks,
Murf
--
John A. Murphy (better known as Erin's dad) jam@philabs.research.philips.com
345 Scarborough Road One one-trillionith of a surprise: picoboo
Briarcliff Manor, NY 10510 millihellen: The beauty needed to launch 1 ship
(914)945-6216 ** My views and opinions do not reflect those of my employer **
------------------------------
Date: Wed, 28 May 1997 21:36:33 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: PURE PERL .gif creating library needed; not in @#$ C language or external modules. PERL!
Message-Id: <338ca4d6.31750678@10.0.2.33>
On Wed, 28 May 1997 02:30:20 GMT, abigail@fnx.com (Abigail) wrote:
>I don't understand what's against using existing (C) modules.
Well, there's the little thing called "using someone else's web
server." Our Web provider doesn't provide a C compiler. I don't have
access to the same architecture anywhere else. I think an all-Perl
GIF library would be nice, too, if it could be gotten to run quickly.
Of course, I'd use it for something more useful than YAWebCounter.
--
Ron Parker
Software Engineer
Farm Works Software Come see us at http://www.farmworks.com
For PGP public key see http://www.farmworks.com/Ron_Parker_PGP_key.txt
------------------------------
Date: 28 May 1997 19:58:28 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: reading hashes from a file
Message-Id: <5mi2p4$c42$3@dartvax.dartmouth.edu>
In article <338B27E5.2677@acs.ucalgary.ca>
"Randall S. Willcox" <rswillco@acs.ucalgary.ca> writes:
> How can I assign an individual hash from "foo.txt" to %answers?
>
> I was hoping it would be something as simple as getting the correct
> hidden field value & then doing something like this:
>
> open (INFILE, "foo.txt");
>
> %01 = %answers;
I'm not sure what you mean by %01...
How you read in the hash depends on the format.
Suppose your textfile is formatted like this:
01 a
02 c
03 d
etc.
Then you could do:
open (INFILE, "foo.txt");
undef $/; # read in entire file
%answers = split(' ', <INFILE>);
That splits the input file on whitespace and assigns the resulting list
to the hash. It assumes the input file is formatted properly.
Of course, if your input file is formatted differently, you'll need a
different way of reading it in and assigning the hash.
Chipmnuk
------------------------------
Date: Wed, 28 May 1997 21:27:42 GMT
From: schaer@[204.52.135.1] (A. M. Schaer)
Subject: Search results problem is making me crazy
Message-Id: <338ca08a.14828565@news.hal-pc.org>
#!/usr/bin/perl
I am trying to get Perl to write *only* lines matching a specified
pattern to a file. What is happening when I run the script is that
*all* the lines in the input file get written to the output file. I'm
obviously missing something.
This is the script:
$infile="practice.txt";
$outfile="temp.txt";
$pattern=/marker/;
grep ($pattern, $infile > $outfile);
open (IN, "practice.txt") || die "Can't open practice.txt: $!";
@hits = grep (/$pattern/, <IN>);
close (IN) || die "Can't close infile: $!";
open (OUT, "> temp.txt") || die "Can't open outfile: $!";
print OUT @hits;
close (OUT);
This is the file I used to test it:
text with the word marker in it
Line 2
Line 3
line 4
line 5
line 6
Exactly the same text is written to temp.txt.
What I want to see in temp.txt is just the line:
text with the word marker in it
Thanks in advance.
--
A. M. Schaer
schaer@hal-pc.org
------------------------------
Date: 28 May 1997 15:23:41 -0700
From: trs@azstarnet.com (Tim Smith)
Subject: Re: Search results problem is making me crazy
Message-Id: <5mib9d$g9p@web.azstarnet.com>
In article <338ca08a.14828565@news.hal-pc.org>,
A. M. Schaer <schaer@[204.52.135.1]> wrote:
A.,
>I am trying to get Perl to write *only* lines matching a specified
>pattern to a file.
Several things stand out.
>$infile="practice.txt";
>$outfile="temp.txt";
>$pattern=/marker/;
You need to quote that pattern, don't use //. The // is for matching
patterns. It defaults to matching against the $_ variable (which is
undefined at this point in your program), and $pattern winds up being
undefined. You should use this:
$pattern = 'marker';
> grep ($pattern, $infile > $outfile);
I'm assuming that is pseudo-code, and is not really in your perl
script. You should make that obvious by putting a # in front of
it when posting code samples.
>open (IN, "practice.txt") || die "Can't open practice.txt: $!";
Why define $infile above, but not use it here? If I'm using your
code and see $infile='xxx' at the top, I expect that to be used
later on. You should write:
open (IN, "< $infile") or die "can't open < $infile: $!\n";
>@hits = grep (/$pattern/, <IN>);
Since $pattern was undefined at this point, the grep looks like this:
@hits = grep (//, <IN>); # undefined pattern interpolates to empty string
That pattern ALWAYS matches, which explains why every line was showing
up in the outfile.
>close (IN) || die "Can't close infile: $!";
>open (OUT, "> temp.txt") || die "Can't open outfile: $!";
Again, use your $outfile variable, if you're going to define it.
>print OUT @hits;
>close (OUT);
This method should work, but it is wasteful of memory (especially if your
infile is large). A more common approach to this problem is to open both
the infile and outfile at the same time, then loop through the infile one
line at a time. It would look like this:
open (IN, "< $infile") or die "can't open < $infile: $!\n";
open (OUT, "> $outfile") or close(IN), die "can't open > $outfile: $!\n";
while (<IN>) {
print OUT $_ if /$pattern/; # don't need grep, just a pattern match
}
close(OUT);
close(IN);
exit 0;
__END__
By the way, you really should be reading the new Perl book, not the
old one. Get the 2nd edition Camel, and use Perl 5. And use the
-w switch. And use 'use strict'. You'll learn a lot better, I
promise.
Enjoy,
Tim
------------------------------
Date: 28 May 1997 21:43:20 GMT
From: "Hidden" <guess@somewhere.com>
Subject: Re: Standalone web database for Perl?
Message-Id: <01bc6baf$4f066800$8ccd78cf@default>
depending on how large the Database file will be you may not even need a
Database management system. Perl can work with text files with the fields
on separate lines and the records separated with a blank line.
Name: B J'S CAFE
Address: 207 S RALEIGH ST
City: ANGIER
State: NC
Zip Code: 27501
Telephone: (919) 639-0788
Name: CORNER GRILL
Address: HIGHWAY 55 S
City: ANGIER
State: NC
Zip Code: 27501
Telephone: (919) 639-2312
Gary Weinfurther <gary@mich.com> wrote in article
<MPG.df65c741202955a989680@news.mich.com>...
> A client wants a "simple" database application developed in Perl for a
> corporate intranet. According to the client, the web server does not
> currently have a DBMS. He wants a small, low-budget database for this
> application and it does not need to interact with any other application
> on the intranet. Is there a Perl library that manages database records,
> similarly to a data management library for C or other languages? Or do
> we have to purchase a large C/S RDBMS and install it on the server?
>
> Thanks in advance!
> --
>
> ...Gary (gary@mich.com)
>
------------------------------
Date: 28 May 1997 17:01:06 -0400
From: Jesse Glick <jesse@ginger.sig.bsh.com>
Subject: Re: subroutine call as lvalue (was: Re: questions about chop)
Message-Id: <4on2pfux9p.fsf@ginger.sig.bsh.com>
> Randal Schwartz <merlyn@stonehenge.com> writes:
>
> > The Perl development team (aka, the P5P) have been looking into making
> > it possible to write user subroutines that can perform similarly.
> > Such a feature did not make it into 5.004, but perhaps 5.005 or 5.006
> > will include such capability.
Why not:
foo()="bar"
===>
${foo()}="bar"
and similarly for other ref types, according to the ref actually returned by
the routine at runtime, if any (else error). If you need some special logic
built into that, tie. E.g.:
sub my_substr {
tie my $foo, MY_SUBSTR, @_;
\$foo;
}
package MY_SUBSTR;
sub FETCH {...substr(...)...}
sub STORE {...substr(...)=...}
This would require very little extra logic in the Perl core, and it would be
simple to write modules to make things more convenient.
--
Jesse "Da Juice" Glick
mailto:jglick@sig.bsh.com
617-867-1017
------------------------------
Date: 28 May 1997 17:04:16 -0400
From: Jesse Glick <jesse@ginger.sig.bsh.com>
Subject: Re: types
Message-Id: <4olo4zux4f.fsf@ginger.sig.bsh.com>
tcyang@netcom.com (Tung-chiang Yang) writes:
> One more thing. $a = 'a' can pass the test
>
> ($a ne '') && ($a eq int($a))
>
> but $a = '0.0' cannot pass that test (the above test will say $a = 'a'
> is not an integer but $a = '0.0' is not, either).
How about:
do {local($^W)=0; no integer; $a eq 0+$a and $a==int $a}
--
Jesse "Da Juice" Glick
mailto:jglick@sig.bsh.com
617-867-1017
------------------------------
Date: Wed, 28 May 1997 17:44:50 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: types
Message-Id: <ken-2805971744500001@news.swarthmore.edu>
This problem can be solved by just using
print "it's an integer\n" if $foo eq int($foo);
.
In article <comdog-ya02408000R2505972047450001@nntp.netcruiser>,
comdog@computerdog.com (brian d foy) wrote:
> In article <Pine.GSO.3.96.970525160635.24194J-100000@kelly.teleport.com>,
> Tom Phoenix <rootbeer@teleport.com> wrote:
>
> > On Fri, 23 May 1997, Pierre Merle wrote:
> >
> > > How to know if what's returned from a from is an integer
> > > or not ?
> >
> > Mostly, this will do it.
> >
> > print "it's an integer" if $foo == int($foo);
>
> hmmmm.....
>
> #!/usr/bin/perl
>
> @foo = qw(1 x dog . *);
>
> foreach $foo (@foo)
> {
> print "it's an integer\n" if $foo == int($foo);
> }
>
> __END__
> it's an integer
> it's an integer
> it's an integer
> it's an integer
> it's an integer
>
>
> a non-number used in an number context evaluates to 0, so
> we end up with 0 == 0 if $foo is not a number, which is true...
>
> --
> brian d foy
<URL:http://computerdog.com>
>
> unsolicited commercial email is not appreciated
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: 28 May 1997 19:59:57 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Using hash, appending and dbm
Message-Id: <5mi2rt$c42$4@dartvax.dartmouth.edu>
In article <5mfr84$cok$1@news10.gte.net>
jbharvey@gte.net (Justin B. Harvey) writes:
> $hash{$ip} = $var;
>
> But it reports this:
>
> ndbm store returned -1, errno 28, key "199.180.3.29" at roto
> line 17, <DETAIL> chunk 118.
>
> When I run it...so what am I doing wrong?
I think you need to find out what errno 28 means.
Chipmunk
------------------------------
Date: Wed, 28 May 1997 17:37:03 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: Variables In Data Structures.
Message-Id: <ken-2805971737030001@news.swarthmore.edu>
The following will do what you want:
$dom{Var1} = "bar";
$dom{Var2} = "foo $dom{Var1}";
print "$dom{Var1}\n"; #case 1
print "$dom{Var2}\n"; #case 2
In order to understand it, you need to look at your code from the
compiler's point of view:
Code:
%dom = (
"Var1" => "bar",
"Var2" => "foo $dom{Var1}"
);
Compiler:
Looks like I'm going to be creating a hash from a list. I'd better figure
out what's in the list, and then once I'm done with that I'll assign the
whole thing to a hash.
If you parse the list first, then you'll get this:
("Var1" => "bar", "Var2" => "foo $dom{Var1}") # => acts like a comma
("Var1", "bar", "Var2", "foo $dom{Var1}") # do variable interpolation
("Var1", "bar", "Var2", "foo ") # $dom{Var1} was undefined
Now all elements in the list are just flat strings, so it can be assigned
to the hash.
Make sense?
In article <5lur6b$sb9@snews5.zippo.com>, dharma@msys.net (Ron Picker) wrote:
> I'm attempting to use variables, without success, in data structures
> as demonstrated in the following trivial test case.
>
> #!/usr/bin/perl
> %dom = (
> "Var1" => "bar",
> "Var2" => "foo $dom{Var1}"
> );
>
> print "$dom{Var1}\n"; #case 1
> print "$dom{Var2}\n"; #case 2
>
> I expected to have "foo bar" printed for print case 2 but only get
> foo.
>
> Please provide suggestions.
>
> Thank you.
>
>
> Ron Picker
> DharmaSystems
> dharma@msys.net
> Druid Hollow
> French Creek, WV.
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: 28 May 1997 20:46:01 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Where can I get Net::FTP?
Message-Id: <5mi5i9$6qd@fridge-nf0.shore.net>
Robert Chapman (robc@no_spam!_igs.net) wrote:
: I have checked enterprise.ic.gc.ca/pub/perl/CPAN/modules/by-module/Net and I
: did not find it.
Ahh, it has been so clearly packaged as part of libnet*.tar.gz, which
should be found in the same directory. ;-)
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 534
*************************************