[25356] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7601 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 4 06:05:57 2005

Date: Tue, 4 Jan 2005 03:05:19 -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           Tue, 4 Jan 2005     Volume: 10 Number: 7601

Today's topics:
        AWLP turns your PC into web-managed wireless access gat (Alp)
        calling a .dll <dontmewithme@got.it>
    Re: calling a .dll (Anno Siegel)
    Re: calling a .dll <kalinaubears@iinet.net.au>
    Re: calling a .dll <dontmewithme@got.it>
    Re: calling a .dll <dontmewithme@got.it>
    Re: Curses and getch problem <bik.mido@tiscalinet.it>
    Re: Curses and getch problem spambox@volja.net
    Re: FAQ 1.4: What are perl4 and perl5? <ebohlman@omsdev.com>
    Re: how to get perl catching a device (mic) ? <martind@algonet.se>
    Re: how to get perl catching a device (mic) ? <dontmewithme@got.it>
        LWP::Simple getstore not working inside of hash :( <HodgeBrad@gmail.com>
    Re: Newbie Question <jurgenex@hotmail.com>
        Newbie question: "Get substring of line" <mikael.petterson@ericsson.se>
    Re: Newbie question: "Get substring of line" <uri@stemsystems.com>
    Re: Newbie question: "Get substring of line" <mikael.petterson@ericsson.se>
    Re: Newbie question: "Get substring of line" <spamtrap@dot-app.org>
    Re: Newbie question: "Get substring of line" (Anno Siegel)
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: Program optimisation advice for newbie <wolf_gore@yahoo.com.au>
    Re: Program optimisation advice for newbie <someone@example.com>
    Re: Why does this work? <abigail@abigail.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 4 Jan 2005 02:51:27 -0800
From: acakircali@yahoo.com (Alp)
Subject: AWLP turns your PC into web-managed wireless access gateway
Message-Id: <d55ab063.0501040251.65d7b830@posting.google.com>

Greetings. I would like to inform you about an open-source project
I developed in Perl, using Slackware distro, HostAP driver and utilities,
that turns your PC with Prism2/2.5/3 wireless LAN card into a
full-featured web-managed wireless access gateway.

   AWLP has pretty much all the features you would expect from
an off-the-shelf wireless access gateway like DHCP server,
caching-only DNS server, ACL, etc.

   I belive AWLP is useful for a wide range of users:
- Academicians can use it for wireless experiment setups
- Developers can add/change its features
- Home users can set it up for their broadband connection sharing needs
- Small caffes and restaruants can use it as a simple hotspot box

   I have tried to be loyal to Slackware distro as much as I can.
Actually, the only major modification was to set couple of suid
and guid permission bits so that AWLP can be web-managed.
Staying loyal to Slackware pays-off when time comes for package
upgrades. You can easily add/upgrade/remove packages using standard
Slackware package tools (installpkg, upgradepkg, removepkg).

Project's Web Site:
http://awlp.sourceforge.net/

Screenshosts:
https://sourceforge.net/project/screenshots.php?group_id=127028

Photos of an example setup:
(Worked as the wireless access gateway for 12-days without a problem)
http://awlp.sourceforge.net/photos/metu-ie/index.html

   I hope you can find the time to review this open-source project
sometime. If you don't, however, I will be happy to know that you are
aware of it.


   Best Regards,

   Alptekin Cakircali
   alptekin@cakircali.com
   http://www.cakircali.com/alptekin


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

Date: Tue, 04 Jan 2005 08:05:46 GMT
From: Larry <dontmewithme@got.it>
Subject: calling a .dll
Message-Id: <dontmewithme-14057F.09054104012005@twister1.tin.it>

How can I do this in Perl:

Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal 
uDeviceID As Long, lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, 
ByVal dwInstance As Long, ByVal dwFlags As Long) As Long

thanks..


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

Date: 4 Jan 2005 08:28:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: calling a .dll
Message-Id: <crdk3q$qtl$1@mamenchi.zrz.TU-Berlin.DE>

Larry  <dontmewithme@got.it> wrote in comp.lang.perl.misc:
> How can I do this in Perl:
> 
> Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal 
> uDeviceID As Long, lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, 
> ByVal dwInstance As Long, ByVal dwFlags As Long) As Long

Your question makes no sense.  You can't take a snippet of one
language and translate it to another.

Anno


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

Date: Tue, 04 Jan 2005 08:10:01 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: calling a .dll
Message-Id: <41da5ed5$0$31846$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

Larry wrote:
> How can I do this in Perl:
> 
> Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal 
> uDeviceID As Long, lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, 
> ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
> 

Here's 2 ways you can get access to Win32 dll functions from perl:
1) Access the function using the Win32::API module. (That's the most 
common way.)

2) Wrap the function using XS or the Inline::C module. For this you'll 
need a C compiler.

Cheers,
Rob

-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: Tue, 04 Jan 2005 09:33:07 GMT
From: Larry <dontmewithme@got.it>
Subject: Re: calling a .dll
Message-Id: <dontmewithme-80E17D.10330204012005@twister1.tin.it>

