[22589] in Perl-Users-Digest
Perl-Users Digest, Issue: 4810 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 3 11:06:51 2003
Date: Thu, 3 Apr 2003 08: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)
Perl-Users Digest Thu, 3 Apr 2003 Volume: 10 Number: 4810
Today's topics:
[Net::Pop3] get error message <jgw78@hotmail.com>
Re: [Net::Pop3] get error message <tony_curtis32@yahoo.com>
Re: [Net::Pop3] get error message <jgw78@hotmail.com>
Re: ActivePerl FTP Performence (Helgi Briem)
Algorithm Suggestion (Ed Napier)
comments within complex structures (qanda)
Re: comments within complex structures <nobull@mail.com>
Re: comments within complex structures (Anno Siegel)
Re: comments within complex structures <usenet@NOSPAM.matthewb.org>
Re: comments within complex structures <perl-dvd@darklaser.com>
Re: cpan <Ian@junk.net>
Re: Dialup using Perl <graham.drabble@lineone.net>
Re: File more recent than 7 days ? <dont@want.spam>
Re: File more recent than 7 days ? <Jodyman@hotmail.com>
Re: Help me with a Perl Script <D'oh@a.deer>
Re: Help me with a Perl Script <congers@yoeric.com>
Re: how can i get a list of documents from perldoc? <john-s@moving-picture.com>
Re: Loading STDOUT into a variable <sbour@niaid.nih.gov>
Re: looking for duplicates (C Marshall)
Net::Ping problem with sol 5.8 <thens@nospam.com>
Perl error after upgrade <paul@noret-pksings.net>
Re: Perl One-Liner <barryk2@SPAM-KILLER.mts.net>
perl problem <paul@noret-pksings.net>
Re: Problem building perl on WinXP. Help! <crusader@bestweb.net>
Re: Problem building perl on WinXP. Help! <kalinabears@hdc.com.au>
Re: Simple Filehandle Seek prob <D'oh@a.deer>
Re: Text::ParseWords <Use-Author-Supplied-Address-Header@[127.1]>
Win32::Sound::Volume() setting balance <ian@WINDOZEdigiserv.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 03 Apr 2003 17:37:30 +0200
From: Gert <jgw78@hotmail.com>
Subject: [Net::Pop3] get error message
Message-Id: <b6hkh3$hbs$1@news>
Group,
I've written a little script, to check the number of messages and size
of the mbox on a pop3 server.
I'm using Net::Pop3 for this.
Works like a charm. My only problem is that when an error occurs, for
example '[ERR IN USE]' or something, I can't get the text of the
errormessage that is returned by the server.
Like -ERR [IN-USE] /var/spool/maildrop_tmp/.name.pop lock busy!
Am I missing something here?
Many thanks,
Gert van der Weyde
------------------------------
Date: Thu, 03 Apr 2003 09:46:53 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: [Net::Pop3] get error message
Message-Id: <877kab60sy.fsf@limey.hpcc.uh.edu>
>> On Thu, 03 Apr 2003 17:37:30 +0200,
>> Gert <jgw78@hotmail.com> said:
> Group, I've written a little script, to check the number
> of messages and size of the mbox on a pop3 server. I'm
> using Net::Pop3 for this. Works like a charm. My only
> problem is that when an error occurs, for example '[ERR
> IN USE]' or something, I can't get the text of the
> errormessage that is returned by the server.
Net::POP3 is a sub-class of Net::Cmd. So Net::Cmd's
methods for accessing return codes/text are available
through your Net::POP3 object, e.g. code() or message().
hth
t
------------------------------
Date: Thu, 03 Apr 2003 17:53:01 +0200
From: Gert <jgw78@hotmail.com>
Subject: Re: [Net::Pop3] get error message
Message-Id: <b6hle6$ht6$1@news>
Tony Curtis wrote:
>>>On Thu, 03 Apr 2003 17:37:30 +0200,
>>>Gert <jgw78@hotmail.com> said:
>>
>
>>Group, I've written a little script, to check the number
>>of messages and size of the mbox on a pop3 server. I'm
>>using Net::Pop3 for this. Works like a charm. My only
>>problem is that when an error occurs, for example '[ERR
>>IN USE]' or something, I can't get the text of the
>>errormessage that is returned by the server.
>
>
> Net::POP3 is a sub-class of Net::Cmd. So Net::Cmd's
> methods for accessing return codes/text are available
> through your Net::POP3 object, e.g. code() or message().
>
> hth
> t
Thanks!
------------------------------
Date: Thu, 03 Apr 2003 11:20:41 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: ActivePerl FTP Performence
Message-Id: <3e8c1844.455417856@news.cis.dfn.de>
On Thu, 3 Apr 2003 12:36:14 +0300, "Arik"
<arikg@zoran.co.il> wrote:
>My problem is that the transfare rate of using FTP and
>ActivePerl is match slower than using standard win2k's
>ftp application.
>
>For the same file I got about 4Sec using ActivePerl and
>0.7 Sec using win2k's FTP.
So what?
There is probably no difference in transfer rate as both
use the same underlying protocol.
The difference is probably in the overhead of starting
up a Perl process. Try downloading a much bigger file.
I'll bet you'll see much less difference.
Perl is a scripting language. If speed is so important
that a difference of 3.3 seconds matters, Perl is
probably not the right tool.
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: 3 Apr 2003 07:02:27 -0800
From: p1edn01@netscape.net (Ed Napier)
Subject: Algorithm Suggestion
Message-Id: <bb040849.0304030702.2e5b4d36@posting.google.com>
I'm looking for suggestions on a fast algorithm to do the following:
I have a list (thousands) of computers and IP addresses (10.10.10.20)
and flat file with thousands of entries relating to subnets and
gateways. The format is:
First.3.Octets,lower range, upper range, gatewayname
which ends up looking something like this:
172.18.121,0,15,gateway1
172.18.121,16,30,gateway2
172.18.121,31,100,gateway3
What I need to do is find the gateway that corresponds to each
computer. Now, I can come up with BFI algorithm to do it, but I was
hoping that someone out there has a suggestion that borders on magic.
Thanks,
Ed
------------------------------
Date: 3 Apr 2003 04:04:33 -0800
From: fumail@freeuk.com (qanda)
Subject: comments within complex structures
Message-Id: <62b4710f.0304030404.53a9d533@posting.google.com>
Hi all, can you tell me if there is any way to include comments
directly inside complex structures. The following is an example of
what I would like, however Perl would not like this ...
my %complex_set1 = ( # Complex set 1.
fld_set1 => { # Field set 1.
fs1_fld1, # fs1 field 1.
fs1_fld2, # fs1 field 2.
},
fld_set2 => { # Field set 2.
fs2_fld1, # fs2 field 1.
fs2_fld2, # fs2 field 2.
},
);
(followed by other complex sets)
The objective is to write comments on each line that defines a
structure and/or field.
I know I could initialise each field, eg
field_n => '', # comment line here
but that seems long winded. Would it work as expected if I quoted
keys, eg
"field_n", # comment
Thanks.
------------------------------
Date: 03 Apr 2003 13:18:49 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: comments within complex structures
Message-Id: <u97kabpydy.fsf@wcl-l.bham.ac.uk>
fumail@freeuk.com (qanda) writes:
> Hi all, can you tell me if there is any way to include comments
> directly inside complex structures.
You can put comments anywhere exept inside quoting constructs. (You
can also put them inside //x quoted regex).
> The following is an example of
> what I would like, however Perl would not like this ...
[ snip syntactically valid Perl ]
Why do you think Perl would not like it?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 3 Apr 2003 12:59:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: comments within complex structures
Message-Id: <b6hb75$i7n$1@mamenchi.zrz.TU-Berlin.DE>
qanda <fumail@freeuk.com> wrote in comp.lang.perl.misc:
> Hi all, can you tell me if there is any way to include comments
> directly inside complex structures. The following is an example of
> what I would like, however Perl would not like this ...
>
> my %complex_set1 = ( # Complex set 1.
> fld_set1 => { # Field set 1.
> fs1_fld1, # fs1 field 1.
> fs1_fld2, # fs1 field 2.
> },
> fld_set2 => { # Field set 2.
> fs2_fld1, # fs2 field 1.
> fs2_fld2, # fs2 field 2.
> },
> );
> (followed by other complex sets)
>
>
> The objective is to write comments on each line that defines a
> structure and/or field.
The comments are fine, your problem are the barewords "fs1_fld1"
etc. The hashrefs you use are constructed wrong, you need a pair
of a key and a value for each entry. The usual construct looks like
fs1_fld1 => 1234, # comment
etc. Then the auto-quoting property of "=>" takes care of the barewords.
Anno
------------------------------
Date: Thu, 03 Apr 2003 14:14:35 +0100
From: Matthew Browning <usenet@NOSPAM.matthewb.org>
Subject: Re: comments within complex structures
Message-Id: <pan.2003.04.03.14.14.33.434827.1388@NOSPAM.matthewb.org>
On Thu, 03 Apr 2003 13:59:17 +0100, Anno Siegel wrote:
> qanda <fumail@freeuk.com> wrote in comp.lang.perl.misc:
>> Hi all, can you tell me if there is any way to include comments
>> directly inside complex structures. The following is an example of
>> what I would like, however Perl would not like this ...
>>
>> my %complex_set1 = ( # Complex set 1.
>> fld_set1 => { # Field set 1.
>> fs1_fld1, # fs1 field 1. fs1_fld2,
>> # fs1 field 2.
>> },
>> fld_set2 => { # Field set 2.
>> fs2_fld1, # fs2 field 1. fs2_fld2,
>> # fs2 field 2.
>> },
>> );
>> (followed by other complex sets)
>>
>>
>> The objective is to write comments on each line that defines a
>> structure and/or field.
>
> The comments are fine, your problem are the barewords "fs1_fld1" etc.
> The hashrefs you use are constructed wrong, you need a pair of a key and
> a value for each entry. The usual construct looks like
>
> fs1_fld1 => 1234, # comment
>
> etc. Then the auto-quoting property of "=>" takes care of the
> barewords.
>
...on the left hand side. You would have to quote the right if you want
to treat it as a string.
The way I read the OP, the error there is that he is trying to make an
anonymous array but using curly braces like a hash, in which case a
correction would look like:
my %complex_set1 = (
fld_set1 => [
'fs1_fld1', # these
'fs1_fld2' # comments
],
fld_set2 => [
'fs2_fld1', # are
'fs2_fld2' # fine
]
);
[MB]
------------------------------
Date: Thu, 03 Apr 2003 14:41:52 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: comments within complex structures
Message-Id: <QKXia.36$NY5.13995@news-west.eli.net>
"qanda" <fumail@freeuk.com> wrote in message
news:62b4710f.0304030404.53a9d533@posting.google.com...
> Hi all, can you tell me if there is any way to include comments
> directly inside complex structures. The following is an example of
> what I would like, however Perl would not like this ...
>
> my %complex_set1 = ( # Complex set 1.
> fld_set1 => { # Field set 1.
> fs1_fld1, # fs1 field 1.
> fs1_fld2, # fs1 field 2.
> },
> fld_set2 => { # Field set 2.
> fs2_fld1, # fs2 field 1.
> fs2_fld2, # fs2 field 2.
> },
> );
This hash definition works just fine on my linux machine.
> The objective is to write comments on each line that defines a
> structure and/or field.
Seems that the above does just what you were looking to do.
Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'
------------------------------
Date: Thu, 3 Apr 2003 09:00:36 -0500
From: "Ian" <Ian@junk.net>
Subject: Re: cpan
Message-Id: <z6Xia.5440$k21.649548@news20.bellglobal.com>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b6gugb$9lb$1@mamenchi.zrz.TU-Berlin.DE...
> Ian <Ian@junk.net> wrote in comp.lang.perl.misc:
> > Hi,
> > I'm very new to this. I'm configuring cpan with "o conf init" and
I'm
> > getting asked some questions that I find awkward to answer.
> > What do you guys use for unzip? Gzip I have and winzip is not command
line.
>
> If it shows a default, accept the default.
>
> > for FTP proxy?
> > for http proxy?
> > for no proxy ???
>
> If you don't have proxies, use the defaults.
>
> > for a nearby continent?
>
> The continent you're on.
>
> > Also what's a good url to give it? www.cpan.org may not be what you all
> > use.
>
> If you answer the "continent" question, it will give you a list of
> servers to select from.
It did not accept America canada quebec or anything else I typed
============================================
>
> Anno
> --
> --
>
> sub nmax { @$_[ @_] = (); $#$_ }
------------------------------
Date: Thu, 03 Apr 2003 13:49:31 +0100
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Dialup using Perl
Message-Id: <Xns93528CA352619grahamdrabblelineone@ID-77355.user.dfncis.de>
On 03 Apr 2003 Vlad Tepes <minceme@start.no> wrote in
news:b6guvv$qqd$1@troll.powertech.no:
> * Graham Drabble:
>
>> What I need is a way to get perl to check whether a connection
>> exists and, if it doesn't, dial up and supply the username and
>> password for the ISP. I've had a look in the FAQs but can't find
>> anything. If it helps I'm using Win 2000.
>
> Check out the command-line utility rasdial for options.
Brilliant thanks. I hadn't thought of even looking for command promts.
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Thu, 03 Apr 2003 14:35:41 +0100
From: Chris Lowth <dont@want.spam>
Subject: Re: File more recent than 7 days ?
Message-Id: <ZOWia.712$mt3.99435@newsfep2-gui.server.ntli.net>
Michael Budash wrote:
> In article <v8nfbed3dkqhfe@corp.supernews.com>,
> "Michael Hill" <hillmw@charter.net> wrote:
>
>> I have a need to determine if my file is less than 7 days old. Below I
>> find the date on the file, but don't really know how to see it it is less
>> tahn 7 days from today.
>>
>> Anyone done this before?
>>
>> use POSIX 'strftime';
>> use File::stat;
>> my $selected = "/home/usr/file.cgi";
>> my $st = stat($selected) or die "Can't stat($selected): $!\n";
>> my $modstr = strftime('%b %d %Y', localtime($st->mtime));
>>
>> #here i need to determine it its less than 7 days.
>>
>> Mike
>>
>>
>
> i usually use:
>
> if (-M $thefile > 7) {
> # $thefile is older than 7 days
> }
>
> hth-
>
"-M" gives the file age at the time the script started. If this doesnt work
for you (ie, the script runs long-term as a daemon or some such), then
try..
[not tested]
my @st = stat($filename);
if ( (time() - $st[9]) > (7*24*60*60) ) {
print "File is 7 or more days old\n";
}
Chris
--
Real address: chris at lowth dot sea oh em.
For free GPL e-mail virus blockade ...
http://protector.sourceforge.net
------------------------------
Date: Thu, 03 Apr 2003 16:03:03 GMT
From: "Jodyman" <Jodyman@hotmail.com>
Subject: Re: File more recent than 7 days ?
Message-Id: <XWYia.7146$4P1.559587@newsread2.prod.itd.earthlink.net>
"Michael Hill" <hillmw@charter.net> wrote in message
> I have a need to determine if my file is less than 7 days old. Below I
find
> the date on the file, but don't really know how to see it it is less tahn
7
> days from today.
I use this all the time, it might help you.
#!c:/perl/bin/perl.exe
use warnings;
use diagnostics;
use Date::Calc qw(Add_Delta_Days);
my ($mo, $day, $yr, $new_year, $new_month, $new_day, $delta_days, $today,
$previous);
$mo =
("01","02","03","04","05","06","07","08","09","10","11","12")[(localtime)[4]
];
$day = (qw\00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21
22 23 24 25 26 27 28 29 30 31\)[(localtime)[3]];
$yr = substr(localtime,22,4);
$delta_days = -7;
($new_year, $new_month, $new_day) = Add_Delta_Days($yr, $mo, $day,
$delta_days);
$_ = sprintf "%02d", $_ for $new_month, $new_day, $new_year; # Normalize 2
digit
#$today = "$mo-$day-$yr"; # WIN98
#$previous = "$new_month-$new_day-$new_year"; # WIN98
$today = "$mo/$day/$yr"; # WINNT
$previous = "$new_month/$new_day/$new_year"; # WINNT
print "Today is: $today, Seven Days ago was: $previous\n";
PS - If anyone knows a more elegant way of doing the above, feel free to rip
it up
and show me a faster/better way.
Jody
------------------------------
Date: Thu, 03 Apr 2003 21:50:54 +1000
From: D'oh <D'oh@a.deer>
Subject: Re: Help me with a Perl Script
Message-Id: <3E8C201E.303A6714@a.deer>
"Susan G. Conger" wrote:
>
> i have been trying to figure out how to create a simple Perl script that
> has a list of files that it opens and add the following line at the top
> of the file:#if !defined (MAC_COMPILE) and an #endif as then last line
> in the file. The file list should be hard codded at the top of the
> script. Something like fileList=xyz.cpp,xyz2.cpp and then a for loop
> would read the string variable and do the operation on the file.
Hope this helps. It's not the most efficient, but it works...
#!/bin/perl
use warnings;
use strict;
my @file_list = qw(xyz.cpp xyz2.cpp); ## List of files
my $i; ## Loop counter
my $first = "#if !defined (MAC_COMPILE)\n"; ## First line
my $last = "#endif\n"; ## Last line
my @file; ## Array file will be
read into
my $file_lines; ## Number of lines in
the open file
## Loop trough the list of files
##
for (my $i=0; $i<scalar(@file_list); $i++) {
##
## Open file and save into array
##
open(INFILE, "< $file_list[$i]") or die("INFILE $file_list[$i]: $!");
@file = <INFILE>;
close(INFILE);
##
## Modify first and last emements of array
## Then save the array back into the same file
##
$file_lines = scalar(@file);
$file[0] = "${first}$file[0]";
$file[$file_lines] = "$file[$file_lines]${last}";
open(OUTFILE, "> $file_list[$i]") or die("OUTFILE $file_list[$i]:
$!");
print(OUTFILE @file);
close(OUTFILE);
}
------------------------------
Date: Thu, 03 Apr 2003 09:15:54 -0500
From: "Susan G. Conger" <congers@yoeric.com>
Subject: Re: Help me with a Perl Script
Message-Id: <congers-3DD9E4.09155303042003@news.uswest.net>
Thank you so much. I appreciate your help!
Susan
In article <3E8C201E.303A6714@a.deer>, D'oh <D'oh@a.deer> wrote:
> "Susan G. Conger" wrote:
> >
> > i have been trying to figure out how to create a simple Perl script that
> > has a list of files that it opens and add the following line at the top
> > of the file:#if !defined (MAC_COMPILE) and an #endif as then last line
> > in the file. The file list should be hard codded at the top of the
> > script. Something like fileList=xyz.cpp,xyz2.cpp and then a for loop
> > would read the string variable and do the operation on the file.
>
> Hope this helps. It's not the most efficient, but it works...
>
> #!/bin/perl
> use warnings;
> use strict;
>
> my @file_list = qw(xyz.cpp xyz2.cpp); ## List of files
> my $i; ## Loop counter
> my $first = "#if !defined (MAC_COMPILE)\n"; ## First line
> my $last = "#endif\n"; ## Last line
> my @file; ## Array file will be
> read into
> my $file_lines; ## Number of lines in
> the open file
>
>
> ## Loop trough the list of files
> ##
> for (my $i=0; $i<scalar(@file_list); $i++) {
> ##
> ## Open file and save into array
> ##
> open(INFILE, "< $file_list[$i]") or die("INFILE $file_list[$i]: $!");
> @file = <INFILE>;
> close(INFILE);
>
>
> ##
> ## Modify first and last emements of array
> ## Then save the array back into the same file
> ##
> $file_lines = scalar(@file);
> $file[0] = "${first}$file[0]";
> $file[$file_lines] = "$file[$file_lines]${last}";
> open(OUTFILE, "> $file_list[$i]") or die("OUTFILE $file_list[$i]:
> $!");
> print(OUTFILE @file);
> close(OUTFILE);
> }
--
============================================================
Susan G. Conger Custom Windows & Macintosh Development
President Web Site Design & Development
YOERIC Corporation Database Design & Development
256 Windy Ridge Road
Chapel Hill, NC 27517
Phone/Fax: (919)542-0071
email: congers@yoeric.com Web: www.yoeric.com
------------------------------
Date: Thu, 3 Apr 2003 13:00:49 +0100
From: John Strauss <john-s@moving-picture.com>
Subject: Re: how can i get a list of documents from perldoc?
Message-Id: <20030403130049.3179b31b.john-s@moving-picture.com>
On 2 Apr 2003 17:51:01 GMT
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote:
>
> Also sprach John Strauss:
>
> > how does one get a list of documents from perldoc?
> >
> > if i know the name of one of the documents, say,
> > perlfunc, i can run "perldoc -l perlfunc", and look
> > for other .pod files in perlfunc.pod's parent directory.
> > but that solution requires someone new to perl to know
> > the name of a document, etc.
>
> Simply try
>
> perldoc perl
>
> and you'll get a list of all available manpages along with a few words
> on what they are about.
>
> Tassilo
> --
>
thanks (to both repliers)!
at the risk of unneccessarily prolonging the thread, it would be nice if "perldoc -h" or "perldoc perldoc" or "man perldoc" or simply "perldoc" tells the user about "perldoc perl", or even better, incorporates the list of available manpages into its default output. as it stands, you must already know the name of a document to find out what documents it can display. that's odd.
no need to reply to this, really-- i've got what i needed.
i'm far from being new to perl, but i've not gotten the most out of perldoc, pretty much because i didn't know how to get the list of docs. it's not suprising (to me) that a true newbie would be asking obvious in this newsgroup... i'm sure *some* of them would not be asked if perldoc gave them a bit more by default.
------------------------------
Date: Thu, 03 Apr 2003 08:55:50 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Loading STDOUT into a variable
Message-Id: <BAB1A796.6DE8%sbour@niaid.nih.gov>
in article slrnb8nhij.278.tadmc@magna.augustmail.com, Tad McClellan at
tadmc@augustmail.com wrote on 4/3/03 00:27:
> Stephan Bour <sbour@niaid.nih.gov> wrote:
>> in article slrnb8k0hv.3tn.tadmc@magna.augustmail.com, Tad McClellan at
>> tadmc@augustmail.com wrote on 4/1/03 16:18:
>>> Stephan Bour <sbour@niaid.nih.gov> wrote:
>>>> in article slrnb8i0a4.27c.tadmc@magna.augustmail.com, Tad McClellan at
>>>> tadmc@augustmail.com wrote on 3/31/03 22:02:
>>>>
>>>>> Stephan Bour <sbour@niaid.nih.gov> wrote:
>>>>>
>>>>>> system("ifconfig");
>>>>>
>>>>>> there any way to assign the content of STDOUT to a variable
>>>>>
>>>>> perldoc -f system
>>>>>
>>>>> *plonk*
>
>
>>> Are you saying that you did not know how to look up Perl functions?
>>>
>>
>> I do consider telling me about perldoc help, so thanks.
>
>
> You're welcome. If you didn't know that, then there are likely to
> be other helpful tidbits in the Posting Guidelines:
>
> http://mail.augustmail.com/~tadmc/clpmisc.shtml
>
>
>> I didn't know about
>> that resource and I'm glad it was pointed out to me. In my struggle to learn
>> my first programming language I mostly rely on books
>
>
> Books are a third level resource.
>
> First is the documentation that came with the software you are using.
>
> Second is a Google groups search.
>
>
>> but sometimes even the
>> simplest explanations in those beginner books are unclear to me because I
>> have no programming experience.
>
>
> The usual Perl tutorial book recommendation for non-programmers is:
>
> "Elements of Programming with Perl" by Andrew Johnson
>
> Is that one of the books you have?
Snip... I have: Learning Perl (O'Reilly), Perl A Beginner's Guide (Osborne),
Perl 5 Pocket Reference (O'Reilly), Programming Perl (O'Reilly) and Perl
Cookbook (O'Reilly). I guess I need one more...
Thanks.
------------------------------
Date: 3 Apr 2003 06:07:45 -0800
From: c_j_marshall@hotmail.com (C Marshall)
Subject: Re: looking for duplicates
Message-Id: <cb9c7b76.0304030607.de473a3@posting.google.com>
"Bill Smith" <wksmith@optonline.net> wrote in message news:<txNia.1940
>
> use strict;
> use warnings;
> my %prev;
> foreach (<DATA>){
> print if exists $prev{$_} and /^\d+/ and !/^#/;
> $prev{$_} = 1;
> }
That also outputs every occurrence of the duplicates
this:
foreach (<DATA>){
print if $prev{$_}++ == 1 and /^\d+/ and !/^#/;
}
outputs just one of each.
Chris
------------------------------
Date: Thu, 3 Apr 2003 17:28:53 +0530
From: Thens <thens@nospam.com>
Subject: Net::Ping problem with sol 5.8
Message-Id: <20030403172853.6415f488.thens@nospam.com>
All,
Iam using the following module Net::Ping from CPAN. Iam getting the
following error when i run my script in sol 5.8. It works fine in 5.7.
Has anyone faced this issue before. Iam using version 2.02 of the
module.
Died at /usr/local/lib/5.00503/Net/Ping.pm line 308
(line no : 308 $SIG{'ALRM'} = sub { die } )
Module : Net/Ping.pm (version 2.02)
Thanks in advance,
Thens.
------------------------------
Date: Thu, 03 Apr 2003 14:39:00 GMT
From: "paul" <paul@noret-pksings.net>
Subject: Perl error after upgrade
Message-Id: <pan.2003.04.03.14.27.34.875603@noret-pksings.net>
Perl problem.
I just upgraded to Mandrake 9.1. Because of previous Perl issues I had
removed all of the Mandrake Perl packages, and downloaded perl from CPAN.
Not wanting to go through this again I just let Mandrake install Perl.
Now it doesn't run. The following error message even though the Tk::Jpeg
package is installed.
./xvocp.pl
Tk::JPEG object version 800.023 does not match $Tk::JPEG::XS_VERSION 800.024 at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 249.
Compilation failed in require at ./xvocp.pl line 95.
BEGIN failed--compilation aborted at ./xvocp.pl line 95.
Does this mean that the program is looking for an older library or version
that it's not finding?
And how does one go about fixing such a thing?
Thanks in advance everyone.
paul
------------------------------
Date: Thu, 3 Apr 2003 08:25:23 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Perl One-Liner
Message-Id: <MPG.18f60053c82447a498977c@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <0d7006ef08f711192bcda067ac3274b9@news.teranews.com>, Buck
Turgidson (jc_va@hotmail.com) says...
> I found a perl one-liner to print the os block size on Unix. How can I tell
> what is the range of the other subscripts, and their meaning?
>
>
>
> perl -e '$a=(stat ".")[11]; print $a'
You can get information on the "stat" function by using the perldoc
command as follows :
perldoc -f stat
In perl, by default, subscripts start at zero.
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Thu, 03 Apr 2003 15:12:22 GMT
From: "paul" <paul@noret-pksings.net>
Subject: perl problem
Message-Id: <pan.2003.04.03.15.00.43.333250@noret-pksings.net>
Perl problem.
I just upgraded to Mandrake 9.1. Because of previous Perl issues I had
removed all of the Mandrake Perl packages, and downloaded perl from CPAN.
Not wanting to go through this again I just let Mandrake install Perl.
Now it doesn't run. The following error message even though the Tk::Jpeg
package is installed.
./xvocp.pl
Tk::JPEG object version 800.023 does not match $Tk::JPEG::XS_VERSION 800.024 at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 249.
Compilation failed in require at ./xvocp.pl line 95.
BEGIN failed--compilation aborted at ./xvocp.pl line 95.
Does this mean that the program is looking for an older library or version
that it's not finding?
And how does one go about fixing such a thing?
Thanks in advance everyone.
paul
------------------------------
Date: Thu, 03 Apr 2003 12:19:21 -0000
From: Bill <crusader@bestweb.net>
Subject: Re: Problem building perl on WinXP. Help!
Message-Id: <Xns93524A7C847DDcrusaderbestwebnet@216.168.3.50>
"Sisyphus" <kalinabears@hdc.com.au> wrote in
news:3e8a4c22$0$17497@echo-01.iinet.net.au:
>
> "Bill" <crusader@bestweb.net> wrote in message
> news:Xns9350C874DC6B2crusaderbestwebnet@216.168.3.50...
>> I am new to the concept of building sources. I am trying to build
>> perl 5.8.0 in Windows XP with the Mingw32 GCC version 2.95.2 and
>> dmake-4.1pl1- win32 as told in the perl readme.win32. I followed all
>> of the directions. The only thing I was really stuck on was how to
>> get the ENVIRONMENT VARIABLES in the config.mk in dmake configured
>> for Ming32 GCC.
>
> You should not edit that file. All the required configuring is
> achieved by editing 'makefile.mk' in the Win32 folder. Then cd to that
> folder and run 'dmake' ...... or does one have to run 'dmake
> makefile.mk' ..... I can't remember, though I *think* it's the first
> of those two.
>
> <snip>
>> 'cl' is not recognized as an internal or external command,
>> operable program or batch file.
>> dmake.exe: Error code 1, while making 'perlglob.obj'
>>
>
> It thinks you're using the msvc compiler. (This is one of the things
> taken care of in the 'makefile.mk' configuration.)
>
> You might also need to edit the 'non-configurable' section of
> 'makefile.mk'. In some notes I have regarding the building of 5.6.1
> with gcc (on Win2k, btw) I find:
> ---------------------------------------------------
> "changed line ~ 422 from:
> OPTIMIZE = -g -O2
> LINK_DBG =
>
> to:
> OPTIMIZE = -O2
> LINK_DBG =
>
> Otherwise you get a very big perl.exe and perl56.dll."
> ---------------------------------------------------------
>
> I can't remember whether the same advice applied also to 5.8.
> I could send you a copy of the makefile.mk I used (and those notes) if
> you think it would help. Just let me know.
>
> For source code, it's a good idea to get the latest ActiveState source
> from their website as it incorporates the latest patches.
>
> gcc-built perl is nice, though slightly bigger and marginally slower
> than that built by the mega-bucks msvc++ compilers.
> Stick with it :-)
>
> Cheers,
> Rob
>
>
>
Ok, I have downloaded the latest active perl source and edited that
makefile.mk and my build has gotten further but I still get an error. At
least it found the compiler. Can anyone tell me if theres a problem with
win32.h:313 , I guess thats line 313. The output is below. Help is
appreciated.
Thanks
Bill
------------------------------
Date: Thu, 3 Apr 2003 23:46:14 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: Problem building perl on WinXP. Help!
Message-Id: <3e8c3c1b$0$18820@echo-01.iinet.net.au>
"Bill" <crusader@bestweb.net> wrote in message
news:Xns93524A7C847DDcrusaderbestwebnet@216.168.3.50...
<snip>
> Can anyone tell me if theres a problem with
> win32.h:313 , I guess thats line 313. The output is below. Help is
> appreciated.
>
You forgot to provide that output :-)
Cheers,
Rob
------------------------------
Date: Thu, 03 Apr 2003 22:47:35 +1000
From: D'oh <D'oh@a.deer>
Subject: Re: Simple Filehandle Seek prob
Message-Id: <3E8C2D67.374FA68E@a.deer>
> open (MESSAGE, ">> $file" )|| die "Can't open file: $!";
> seek MESSAGE, 0, 0;
> print MESSAGE "$input\n\n";
> close MESSAGE;
>
> The problem is that $input is added at the END of the file rather than the
> beginning as is the intetion. Does anyone know what I'm doing wrong as I
> don't understand.
I'm a newbe here, but I don't believe you can append to the begining of
a file.
I've checked the perldoc perlfaq5 but my little brain couldn't
understand it.
So here's what I'd do...
#!/bin/perl
use warnings;
use strict;
my @wholefile;
my $file = "message.log";
my $input = "The quick brown fox ain't so quick after all.\nNow is he?";
open(MESSAGE, "< $file") or die("MESSAGE: Can't open file for reading:
$!");
@wholefile = <MESSAGE>;
close(MESSAGE);
open(MESSAGE, "> $file") or die("MESSAGE: Can't open file for writing:
$!");
$wholefile[0] = "$input\n\n$wholefile[0]";
print(MESSAGE @wholefile);
close(MESSAGE);
Bit of a mess, however, if $file isn't very large, the program works
fine.
Alternatively, I would..
open(MESSAGE, "> $tempfile");
print(MESSAGE "$input\n\n");
close(MESSAGE);
system("cat $file >> $tempfile");
system("mv $temfile $file");
------------------------------
Date: Thu, 3 Apr 2003 07:00:46 -0800
From: Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
Subject: Re: Text::ParseWords
Message-Id: <200304031500.h33F0kmu003300@www.aarg.net>
In article <3E8B9266.5020205@rochester.rr.com>
Bob Walton <bwalton@rochester.rr.com> wrote:
>
>
> Robert Brooks wrote:
>
> > In the following script, &shellwords returns an array
> > of three elements. I would like to know what the first
> > element is, that is element number 0.
> >
> > Can you tell me how to print out the element in question?
>
>
> Sure:
>
> use Data::Dumper;
> ...
> print Dumper(\@words);
>
> Doing that, you will discover that @words[0] is empty. You could also
> discover this handily if you call your program like:
>
> perl -d progname.pl
>
> and use the Perl debugger.
>
>
> > Or, could you supply some code that would print the character
> > out in hexadecimal or binary?
>
>
> What character? If there was one or more, you could try:
>
> print sprintf '%02X ',ord $_ for split //,$words[0];
>
> or:
>
> print sprintf '%08b ',ord $_ for split //,$words[0];
>
> ...
> --
> Bob Walton
Thanks for your help, and the free code, too!
I dismissed out-of-hand, and refused to believe,
that anyone would write a parser that returns
an empty value. Another example of TMTOWTDI
where one of the ways is oh, say, non-obvious.
------------------------------
Date: Thu, 03 Apr 2003 15:51:48 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Win32::Sound::Volume() setting balance
Message-Id: <2ulo8vk05sa5tu55vnhan03u1npbkrnstq@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
A'noon all =)
Eventually getting around to it, I knocked up a small test script for
using the Win32::Sound module as suggested by someone here when I
enquired before. The script is as follows:
#!d:\perl\bin\perl
use strict;
use warnings;
use Win32::Sound;
Win32::Sound::Volume(0xFFFF, 0xFFFF);
Win32::Sound::Play("C:\\WINNT\\Media\\notify.wav");
#Win32::Sound::Volume(0);
Win32::Sound::Stop();
This demo works, but it seems to set the balance to 100% left after
playing the sound. I added the (commented out) line to set the volume
to 0 after and this appears to leave the balance set centrally, but
obviously sets the volume to 0 too.
Has anyone else encountered this issue and/or knows a way around it?
It's fine that the script auto sets the volume to max when playing,
ut I can't leave the "default" volume set at zero for everything else
after it's been triggered.
TIA.
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPoxYkWfqtj251CDhEQKHTQCfQZO/PyuWLZYmd0GC/6cjW54xptkAnR2B
2QruzJQzZlx2iWgzYzAEhM07
=wLAp
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
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 4810
***************************************