[17614] in Perl-Users-Digest
Perl-Users Digest, Issue: 5034 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 5 06:06:11 2000
Date: Tue, 5 Dec 2000 03:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976014308-v9-i5034@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 5 Dec 2000 Volume: 9 Number: 5034
Today's topics:
Re: 'require' without 'use lib' (Rafael Garcia-Suarez)
DBI:mySQL for windows richard_dobson@my-deja.com
dbm <Per-fredrik.Pollnow@epk.ericsson.se>
Re: dbm (Honza Pazdziora)
Re: finding content type <iltzu@sci.invalid>
Re: Help with dbm locking requested (Garry Williams)
help with my first ever perl script <nobody@nowhere.net>
help with my first ever perl script crudlam@my-deja.com
Re: help with my first ever perl script <nobody@nowhere.net>
Re: help with my first ever perl script crudlam@my-deja.com
i am i new <myplace-two@263.net>
Re: learning perl, this does not work ... why? (Helgi Briem)
Re: Random password generator <schneider@xtewa.de>
Re: references, hashes & arrays (Bernard El-Hagin)
Re: references, hashes & arrays (Ilya Zakharevich)
Re: references, hashes & arrays <iltzu@sci.invalid>
Re: references, hashes & arrays (Eric Bohlman)
Re: sockets and threads <schneider@xtewa.de>
Re: String Manipulation (Helgi Briem)
Re: unsolved: <STDIN> <schneider@xtewa.de>
Re: unsolved: <STDIN> <schneider@xtewa.de>
Your help please <katie.foster@bt.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 05 Dec 2000 08:13:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: 'require' without 'use lib'
Message-Id: <slrn92p8ul.te9.rgarciasuarez@rafael.kazibao.net>
jack.dunnigan@ec.gc.ca wrote in comp.lang.perl.misc:
> Is there anyway to 'require' a plain perl syntax file (i.e. not a *.pm)
> without changing @INC? Or alternatively, "un"use the lib after the file
> has been found and ingested?
>
> Currently I have something like:
>
> use lib '/some/wierd/directory';
> require "Some.config";
Two solutions:
The first :
require "/some/wierd/directory/Some.config";
The second:
use lib '/some/wierd/directory';
require "Some.config";
no lib '/some/wierd/directory';
See the documentation for the lib module (usually 'perldoc lib').
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
sub japh { bless [ split /(?= )/ => $_[1] ] => $_[0] }
$_ = japh main "Just another Perl hacker,\n"; print; print; print; print;
------------------------------
Date: Tue, 05 Dec 2000 10:29:58 GMT
From: richard_dobson@my-deja.com
Subject: DBI:mySQL for windows
Message-Id: <90ig32$opr$1@nnrp1.deja.com>
Hello there,
I am desparately looking for the DBi drivers for mySQL on wondows. Does
anyone know where there is one off hand? This is driving me up the wall.
I'm sure i saw one yesterday somewhere
Thanks in advance
Richard
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 5 Dec 2000 11:33:01 +0100
From: "Per- Fredrik Pollnow" <Per-fredrik.Pollnow@epk.ericsson.se>
Subject: dbm
Message-Id: <90ifn2$54f$1@newstoo.ericsson.se>
Hi,
I need help with a dbm script I'm building.. This is the function:
First I want to open the dbmfile, I did it like this.
$hello = "gunde";
dbmopen(%DBMLIST, "/etc/dbmfile", 0644);
Ok, now I want the scalar variable $hello to be written in to the
dbmfile.????
dbmclose($hello);
Ok, the other program I need to find the $hello value in the dbmfile ?????
pleas can some1 show me how to do this / thanx
------------------------------
Date: Tue, 5 Dec 2000 10:49:12 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: dbm
Message-Id: <G53Cq0.4Jx@news.muni.cz>
On Tue, 5 Dec 2000 11:33:01 +0100, Per- Fredrik Pollnow <Per-fredrik.Pollnow@epk.ericsson.se> wrote:
>
> I need help with a dbm script I'm building.. This is the function:
> First I want to open the dbmfile, I did it like this.
> $hello = "gunde";
> dbmopen(%DBMLIST, "/etc/dbmfile", 0644);
> Ok, now I want the scalar variable $hello to be written in to the
> dbmfile.????
$DBMLIST{$hello} = 1;
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: 5 Dec 2000 08:22:44 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: finding content type
Message-Id: <976004275.16488@itz.pp.sci.fi>
In article <S3BW5.6867$Nw6.23040@news.iol.ie>, EM wrote:
>i have a script to allow people to upload files to a directory where others
>can then download
>how do i find the content type of the file uploaded?
You happened to mention in another post that you're using cgi-lib.pl.
You really shouldn't be, as it has been made obsolete years ago by
CGI.pm. "perldoc CGI" includes the following:
When a file is uploaded the browser usually sends along some
information along with it in the format of headers. The
information usually includes the MIME content type. Future
browsers may send other information as well (such as
modification date and size). To retrieve this information,
call uploadInfo(). It returns a reference to an associative
array containing all the document headers.
$filename = $query->param('uploaded_file');
$type = $query->uploadInfo($filename)->{'Content-Type'};
unless ($type eq 'text/html') {
die "HTML FILES ONLY!";
}
If you are using a machine that recognizes "text" and
"binary" data modes, be sure to understand when and how to
use them (see the Camel book). Otherwise you may find that
binary files are corrupted during file uploads.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Tue, 05 Dec 2000 08:29:43 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Help with dbm locking requested
Message-Id: <XH1X5.615$Xq5.30018@eagle.america.net>
On Mon, 04 Dec 2000 22:51:40 GMT, James Kufrovich
<eggie@REMOVE_TO_REPLYsunlink.net> wrote:
> I'm having a slight problem with file locking. I'm writing a CGI
>script that has to access a dbm file ...
>... Just to test things, I ran the following script:
>---------------------------------------------------------
>#!/usr/bin/perl -w
>
>use strict;
>use SDBM_File;
>use MLDBM;
>use Fcntl qw/:flock/;
>
>my %hash1;
>my %hash2;
>
>my $handle1 = tie (%hash1, 'MLDBM', 'testdb.dat', 'O_EXLOCK', 0666)
> or die "Can't open first hash: $!\n";
>sleep 1;
>my $handle2 = tie (%hash2, 'MLDBM', 'testdb.dat', 'O_EXLOCK', 0666)
> or die "Can't open second hash: $!\n";
>
>untie %hash1;
>untie %hash2 if tied %hash2;
>------------------------------------------------------------------------
>
>hoping the second tie would cause the script to die, as the first tie
>would have locked the file , but apparently O_EXLOCK isn't defined on this
>system. LOCK_EX isn't, either. Neither are O_RWDR or O_CREAT, for that
>matter.
It may be true that those constants are not defined on your platform.
Then you would receive the error message "Your vendor has not defined
Fcntl macro %s, used at". (Well, the DB_File module supplies that
message; I don't know about SDBM_File/MLDBM. But if you ran the code
above, you would never see that because you placed quotes around the
Fcntl constants. As a matter of fact, you should have received a
warning about non-numeric values used in the tie statement. Don't do
that. :-)
use Fcntl; # Import O_* constants (DB_File does this fo you)
tie (%hash1, 'MLDBM', 'testdb.dat', O_RDWR|O_CREAT, 0666) or ...
(I don't have MLDBM installed, so I didn't try your code. I don't
know a system that defines O_EXLOCK. Where did it come from?)
On the matter of locking, I think you need to consider another
approach. Although some systems support mandatory file locking, I've
never used it, so I can't advise you. Most systems support advisory
locks, though. If you were using DB_File, its manual page discusses
safe locking for Berkeley DB files with DB_File. The principles are
the same, if you're not using DB_File:
Use a lock file to _represent_ your database. Lock it with flock()
before tie'ing the database file. Manipulate the database file.
untie() the database file. Close the lock file.
See the perlfaq5 manual page, "How can I lock a file?".
By the way, on many systems, it is not an error or a blocking
operation to obtain two exclusive locks on the same file in a single
process.
$ uname -a
SunOS ifr 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-5_10
$ cat x
#!/usr/local/bin/perl -w
use strict;
use Fcntl qw( :flock ); # Import LOCK_* constants
open(ONE, ">>lock_file") || die "lock_file: $!";
flock(ONE, LOCK_EX) || die "ONE flock: $!";
print "locked once\n";
open(TWO, ">>lock_file") || die "lock_file: $!";
flock(TWO, LOCK_EX) || die "TWO flock: $!";
print "locked twice\n";
$ perl x
locked once
locked twice
$
You may have to test by using two processes (fork()):
$ cat x
#!/usr/local/bin/perl -w
use strict;
use Fcntl qw( :flock );
open(ONE, ">>lock_file") || die "lock_file: $!";
flock(ONE, LOCK_EX) || die "ONE flock: $!";
print "locked once\n";
sleep(5), exit if fork;
print "about to lock...", time, "\n";
open(TWO, ">>lock_file") || die "lock_file: $!";
flock(TWO, LOCK_EX) || die "TWO flock: $!";
print "locked twice ...", time, "\n";
$ perl x
locked once
about to lock...976002204
locked twice ...976002209
$ rm lock_file
$
I am not sure, if flock() is portable to Windows NT.
Finally, you _may_ want to consider the Storable module along with
DB_File to serialize your Perl data structures. I believe you will
find that combination quite robust.
Hope this helps.
--
Garry Williams
------------------------------
Date: Tue, 5 Dec 2000 17:33:50 +0800
From: "alex" <nobody@nowhere.net>
Subject: help with my first ever perl script
Message-Id: <90icna$dj1$1@imsp026.netvigator.com>
i've been writing a script that retrieve the contents of a web site and
print them out ,and i've got error on match the contents and printing
content on the win98 system
use win32::internet;
$quamnet = new Win32::Internet();
#get links
$linkfile =
$quamnet ->FetchURL("http://www.quamnet.com/fcgi-bin/c/cnews.fpl?par2=2&par3
=0");
@links = ($linkfile =~ /cnews\.fpl\?par2=2&par3=3&par4=\d/g);
$i = 1;
#get contents
for (@links){
$base = 'http://www.quamnet.com/fcgi-bin/c/';
$k = $base . $_;
$content[$i] = $quamnet ->FetchURL($k);
$i = $i + 1;
}
#clear tags and print out
$foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
$foo2='<\/font><br><font class\=\'timetext\'>';
$foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
$foo4='<br><\/td><\/tr>';
foreach $i(@content) {
$i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g;
my ($title, $time, $text)=($1, $2, $3);
$text =~ s/\<br\>/\n/gi;
open (FILE , ">c:\\windows\\desktop\\temp\.txt");
print FILE "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close(FILE);
`notepad /p "c:\\windows\\desktop\\temp.txt"`;
}
and the below are the another version of code that about clear and print
matter , and i have try both version doesn't work
#clear tags and print out
$foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
$foo2='<\/font><br><font class\=\'timetext\'>';
$foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
$foo4='<br><\/td><\/tr>';
foreach $i(@content) {
($title, $time, $text) = ($i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g);
$text =~ s/\<br\>/\n/gi;
open (FILE , ">c:\\windows\\desktop\\temp.txt");
print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close (FILE);
}
the notepad way seemed to be able to print a single job instead of batch
printing , it works fine in some way like this :
open (FILE , ">c:\\windows\\desktop\\temp.txt");
print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close (FILE);
any advice would be very very apprieciated and thanx in advanced
------------------------------
Date: Tue, 05 Dec 2000 09:42:48 GMT
From: crudlam@my-deja.com
Subject: help with my first ever perl script
Message-Id: <90idan$mt4$1@nnrp1.deja.com>
i've been writing a script that retrieve the contents of a web site and
print them out ,and i've got error on match the contents and printing
content on the win98 system
use win32::internet;
$quamnet = new Win32::Internet();
#get links
$linkfile =
$quamnet ->FetchURL("http://www.quamnet.com/fcgi-bin/c/cnews.fpl?
par2=2&par3
=0");
@links = ($linkfile =~ /cnews\.fpl\?par2=2&par3=3&par4=\d/g);
$i = 1;
#get contents
for (@links){
$base = 'http://www.quamnet.com/fcgi-bin/c/';
$k = $base . $_;
$content[$i] = $quamnet ->FetchURL($k);
$i = $i + 1;
}
#clear tags and print out
$foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
$foo2='<\/font><br><font class\=\'timetext\'>';
$foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
$foo4='<br><\/td><\/tr>';
foreach $i(@content) {
$i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g;
my ($title, $time, $text)=($1, $2, $3);
$text =~ s/\<br\>/\n/gi;
open (FILE , ">c:\\windows\\desktop\\temp\.txt");
print FILE "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close(FILE);
`notepad /p "c:\\windows\\desktop\\temp.txt"`;
}
and the below are the another version of code that about clear and print
matter , and i have try both version doesn't work
#clear tags and print out
$foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
$foo2='<\/font><br><font class\=\'timetext\'>';
$foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
$foo4='<br><\/td><\/tr>';
foreach $i(@content) {
($title, $time, $text) = ($i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g);
$text =~ s/\<br\>/\n/gi;
open (FILE , ">c:\\windows\\desktop\\temp.txt");
print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close (FILE);
}
the notepad way seemed to be able to print a single job instead of batch
printing , it works fine in some way like this :
open (FILE , ">c:\\windows\\desktop\\temp.txt");
print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
close (FILE);
any advice would be very very apprieciated and thanx in advanced
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 5 Dec 2000 17:38:25 +0800
From: "alex" <nobody@nowhere.net>
Subject: Re: help with my first ever perl script
Message-Id: <90id0h$ebr$1@imsp026.netvigator.com>
and i've been trying the print out data direct out to printer pc2519 (HP
JetDirect Port) , with this :
open (PRNT ">PC2519");
while perl only create a file named PC2519 and print in the content in
it,why and how ?
"alex" <nobody@nowhere.net> ¼¶¼g©ó¶l¥ó
news:90icna$dj1$1@imsp026.netvigator.com...
> i've been writing a script that retrieve the contents of a web site and
> print them out ,and i've got error on match the contents and printing
> content on the win98 system
>
> use win32::internet;
> $quamnet = new Win32::Internet();
>
> #get links
>
> $linkfile =
>
$quamnet ->FetchURL("http://www.quamnet.com/fcgi-bin/c/cnews.fpl?par2=2&par3
> =0");
> @links = ($linkfile =~ /cnews\.fpl\?par2=2&par3=3&par4=\d/g);
> $i = 1;
>
> #get contents
>
> for (@links){
> $base = 'http://www.quamnet.com/fcgi-bin/c/';
> $k = $base . $_;
> $content[$i] = $quamnet ->FetchURL($k);
> $i = $i + 1;
> }
>
> #clear tags and print out
>
> $foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
> $foo2='<\/font><br><font class\=\'timetext\'>';
> $foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
> $foo4='<br><\/td><\/tr>';
>
> foreach $i(@content) {
> $i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g;
> my ($title, $time, $text)=($1, $2, $3);
> $text =~ s/\<br\>/\n/gi;
> open (FILE , ">c:\\windows\\desktop\\temp\.txt");
> print FILE "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close(FILE);
> `notepad /p "c:\\windows\\desktop\\temp.txt"`;
> }
>
> and the below are the another version of code that about clear and print
> matter , and i have try both version doesn't work
>
> #clear tags and print out
>
>
>
> $foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
> $foo2='<\/font><br><font class\=\'timetext\'>';
> $foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
> $foo4='<br><\/td><\/tr>';
>
> foreach $i(@content) {
> ($title, $time, $text) = ($i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g);
> $text =~ s/\<br\>/\n/gi;
> open (FILE , ">c:\\windows\\desktop\\temp.txt");
> print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close (FILE);
> }
>
>
> the notepad way seemed to be able to print a single job instead of batch
> printing , it works fine in some way like this :
>
> open (FILE , ">c:\\windows\\desktop\\temp.txt");
> print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close (FILE);
>
> any advice would be very very apprieciated and thanx in advanced
>
>
>
------------------------------
Date: Tue, 05 Dec 2000 09:45:04 GMT
From: crudlam@my-deja.com
Subject: Re: help with my first ever perl script
Message-Id: <90idev$n3q$1@nnrp1.deja.com>
In article <90idan$mt4$1@nnrp1.deja.com>,
crudlam@my-deja.com wrote:
> i've been writing a script that retrieve the contents of a web site
and
> print them out ,and i've got error on match the contents and printing
> content on the win98 system
>
> use win32::internet;
> $quamnet = new Win32::Internet();
>
> #get links
>
> $linkfile =
> $quamnet ->FetchURL("http://www.quamnet.com/fcgi-bin/c/cnews.fpl?
> par2=2&par3
> =0");
> @links = ($linkfile =~ /cnews\.fpl\?par2=2&par3=3&par4=\d/g);
> $i = 1;
>
> #get contents
>
> for (@links){
> $base = 'http://www.quamnet.com/fcgi-bin/c/';
> $k = $base . $_;
> $content[$i] = $quamnet ->FetchURL($k);
> $i = $i + 1;
> }
>
> #clear tags and print out
>
> $foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
> $foo2='<\/font><br><font class\=\'timetext\'>';
> $foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
> $foo4='<br><\/td><\/tr>';
>
> foreach $i(@content) {
> $i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g;
> my ($title, $time, $text)=($1, $2, $3);
> $text =~ s/\<br\>/\n/gi;
> open (FILE , ">c:\\windows\\desktop\\temp\.txt");
> print FILE "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close(FILE);
> `notepad /p "c:\\windows\\desktop\\temp.txt"`;
> }
>
> and the below are the another version of code that about clear and
print
> matter , and i have try both version doesn't work
>
> #clear tags and print out
>
> $foo1='<tr><td colspan\=\'2\'><font class\=\'btext\'>';
> $foo2='<\/font><br><font class\=\'timetext\'>';
> $foo3='<\/font><font class\=\'text\'><br>Quamnet News Service<p>';
> $foo4='<br><\/td><\/tr>';
>
> foreach $i(@content) {
> ($title, $time, $text) = ($i =~ /$foo1(.+)$foo2(.+)$foo3(.+)$foo4/g);
> $text =~ s/\<br\>/\n/gi;
> open (FILE , ">c:\\windows\\desktop\\temp.txt");
> print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close (FILE);
> }
>
> the notepad way seemed to be able to print a single job instead of
batch
> printing , it works fine in some way like this :
>
> open (FILE , ">c:\\windows\\desktop\\temp.txt");
> print "$title\n\n$time\n\nQuamnet News Service\n\n$text\n";
> close (FILE);
>
> any advice would be very very apprieciated and thanx in advanced
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
and i've been trying the print out data direct out to printer pc2519
(HP
JetDirect Port) , with this :
open (PRNT ">PC2519");
while perl only create a file named PC2519 and print in the content in
it,why and how ?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 5 Dec 2000 17:35:25 +0800
From: "newdonger" <myplace-two@263.net>
Subject: i am i new
Message-Id: <90ib74$a2i$1@sunlight.pku.edu.cn>
Hello everyone!
I am a new people for the world.The reason is simply,my english is poor,and
my knowledge of perl is poor,too.But i want have a best place of my in the
internet.So i am making a person website.of cause,i have lots of trouble in
doing it ,I also want get help from here!But as you know,I know little about
the rule of here.So i want get a guide to here,and want you help,thanks!
My address:myplace-two@263.net
------------------------------
Date: Tue, 05 Dec 2000 10:37:44 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: learning perl, this does not work ... why?
Message-Id: <3a2cc4d1.228422554@news.itn.is>
On Sun, 03 Dec 2000 04:23:32 +0600, "Jerry F. Davis"
<jfdecd@execpc.com> wrote:
>Hey all:
>
>I am just learning perl. I have perl 5.6.0 for i686-linux
>
You posted this three times, a good way to
ensure nobody replies. But I'm a nice guy.
>I put in the following script (from Beginning perl by Simon Cozens)
>expecting the $1 .. $5 variables to print something.
>I get the first print line, "The text matches ...", but do not get
>anything for $1 as I expected.
>
>why?
>
You need to enclose $pattern in
parentheses in order to capture $1
thus: >if (/($pattern)/) {
You also have only one pattern so
$2-$5 will always be undefined.
Regards,
Helgi Briem
------------------------------
Date: Tue, 05 Dec 2000 10:17:10 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: Random password generator
Message-Id: <90ifb2$ocq$1@nnrp1.deja.com>
> >> You do read the descriptions for the functions that you use, don't
> >you?
> >I have to admit that I don't!
> Don't say that where people can hear you, or they may do
> something about it (like ignore all of your posts).
Ok, I'll explain:
I just started programming in perl a two years ago and I learned the
whole language just from looking into scripts of others.
Of course, I used the documentation _alot_, because I didn't know what
all the functions did that I used.
When I am facing a problem, the first the first thing I do is search
the documentation. For I am not a native english-speaker, some of the
explanations are a little hard to understand (not many, but some). So
the next step is to search the internet for related topics. Most hits
are links to the documentation. :/
So that is when I start posting to a newsgroup. Actually this is when I
start looking into former messages in a newsgroup (or forum), because
this forum is the first perl-forum I ever joined and I did so only a
few days ago!!
So what I don't do is:
read the whole documentation whenever I have a problem.
What I do is:
try to find a solution on my own.
And even if I find a solution, I think it still is useful to post to a
forum, because you find people who know the language way better than I
do (like you e.g.) who can help you to create "better" code!
And you don't have to answer if you don't want to ;)
Correct me if I am wrong ... !
> Most folks here will get mad if you expect them to read the docs
> for you. Making folks mad is not a good idea.
> You shouldn't do that anymore.
s.a.
> >I thank you for the information on how to write better code.
> Hope it helped!
It certainly did. Thanks.
> I see nothing wrong with your English.
Thank you ... :)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 5 Dec 2000 08:10:56 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: references, hashes & arrays
Message-Id: <slrn92p8m8.9v.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 5 Dec 2000 02:53:23 -0500, Jody Fedor <Jodyman@usa.net> wrote:
>
>Bernard El-Hagin wrote in message ...
>
>> Try getting rid of those outermost 's like so:
>>
>>$unit{$in{'unit'}}
>>
>>and, if $in{'unit'} really is akrn you'll get the result you wanted.
>
>
>It was that problem exactly Bernard. Thanks for the help.
>
>
>Jody
>
>PS - Still don't understand why you use the ' marks when accessing a hash
>but
>not if you are using a hash of a hash i.e.
>
>%in = (
>unit => "akrn",
>month => "12",
>year => "2000",
>);
>
>%unit = (
>akrn => "Akron Ward",
>);
>
>you would use: print $unit{'akrn'} to get: Akron Ward
>if $in{'unit'} = akrn why wouldn't you use: $unit{'$in{'unit'}'} ???
Because 'unit' isn't a variable and there is no need for interpolation.
$in{'unit'}, on the other hand, has to be interpolated, because it's a
variable and you have to tell Perl whether you want to treat it as a
literal string (by using '') or as the value it stores.
Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'
------------------------------
Date: 5 Dec 2000 08:47:32 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: references, hashes & arrays
Message-Id: <90ia34$9ud$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Bernard El-Hagin
<bernard.el-hagin@lido-tech.net>],
who wrote in article <slrn92p72f.9v.bernard.el-hagin@gdndev25.lido-tech>:
> This:
>
> $unit{'$in{'unit'}'}
>
> means that you want to access the element of hash %unit which has the
> key - "a literal dollar sign, an i, an n, a literal opening curly,
> etc."
Nope. This is not that, but a syntax error. See "Gory details..."
for details.
What you wrote suites
$unit{ q[$in{'unit'}] },
which is quite a different beast.
Ilya
------------------------------
Date: 5 Dec 2000 09:38:28 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: references, hashes & arrays
Message-Id: <976007422.26149@itz.pp.sci.fi>
In article <90i6d1$qd3$1@plonk.apk.net>, Jody Fedor wrote:
>
>OK, so I'm brain dead. $unit{$in{'unit'}} worked fine. Why does it work?
>What actually does the ' ' do around the key?
They mark a string. Specifically, a literal string in which $, @ and
\ have no special meaning, unlike in strings surrounded by "". (Well,
almost. The combinations \' and \\ are special even in single quoted
strings, for reasons that should become obvious after some thinking.)
$in{'unit'} # Looks for the key 'unit' in the hash %in.
$in{"unit"} # Same as above. (No special chars in "unit".)
$in{unit} # Same as above. (Identifiers are turned into
# strings in hash lookups and before the =>
# operator, just so you wouldn't have to type the
# quotes every time.)
$unit{'$in{unit}'} # Looks for the literal key '$in{unit}' in %unit.
$unit{"$in{unit}"} # Interpolates the value of $in{unit} into a
# string, and uses that as the key to look for.
$unit{$in{unit}} # Uses the value of $in{unit} as the key to look
# for in %unit. (Hash keys are always treated as
# strings anyway, so this is the same as above.)
The last example is what you want.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: 5 Dec 2000 11:01:43 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: references, hashes & arrays
Message-Id: <90ihun$gi3$2@bob.news.rcn.net>
Bernard El-Hagin <bernard.el-hagin@lido-tech.net> wrote:
> This:
> $unit{'$in{'unit'}'}
> means that you want to access the element of hash %unit which has the
> key - "a literal dollar sign, an i, an n, a literal opening curly,
> etc." Try getting rid of those outermost 's like so:
> $unit{$in{'unit'}}
> and, if $in{'unit'} really is akrn you'll get the result you wanted.
Right solution, but wrong explanation. Single quotes inside double quotes
are treated literally; they don't suspend interpolation. In this case,
the hash key was a single quote followed by an a, a k, an r, an n, and
another single quote. The literal single quotes in the key were
preventing it from matching.
------------------------------
Date: Tue, 05 Dec 2000 10:28:28 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: sockets and threads
Message-Id: <90ig08$opb$1@nnrp1.deja.com>
> Well, if you can use non-blocking clals, or calls that have timeouts,
> that's best. If you can't, you're reasonably out of luck.
I found a solution myself:
The last thing my main-thread does before exiting is opening a
connection to that listening thread. It just sends a "NULL"-information
and so the thread finishes (and isn't spawned again, because the main-
thread is down already).
It is not a perfect way but it works for me ... :)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 10:30:53 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: String Manipulation
Message-Id: <3a2cc34c.228033364@news.itn.is>
On Sat, 2 Dec 2000 19:08:04 -0000, "James Boulter"
<jbou@bunker79.fsnet.co.uk> wrote:
>Dear all,
>
>I have the string "James <email address>"
>
>How can I get the information into two separate variables without the
>brackets.
>
>James
>
# putting both > and < in the split delimiter gets
# rid of the trailing >
my ($name,$email) = split/[<>/,$string;
Regards,
Helgi Briem
------------------------------
Date: Tue, 05 Dec 2000 10:38:04 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: unsolved: <STDIN>
Message-Id: <90igic$p8a$1@nnrp1.deja.com>
> >I would just check if there _is_ input
> Perl FAQ, part 8:
> "How do I check whether input is ready on the keyboard?"
> You inch ever closer to earning yourself a killfile entry.
> Better stop doing that quick before it gets to be too late...
Ok, even after _knowing_ what to look for, I didn't find it!
Am I just to stupid?
Please tell me where to find that faq (it obviously isn't on perl.com)
and I won't bother you anymore ...
:(
btw: I hope that there are more tolerant people out there that know
perl!!!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 05 Dec 2000 10:41:17 GMT
From: SimBean <schneider@xtewa.de>
Subject: Re: unsolved: <STDIN>
Message-Id: <90igoc$pao$1@nnrp1.deja.com>
> <STDIN> is not a filehandle. STDIN might be.
> <STDIN> is an operation to read an entire line from a filehandle.
Since
> some of the line may be present, but not an entire line, this
operation
> will block until an entire line is available.
>
> If you want non-blocking I/O, you can't use stdio stuff like this.
>
> Instead use select to see if you can read, and then sysread to get
some
> data. Do this in a loop and you shouldn't have to block.
Now this _was_ helpfull.
Thanky you, I'll see if I can get it working that way!!! :)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 5 Dec 2000 10:11:17 -0000
From: "Katie Foster" <katie.foster@bt.com>
Subject: Your help please
Message-Id: <90if3b$61i$1@pheidippides.axion.bt.co.uk>
I haven't been doing Perl very long, so I was hoping someone on here could
help me, please.
My group have upgraded from Perl 3 to Perl 5.05. Some of our scripts no
longer work, I have fixed some of them, but have come accross a problem with
one particular script.
The script is called from another scripts which sets the frames up on the
page. Two of the frames work fine, but one frame doesn't work. It
produces the error message Premature end of script headers: /name of file.
If you re-fresh the frame then it works and does not produce an error
message.
I have cheked the environment variables by printing them to the errorlog,
When I do this the script works fine. If I just print a line saying Test
into the errorlog then that also works.
Anyone any ideas on why it isn't working or how to fix it??
Thanks Katie
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5034
**************************************