In article <crdk3q$qtl$1@mamenchi.zrz.TU-Berlin.DE>,
 anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> Larry  <dontmewithme@got.it> wrote in comp.lang.perl.misc:
> > How can I do this in Perl:
> > 
> > Declare Function waveInOpen Lib "winmm.dll" (lphWaveIn As Long, ByVal 
> > uDeviceID As Long, lpFormat As WAVEFORMATEX, ByVal dwCallback As Long, 
> > ByVal dwInstance As Long, ByVal dwFlags As Long) As Long
> 
> Your question makes no sense.  You can't take a snippet of one
> language and translate it to another.
> 
> Anno

my fault. sorry, it was very silly of me.

my aim is get perl to load and use winmm.dll .. that's it

thanks


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

Date: Tue, 04 Jan 2005 09:34:16 GMT
From: Larry <dontmewithme@got.it>
Subject: Re: calling a .dll
Message-Id: <dontmewithme-96C7EC.10341104012005@twister1.tin.it>

In article 
<41da5ed5$0$31846$5a62ac22@per-qv1-newsreader-01.iinet.net.au>,
 Sisyphus <kalinaubears@iinet.net.au> wrote:

> 1) Access the function using the Win32::API module. (That's the most 
> common way.)


ok thanks


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

Date: Tue, 04 Jan 2005 11:03:48 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Curses and getch problem
Message-Id: <c1mkt0dd0j3ieefbgang40vkcfed31pk9v@4ax.com>

On 3 Jan 2005 09:05:34 -0800, spambox@volja.net wrote:

>1 while <>;
[snip]
>If you run it like "script.pl < somefile", pressing 'q' doesn't do
>anything, whereas if you run it like "script.pl somefile", it works as
>expected.

^D (or ^Z).

Nothing actually to do with Curses, BTW.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 4 Jan 2005 02:44:59 -0800
From: spambox@volja.net
Subject: Re: Curses and getch problem
Message-Id: <1104835499.419703.138750@c13g2000cwb.googlegroups.com>

Michele Dondi wrote:
> ^D (or ^Z).
>
> Nothing actually to do with Curses, BTW.

Please elaborate; I fail to see what solution you were proposing.
Thanks,

andrej



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

Date: 4 Jan 2005 06:36:11 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: FAQ 1.4: What are perl4 and perl5?
Message-Id: <Xns95D47575A0A9ebohlmanomsdevcom@130.133.1.4>

PerlFAQ Server <comdog@panix.com> wrote in
news:crbts5$2bt$1@reader1.panix.com: 

> 1.4: What are perl4 and perl5?
> 
>     Perl4 and perl5 are informal names for different versions of the
>     Perl programming language. It's easier to say "perl5" than it is
>     to say "the 5(.004) release of Perl", but some people have
>     interpreted this to mean there's a language called "perl5", which
>     isn't the case. Perl5 is merely the popular name for the fifth
>     major release (October 1994), while perl4 was the fourth major
>     release (March 1991). There was also a perl1 (in January 1988), a
>     perl2 (June 1988), and a perl3 (October 1989). 

[snip rest]

Does this still belong in the FAQ as of 2005?  The only reason I can think 
of is poorly-written books with "Perl 5" in the title (are any of them 
still in print?).


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

Date: 4 Jan 2005 08:48:26 GMT
From: Martin D <martind@algonet.se>
Subject: Re: how to get perl catching a device (mic) ?
Message-Id: <crdl8q$r4s$1@yggdrasil.glocalnet.net>

In article <dontmewithme-79ABF4.12135703012005@twister2.tin.it>,
Larry  <dontmewithme@got.it> wrote:
>In article <crb6p5$qqk$1@yggdrasil.glocalnet.net>,
> Martin D <martind@algonet.se> wrote:
>> 
>> if your're on something unixish Lincoln D. Stein's tpj article "An
>> IP Telephone in 74 Lines of Perl" may be of some help to you.
[...]
>How is it that nobody hacked any code for win? I'll give it a shot 
>anyway.

Well, you didn't say that you were using windows, did you?

check out libwin32:
<http://search.cpan.org/~gsar/libwin32-0.191/>

it contains modules for alot of Windowsy stuff. Sound too, if it will
help you I don't know...

cpan is you friend.

Ma'as salaama,
Martin
-- 
"... Consciousness, for instance, is infinitely superior to twice two makes 
four."    -- Dostojevskij in "Notes from Underground"


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

Date: Tue, 04 Jan 2005 09:29:16 GMT
From: Larry <dontmewithme@got.it>
Subject: Re: how to get perl catching a device (mic) ?
Message-Id: <dontmewithme-B6816A.10291104012005@twister1.tin.it>

In article <crdl8q$r4s$1@yggdrasil.glocalnet.net>,
 Martin D <martind@algonet.se> wrote:


> 
> check out libwin32:
> <http://search.cpan.org/~gsar/libwin32-0.191/>
> 
I just checked Win32::Sound but doesn't deal with waveIn

thanks all the same


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

Date: 3 Jan 2005 21:13:58 -0800
From: "Perl Mon" <HodgeBrad@gmail.com>
Subject: LWP::Simple getstore not working inside of hash :(
Message-Id: <1104815638.885588.164290@f14g2000cwb.googlegroups.com>

I have a question.  I am a perl newbie, but I like it a lot so far.  I
can get this little Perl file to work as a stand alone perl program:

#!/usr/bin/perl
use strict;
use warnings;
use LWP::Simple;

my $TINI_IP = 'http://192.168.1.6';

my $TiniWeather_LocalHTML_location = 'C:/Program
Files/SlimServer/server/TiniWeatherLocalHTML.txt';

LWP::Simple::getstore($TINI_IP,$TiniWeather_LocalHTML_location) or die
"Copy failed: $!";

But, if I try and insert that code under the my functions hash below in
another program, I can't get it to work.  I have worked about 8 hours
on this (incuding reading tons off of the Internet).  I was wondering
if anyone had any ideas.  Any help would be greatly appreciated.

I have the same use statment in the program that this snippet comes
from as above.

************ start code snippet here *********************

my %functions = (
'left' => sub {
Slim::Buttons::Common::popModeRight(shift);
},
'up' => sub {
my $client = shift;

$context{$client} = Slim::Buttons::Common::scroll(
$client,
-1,
$#weather_list + 1,
$context{$client} || 0,
);
$client->update();
},
'down' => sub {
my $client = shift;

$context{$client} = Slim::Buttons::Common::scroll(
$client,
1,
$#weather_list + 1,
$context{$client} || 0,
);
$client->update();
},
'numberScroll' => sub  {
my ($client,undef,$digit) = @_;

$context{$client} = Slim::Buttons::Common::numberScroll(
$client,
$digit,
\@weather_list,
1,
sub { $weather_list[shift]->[0] },
);
$client->update();
},
'add' => sub {
#
#	refresh the weather data list from the text file
#
#	note that the [add] key is labeled as [rec] on the Sony remotes
#
my @field;
my $client = shift;

Slim::Display::Animation::showBriefly(
$client,
getDisplayName() . ' ' . string('PLUGIN_WEATHER_DATA_UPDATING'),
);


my $TINI_IP = 'http://192.168.1.6';
my $TiniWeather_LocalHTML_location = 'C:/Program
Files/SlimServer/server/TiniWeatherLocalHTML.txt';

getstore($TINI_IP,$TiniWeather_LocalHTML_location) or die "Copy
failed: $!";

open (INPUT, "$TiniWeather_LocalHTML_location") || die "cannot open
file";
# opens the file to read, with the filehandle "INPUT"
# Whenever we write "INPUT" in the program it will look at the file
we're pointing to here.

open (OUTPUT, ">$weather_data_location") || die "cannot open file";
# opens the file to write with the filehandle "OUTPUT"
# The single ">" character before the filename means it's open for
writing

while (<INPUT>) {
# executes what's in the curly brackets on each line of "INPUT"
# until it reaches the end of the file

s/<br>/ /g;
s/ <font size="4"><center>Current Weather Conditions |<html>//g;
s/<TD>|<\/TD>|<td>|<\/td>|<\/tr>|<tr>|<th>|<\/th>|&#176|\t|\n//g;
unshift @field, $_;
# breaks up the file into lines
# assigns the lines to the array "field"
# strips out some of the HTML formatting stuff
}

@field = reverse @field;

select OUTPUT;

print "Local Temperature       Today's High   Today's Low | $field[29]
$field[30]            $field[31]\n";
print "Wind Speed & Direction  Today's High  Today's Peak | $field[46]
$field[47]       $field[48]\n";
print "Humididy                Dewpoint                   | $field[63]
$field[80]\n";
print "Barometric Pressure     Trend                      | $field[97]
$field[100]\n";
print "Rainfall YTD | $field[114]\n";
print "Data is updated every 10 minutes.  Last updated: | $field[10]";

select STDOUT;

close INPUT;
close OUTPUT;
# close the two files that were used

read_textfile();
},
);

********************* End code snippet here ********************
Thanks :)



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

Date: Tue, 04 Jan 2005 06:41:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newbie Question
Message-Id: <nUqCd.15395$hc7.3250@trnddc06>

John D. Sanders wrote:
> I have an Apache Web Server running and I want to use Perl as my CGI
> language.
>
> I have Matt's FormMail script running

Very bad idea!
Please see the gazillions of postings about tha topic for details and what 
to do instead.

> properly but when I try to
> implement my own scripts I get an error.

[...]

> Internal Server Error

Did you check the FAQ? Please read "perldoc -q 500", it addresses your very 
error message.

[...]
> More information about this error may be available in the server
> error log.
> Please any help would be appreciated.

Well, did you check the server error log as suggested in the error message?
What does it say?

jue 




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

Date: Tue, 04 Jan 2005 09:09:43 +0100
From: Petterson Mikael <mikael.petterson@ericsson.se>
Subject: Newbie question: "Get substring of line"
Message-Id: <crdioe$e84$1@newstree.wise.edt.ericsson.se>

Hi,

I am quite new to perl ( but have written numerous shell scripts). I had 
a shell script that used awk to get part of a string on a line.

Lines looks like this:

xdt=a2a
zdt=b2b
 ....

Is there a simple way in perl to assign a $str the substring after the 
equal sign?

//Mikael


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

Date: Tue, 04 Jan 2005 08:32:37 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <x73bxh1tnf.fsf@mail.sysarch.com>

>>>>> "PM" == Petterson Mikael <mikael.petterson@ericsson.se> writes:

  PM> xdt=a2a
  PM> zdt=b2b
  PM> ....

  PM> Is there a simple way in perl to assign a $str the substring after the
  PM> equal sign?

no, perl is useless to handle complex string parsing like that. it can
only be done by java or lisp so learn those instead.

have you read ANY documentation or a basic perl book yet? this is beyond
easy and can be done too many ways to count.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 04 Jan 2005 09:44:20 +0100
From: Petterson Mikael <mikael.petterson@ericsson.se>
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <crdkpa$f91$1@newstree.wise.edt.ericsson.se>

Uri Guttman wrote:
>>>>>>"PM" == Petterson Mikael <mikael.petterson@ericsson.se> writes:
> 
> 
>   PM> xdt=a2a
>   PM> zdt=b2b
>   PM> ....
> 
>   PM> Is there a simple way in perl to assign a $str the substring after the
>   PM> equal sign?
> 
> no, perl is useless to handle complex string parsing like that. it can
> only be done by java or lisp so learn those instead.
> 
> have you read ANY documentation or a basic perl book yet? this is beyond
> easy and can be done too many ways to count.
> 
> uri
> 
Hi,

I was looking for some help and not rude answers. I know my java but I 
am writing perl ;-)

Do you have an example of how to do this?

//Mikael


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

Date: Tue, 04 Jan 2005 04:24:04 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <bd2dncPqF_co_UfcRVn-vg@adelphia.com>

Petterson Mikael wrote:

> Hi,
> 
> I am quite new to perl ( but have written numerous shell scripts). I had 
> a shell script that used awk to get part of a string on a line.
> 
> Lines looks like this:
> 
> xdt=a2a
> zdt=b2b
> ....
> 
> Is there a simple way in perl to assign a $str the substring after the 
> equal sign?

Have you seen the posting guidelines that appear here frequently?

Perl comes with *lots* of documentation. Start with "man perl" and "man 
perlfaq". <http://learn.perl.org> has lots of links to online tutorials 
and dead trees to help you get started too.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: 4 Jan 2005 10:25:24 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Newbie question: "Get substring of line"
Message-Id: <crdquk$1ep$1@mamenchi.zrz.TU-Berlin.DE>

Petterson Mikael  <mikael.petterson@nospam.se> wrote in comp.lang.perl.misc:
> Uri Guttman wrote:
> >>>>>>"PM" == Petterson Mikael <mikael.petterson@ericsson.se> writes:
> > 
> > 
> >   PM> xdt=a2a
> >   PM> zdt=b2b
> >   PM> ....
> > 
> >   PM> Is there a simple way in perl to assign a $str the substring after the
> >   PM> equal sign?
> > 
> > no, perl is useless to handle complex string parsing like that. it can
> > only be done by java or lisp so learn those instead.
> > 
> > have you read ANY documentation or a basic perl book yet? this is beyond
> > easy and can be done too many ways to count.
> > 
> > uri
> > 
> Hi,
> 
> I was looking for some help and not rude answers.

You don't always get what you're asking for.

>                                                    I know my java but I 
> am writing perl ;-)

No, you're not.  You are asking other people to write Perl for you.

> Do you have an example of how to do this?

Show an attempt of your own, then we can talk.

Anno


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

Date: 04 Jan 2005 08:22:14 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <41da5235$0$2959$8b463f8a@news.nationwide.net>

Outline
   Before posting to comp.lang.perl.misc
      Must
       - Check the Perl Frequently Asked Questions (FAQ)
       - Check the other standard Perl docs (*.pod)
      Really Really Should
       - Lurk for a while before posting
       - Search a Usenet archive
      If You Like
       - Check Other Resources
   Posting to comp.lang.perl.misc
      Is there a better place to ask your question?
       - Question should be about Perl, not about the application area
      How to participate (post) in the clpmisc community
       - Carefully choose the contents of your Subject header
       - Use an effective followup style
       - Speak Perl rather than English, when possible
       - Ask perl to help you
       - Do not re-type Perl code
       - Provide enough information
       - Do not provide too much information
       - Do not post binaries, HTML, or MIME
      Social faux pas to avoid
       - Asking a Frequently Asked Question
       - Asking a question easily answered by a cursory doc search
       - Asking for emailed answers
       - Beware of saying "doesn't work"
       - Sending a "stealth" Cc copy
      Be extra cautious when you get upset
       - Count to ten before composing a followup when you are upset
       - Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------

Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
    This newsgroup, commonly called clpmisc, is a technical newsgroup
    intended to be used for discussion of Perl related issues (except job
    postings), whether it be comments or questions.

    As you would expect, clpmisc discussions are usually very technical in
    nature and there are conventions for conduct in technical newsgroups
    going somewhat beyond those in non-technical newsgroups.

    The article at:

        http://www.catb.org/~esr/faqs/smart-questions.html

    describes how to get answers from technical people in general.

    This article describes things that you should, and should not, do to
    increase your chances of getting an answer to your Perl question. It is
    available in POD, HTML and plain text formats at:

     http://mail.augustmail.com/~tadmc/clpmisc.shtml

    For more information about netiquette in general, see the "Netiquette
    Guidelines" at:

     http://andrew2.andrew.cmu.edu/rfc/rfc1855.html

    A note to newsgroup "regulars":

       Do not use these guidelines as a "license to flame" or other
       meanness. It is possible that a poster is unaware of things
       discussed here.  Give them the benefit of the doubt, and just
       help them learn how to post, rather than assume 

    A note about technical terms used here:

       In this document, we use words like "must" and "should" as
       they're used in technical conversation (such as you will
       encounter in this newsgroup). When we say that you *must* do
       something, we mean that if you don't do that something, then
       it's unlikely that you will benefit much from this group.
       We're not bossing you around; we're making the point without
       lots of words.

    Do *NOT* send email to the maintainer of these guidelines. It will be
    discarded unread. The guidelines belong to the newsgroup so all
    discussion should appear in the newsgroup. I am just the secretary that
    writes down the consensus of the group.

Before posting to comp.lang.perl.misc
  Must
    This section describes things that you *must* do before posting to
    clpmisc, in order to maximize your chances of getting meaningful replies
    to your inquiry and to avoid getting flamed for being lazy and trying to
    have others do your work.

    The perl distribution includes documentation that is copied to your hard
    drive when you install perl. Also installed is a program for looking
    things up in that (and other) documentation named 'perldoc'.

    You should either find out where the docs got installed on your system,
    or use perldoc to find them for you. Type "perldoc perldoc" to learn how
    to use perldoc itself. Type "perldoc perl" to start reading Perl's
    standard documentation.

    Check the Perl Frequently Asked Questions (FAQ)
        Checking the FAQ before posting is required in Big 8 newsgroups in
        general, there is nothing clpmisc-specific about this requirement.
        You are expected to do this in nearly all newsgroups.

        You can use the "-q" switch with perldoc to do a word search of the
        questions in the Perl FAQs.

    Check the other standard Perl docs (*.pod)
        The perl distribution comes with much more documentation than is
        available for most other newsgroups, so in clpmisc you should also
        see if you can find an answer in the other (non-FAQ) standard docs
        before posting.

    It is *not* required, or even expected, that you actually *read* all of
    Perl's standard docs, only that you spend a few minutes searching them
    before posting.

    Try doing a word-search in the standard docs for some words/phrases
    taken from your problem statement or from your very carefully worded
    "Subject:" header.

  Really Really Should
    This section describes things that you *really should* do before posting
    to clpmisc.

    Lurk for a while before posting
        This is very important and expected in all newsgroups. Lurking means
        to monitor a newsgroup for a period to become familiar with local
        customs. Each newsgroup has specific customs and rituals. Knowing
        these before you participate will help avoid embarrassing social
        situations. Consider yourself to be a foreigner at first!

    Search a Usenet archive
        There are tens of thousands of Perl programmers. It is very likely
        that your question has already been asked (and answered). See if you
        can find where it has already been answered.

        One such searchable archive is:

         http://groups.google.com/advanced_group_search

  If You Like
    This section describes things that you *can* do before posting to
    clpmisc.

    Check Other Resources
        You may want to check in books or on web sites to see if you can
        find the answer to your question.

        But you need to consider the source of such information: there are a
        lot of very poor Perl books and web sites, and several good ones
        too, of course.

Posting to comp.lang.perl.misc
    There can be 200 messages in clpmisc in a single day. Nobody is going to
    read every article. They must decide somehow which articles they are
    going to read, and which they will skip.

    Your post is in competition with 199 other posts. You need to "win"
    before a person who can help you will even read your question.

    These sections describe how you can help keep your article from being
    one of the "skipped" ones.

  Is there a better place to ask your question?
    Question should be about Perl, not about the application area
        It can be difficult to separate out where your problem really is,
        but you should make a conscious effort to post to the most
        applicable newsgroup. That is, after all, where you are the most
        likely to find the people who know how to answer your question.

        Being able to "partition" a problem is an essential skill for
        effectively troubleshooting programming problems. If you don't get
        that right, you end up looking for answers in the wrong places.

        It should be understood that you may not know that the root of your
        problem is not Perl-related (the two most frequent ones are CGI and
        Operating System related), so off-topic postings will happen from
        time to time. Be gracious when someone helps you find a better place
        to ask your question by pointing you to a more applicable newsgroup.

  How to participate (post) in the clpmisc community
    Carefully choose the contents of your Subject header
        You have 40 precious characters of Subject to win out and be one of
        the posts that gets read. Don't waste them. Take care while
        composing them, they are the key that opens the door to getting an
        answer.

        Spend them indicating what aspect of Perl others will find if they
        should decide to read your article.

        Do not spend them indicating "experience level" (guru, newbie...).

        Do not spend them pleading (please read, urgent, help!...).

        Do not spend them on non-Subjects (Perl question, one-word
        Subject...)

        For more information on choosing a Subject see "Choosing Good
        Subject Lines":

         http://www.cpan.org/authors/id/D/DM/DMR/subjects.post

        Part of the beauty of newsgroup dynamics, is that you can contribute
        to the community with your very first post! If your choice of
        Subject leads a fellow Perler to find the thread you are starting,
        then even asking a question helps us all.

    Use an effective followup style
        When composing a followup, quote only enough text to establish the
        context for the comments that you will add. Always indicate who
        wrote the quoted material. Never quote an entire article. Never
        quote a .signature (unless that is what you are commenting on).

        Intersperse your comments *following* each section of quoted text to
        which they relate. Unappreciated followup styles are referred to as
        "top-posting", "Jeopardy" (because the answer comes before the
        question), or "TOFU" (Text Over, Fullquote Under).

        Reversing the chronology of the dialog makes it much harder to
        understand (some folks won't even read it if written in that style).
        For more information on quoting style, see:

         http://web.presby.edu/~nnqadmin/nnq/nquote.html

    Speak Perl rather than English, when possible
        Perl is much more precise than natural language. Saying it in Perl
        instead will avoid misunderstanding your question or problem.

        Do not say: I have variable with "foo\tbar" in it.

        Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
        or I have $var = <DATA> (and show the data line).

    Ask perl to help you
        You can ask perl itself to help you find common programming mistakes
        by doing two things: enable warnings (perldoc warnings) and enable
        "strict"ures (perldoc strict).

        You should not bother the hundreds/thousands of readers of the
        newsgroup without first seeing if a machine can help you find your
        problem. It is demeaning to be asked to do the work of a machine. It
        will annoy the readers of your article.

        You can look up any of the messages that perl might issue to find
        out what the message means and how to resolve the potential mistake
        (perldoc perldiag). If you would like perl to look them up for you,
        you can put "use diagnostics;" near the top of your program.

    Do not re-type Perl code
        Use copy/paste or your editor's "import" function rather than
        attempting to type in your code. If you make a typo you will get
        followups about your typos instead of about the question you are
        trying to get answered.

    Provide enough information
        If you do the things in this item, you will have an Extremely Good
        chance of getting people to try and help you with your problem!
        These features are a really big bonus toward your question winning
        out over all of the other posts that you are competing with.

        First make a short (less than 20-30 lines) and *complete* program
        that illustrates the problem you are having. People should be able
        to run your program by copy/pasting the code from your article. (You
        will find that doing this step very often reveals your problem
        directly. Leading to an answer much more quickly and reliably than
        posting to Usenet.)

        Describe *precisely* the input to your program. Also provide example
        input data for your program. If you need to show file input, use the
        __DATA__ token (perldata.pod) to provide the file contents inside of
        your Perl program.

        Show the output (including the verbatim text of any messages) of
        your program.

        Describe how you want the output to be different from what you are
        getting.

        If you have no idea at all of how to code up your situation, be sure
        to at least describe the 2 things that you *do* know: input and
        desired output.

    Do not provide too much information
        Do not just post your entire program for debugging. Most especially
        do not post someone *else's* entire program.

    Do not post binaries, HTML, or MIME
        clpmisc is a text only newsgroup. If you have images or binaries
        that explain your question, put them in a publically accessible
        place (like a Web server) and provide a pointer to that location. If
        you include code, cut and paste it directly in the message body.
        Don't attach anything to the message. Don't post vcards or HTML.
        Many people (and even some Usenet servers) will automatically filter
        out such messages. Many people will not be able to easily read your
        post. Plain text is something everyone can read.

  Social faux pas to avoid
    The first two below are symptoms of lots of FAQ asking here in clpmisc.
    It happens so often that folks will assume that it is happening yet
    again. If you have looked but not found, or found but didn't understand
    the docs, say so in your article.

    Asking a Frequently Asked Question
        It should be understood that you may have missed the applicable FAQ
        when you checked, which is not a big deal. But if the Frequently
        Asked Question is worded similar to your question, folks will assume
        that you did not look at all. Don't become indignant at pointers to
        the FAQ, particularly if it solves your problem.

    Asking a question easily answered by a cursory doc search
        If folks think you have not even tried the obvious step of reading
        the docs applicable to your problem, they are likely to become
        annoyed.

        If you are flamed for not checking when you *did* check, then just
        shrug it off (and take the answer that you got).

    Asking for emailed answers
        Emailed answers benefit one person. Posted answers benefit the
        entire community. If folks can take the time to answer your
        question, then you can take the time to go get the answer in the
        same place where you asked the question.

        It is OK to ask for a *copy* of the answer to be emailed, but many
        will ignore such requests anyway. If you munge your address, you
        should never expect (or ask) to get email in response to a Usenet
        post.

        Ask the question here, get the answer here (maybe).

    Beware of saying "doesn't work"
        This is a "red flag" phrase. If you find yourself writing that,
        pause and see if you can't describe what is not working without
        saying "doesn't work". That is, describe how it is not what you
        want.

    Sending a "stealth" Cc copy
        A "stealth Cc" is when you both email and post a reply without
        indicating *in the body* that you are doing so.

  Be extra cautious when you get upset
    Count to ten before composing a followup when you are upset
        This is recommended in all Usenet newsgroups. Here in clpmisc, most
        flaming sub-threads are not about any feature of Perl at all! They
        are most often for what was seen as a breach of netiquette. If you
        have lurked for a bit, then you will know what is expected and won't
        make such posts in the first place.

        But if you get upset, wait a while before writing your followup. I
        recommend waiting at least 30 minutes.

    Count to ten after composing and before posting when you are upset
        After you have written your followup, wait *another* 30 minutes
        before committing yourself by posting it. You cannot take it back
        once it has been said.

AUTHOR
    Tad McClellan <tadmc@augustmail.com> and many others on the
    comp.lang.perl.misc newsgroup.



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

Date: 3 Jan 2005 22:52:29 -0800
From: "ChocMonk" <wolf_gore@yahoo.com.au>
Subject: Re: Program optimisation advice for newbie
Message-Id: <1104821549.419731.232000@f14g2000cwb.googlegroups.com>


Alan Mead wrote:
> Star date: Mon, 03 Jan 2005 19:55:33 -0800, ChocMonk's log:
>
> > Here is the snippet I wrote:
> > ----BEGIN CODE--
> > $descr = "
> > asdasdasd@@\main\3
> > boohoo@@\main\6
> > toodle@@\main\9";
> >
> > #grab the filename list
> > (my $crap, my $cset) = split /names/,$descr,2;
> > #split each line into an array
> > my @temp1 = split /\n/,$cset;
> >
> > #chuck the list into a hash
> > my %names;
> > foreach (@temp) {
> > (my $name, my $ver) = split /\@\@/,$_;
> > $names{$name} = $ver;
> > }
>
> This is your actual code?  I don't follow what you're doing in the
second
> chunk (where you "grab the filename list") and it doesn't look like
it
> makes sense... (where does the 'names' string appear in your input?)
> Maybe this is immaterial but I'd encourage you to cut-and-paste
rather
> than re-type (if you did retype).

Yup sorry. I did edit some stuff I figured would be irrelevant.
Basically I'm taking a multiline string $descr and grabbing anything
after "names" into $cset, dicarding anything before in $crap.

> I'm also not seeing why you create a variable @temp1 and then loop
over
> @temp... If this is a typo, then a STRONGLY encourage you to 'use
strict;'
> at the top of your script.  Also 'use warnings;'.
>
> In fact, even if it isn't a typo, I'd have the same advice.
that is a typo and I've taken your strict/warnings advice.

> Ok, now on to answering your question slightly... I guess it's a good
> enough way. If the list is long, then you might want to use a regular
> expression with the ... IIRC 'g' and 'm' options to successively
capture
> the lines (from memory):
>
> my %names=();
> do {
>   $cset =~ /$(.+?)\@\@(.+?)$/gm;
>   $names{$1} = $2 if (defined($1));
> } until (!defined($1));
>
> This uses a regex rather than the split.. don't know which is faster
but
> as written, you use twice the memory needed (because you have the
string
> of lines and then store the lines in a list).  Even better would be
to
> read the lines one at a time from a file but I assume you cannot do
this...
$descr is the output of a command so I'm not using a file.
I tried your regexp method and the match works great except that the
loop ends after the first match and $cset remains unmodified. I changed
the regexp slightly, as perl complained about the initial $ in your
regexp:

my %names=();
do {
$cset =~ /(.+?)\@\@(.+?)$/gm;
$names{$1} = $2 if (defined($1));
print STDERR "\ncset is $cset\n";
} until (!defined($1));


> Also, you shouldn't explicitly use variables like $_ (IMHO) like you
do in
> the last split,  I would write
>
> my($name,$ver) = split /\@\@/;
>
> or
>
> foreach my $t (@temp) {
>   my($name,$ver) = split(/\@\@/,$t);
> ...

Thanks for the great advice.
Choc



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

Date: Tue, 04 Jan 2005 07:34:59 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Program optimisation advice for newbie
Message-Id: <DGrCd.50953$KO5.9732@clgrps13>

ChocMonk wrote:
> 
> I've got a program snippet that takes a multiline string for exapmple:
> "asdasdasd@@\main\3
> boohoo@@\main\6
> toodle@@\main\9"
> 
> and forms a hash from it, where each key is the part of each line upto
> the first "@" and the value is everything following the second "@". So
> the hash key/value pairs for the above string look like:
> asdasdasd => \main\3
> boohoo => \main\6
> toodle => \main\9
> 
> Here is the snippet I wrote:
> ----BEGIN CODE--
> $descr = "
> asdasdasd@@\main\3
> boohoo@@\main\6
> toodle@@\main\9";
> 
> #grab the filename list
> (my $crap, my $cset) = split /names/,$descr,2;
> #split each line into an array
> my @temp1 = split /\n/,$cset;
> 
> #chuck the list into a hash
> my %names;
> foreach (@temp) {
> (my $name, my $ver) = split /\@\@/,$_;
> $names{$name} = $ver;
> }
> ----END CODE--
> 
> Is this a good way to do it? Any comments on making it more
> efficient/elegant would be much appreciated.

This should do what you want:

$ perl -MData::Dumper -le'
my $descr = q(
asdasdasd@@\main\3
boohoo@@\main\6
toodle@@\main\9);

my %names = $descr =~ / ( .+? ) \@\@ ( .+ ) /xg;

print Dumper \%names;
'
$VAR1 = {
           'asdasdasd' => '\\main\\3',
           'toodle' => '\\main\\9',
           'boohoo' => '\\main\\6'
         };



John
-- 
use Perl;
program
fulfillment


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

Date: 04 Jan 2005 08:29:01 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Why does this work?
Message-Id: <slrnctkkuc.h3.abigail@alexandra.abigail.nl>

Andrew Hamm (ahamm@mail.com) wrote on MMMMCXLIV September MCMXCIII in
<URL:news:33u7t2F45eu78U1@individual.net>:
$$  Abigail wrote:
$$ > %%
$$ > %%  because it is, unfortunately, ambiguous. Because the compiler
$$ > makes a %%  decision on your behalf, it MUST issue a warning when it
$$ > could so easily %%  be intended that a literal "-foo" is desired.
$$ > This Is A Good Thing, this %%  un-asked-for warning.
$$ >
$$ > No, it's not. Unasked for warnings are as welcome as unasked for
$$ > system crashes.
$$  
$$  well, this made me chuckle. I won't try to convince you otherwise. Hell,
$$  why not - this is c.l.p.misc and discussion descending into flames is par
$$  for the course. Let's see if we can at least stay above flames even if we
$$  don't end up agreeing...
$$  
$$  I think this warning is borderline as an error. Perhaps you'd feel more
$$  confident if this compiler error was promoted to a compilation-halting
$$  error? That way there'd be one less "unwanted warning". I expect the
$$  author/designer of this warning figured that the programmer could benefit
$$  from allowing the script to proceed since they will be able to
$$  disambiguate the statement the next time they edit. I for one would
$$  appreciate the opportunity to find more than one error as I'm developing a
$$  script.
$$  
$$  the case
$$  
$$      sub foo { .... }
$$      print -foo;
$$  
$$  unfortunately leads to an ambiguity, so the only ultimate answer is to
$$  remove the ambiguity in the Perl syntax? but then, would it still be Perl?

The ambiguity could trivially be resolved. By just defining that if
you have "-" followed by a sub, the result is that the sub is called
and the result negated.

Just like that '$foo = ++ $bar' isn't giving you a warning because
an alternative parse is '$foo = + + $bar'. 

It's not without precedent.

    $foo {shift}

used to warn (although not mandatory) it's going to be interpreted as

    $foo {"shift"}

Since 5.005, it just does AND KEEPS ITS MOUTH SHUT about it.

$$  
$$  I'm hard-pressed to think of any unwanted warnings from Perl that
$$  persistently shit me.
$$  
$$ > Yes, there should, IMO. I really, really loathe warnings I can't
$$ > turned off.  It's so unperl. *I*, the programmer, and only *I* should
$$ > be in control - and never ever the compiler/language.
$$  
$$  Sometimes the compiler needs your help to understand your code. In the
$$  sample given,
$$  
$$      sub foo { ... }
$$      print -foo;
$$  
$$  how pissed off would you be if you REALLY wanted it to mean
$$  
$$      print "-foo";

Yeah, but if I really meant

    $foo {shift ()}

when I write

    $foo {shift}

it keeps silent. And every one is happy about that.

If I really mean

    $var = + + $bar

when I write

    $var = ++ $bar

Perl keeps silent. And every one is happy about that.

If I really meant

    func (($var) + 3)

when I write

    func ($var) + 3

Perl keeps silent (except if the func is named "print", and there's a
single space between the name and the opening paren).

$$  But when you see this friendly warning, you can edit to correct.

And thus making the programmer the slave of the language.

BAD BAD BAD.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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