[26132] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8325 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 16 06:05:30 2005

Date: Tue, 16 Aug 2005 03:05:06 -0700 (PDT)
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, 16 Aug 2005     Volume: 10 Number: 8325

Today's topics:
         Re: mod_gzip and perl <ron@savage.net.au>
    Re: 2 files-array->1files <joe@inwap.com>
        How to extend an XS extension? (Inline::C?) <socyl@987jk.com.invalid>
    Re: How to extend an XS extension? (Inline::C?) <sisyphus1@nomail.afraid.org>
    Re: How to extend an XS extension? (Inline::C?) <sisyphus1@nomail.afraid.org>
    Re: How to extend an XS extension? (Inline::C?) <socyl@987jk.com.invalid>
        Image::GD::Thumbnail <""alexjaquet\"@[no spam]msn.com">
    Re: mod_gzip and perl <flavell@ph.gla.ac.uk>
        Object design of a list of things <fishfry@your-mailbox.com>
    Re: Object design of a list of things (Anno Siegel)
        perl running question <a@cuhk.edu.hk>
    Re: perl running question <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: perl running question <djames@thehub.com.au>
    Re: perl running question <a@cuhk.edu.hk>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: regex in perl (using variables) <dariosmece@yahoo.com>
    Re: Very basic question on using references inside func (Anno Siegel)
    Re: Very basic question on using references inside func xhoster@gmail.com
    Re: Very basic question on using references inside func (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 16 Aug 2005 18:38:49 +1000
From:     Ron Savage <ron@savage.net.au>
Subject:  Re: mod_gzip and perl
Message-Id: <2005816183849.887521@ron>

On Mon, 15 Aug 2005 18:05:33 +1000, lexjaquet@[no spam]msn.com wrote:

Hi Folks

> <quote>his site is optimised for browsersother than MSIE</quote>

Why not go all the way and say that every web site is optimized for browsers=
 
other than IE...




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

Date: Tue, 16 Aug 2005 01:08:59 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: 2 files-array->1files
Message-Id: <D7Cdnappb-65ApzeRVn-gg@comcast.com>

kristoff wrote:

> 1st one with this format ( systemname;message )
> bingo;ERROR Can't be reach port is closed
> pppp;system OK
> typo;System OK
> Ray;ERROR Can't be reach port is closed
> blush;ERROR Can't be reach port is closed
> bingo;system OK
> 
> 2nd FILE ( domain;system name ):
> HP;ppp
> HP;bingo
> IBM;typo
> COMPAQ;blush
> DELL;ray

I would put all the info from the first file into one
hash (key=systemname, val=message), assuming only one
message per systemname.

	/(\w+);(.*)/ and $message{$1} = $2;

Put the info from the second file into a second hash
(key=domain, val=ref to anon array containing system names).

	/(\w+);(\w+)/ and push @{$systems{$1}},$2;

Then process each key in %systems.

	foreach my $domain (sort keys %systems) {
	    print "something with $domain ...\n";
	    foreach my $system ( @{$systems{$domain}} ) {
		print "something with $system and $message{$system}\n";
	    }
	}

Those should be enough hints to get you going.
	-Joe


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

Date: Tue, 16 Aug 2005 01:17:11 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: How to extend an XS extension? (Inline::C?)
Message-Id: <ddreqn$mo7$1@reader2.panix.com>






One of the modules I use is a (huge) XS extension (say Foo.pm).
Unfortunately, this module is missing some functions that I need,
and that, for performance reasons, I need to code in C.  These
functions are quite simple, so I thought I'd do this with Inline::C.
Unfortunately, I'm not getting very far.

I use the following in my code:

use Inline C => Config =>
  INC      => '-I/path/to/header/files',
  LIBS     => '-L/path/to/arch/auto/Foo -lFoo',
  TYPEMAPS => '/path/to/Foo/typemap';

use Inline C => <<'EOCODE';

/* my C code */

EOCODE

Still the compiler complains that it cannot find certain functions
that are required by Foo's typemap file.  These functions are
defined in the library Foo.so, which resides in /path/to/arch/auto/Foo,
but, despite the code above, the compiler compains of not being
able to find it.  What am I doing wrong?

Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Tue, 16 Aug 2005 12:16:24 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: How to extend an XS extension? (Inline::C?)
Message-Id: <43014c9f$0$22557$afc38c87@news.optusnet.com.au>


"kj" <socyl@987jk.com.invalid> wrote in message

[snip]

>
> I use the following in my code:
>
> use Inline C => Config =>
>   INC      => '-I/path/to/header/files',
>   LIBS     => '-L/path/to/arch/auto/Foo -lFoo',

Not sure about this, but if you're trying to link to Foo.dll, then I think
you need to do it with MYEXTLIB instead of LIBS - something like:

MYEXTLIB => '/path/to/arch/auto/Foo/Foo.dll',

Let us know if that doesn't solve the problem.

I've not had need to use Inline C to access a perl dll .... and I'm
struggling to make sense of the need for it ... but that might just be a
result of my brain being somewhat inflexible :-)

Cheers,
Rob




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

Date: Tue, 16 Aug 2005 12:26:01 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: How to extend an XS extension? (Inline::C?)
Message-Id: <43014edf$0$25808$afc38c87@news.optusnet.com.au>


"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message
news:43014c9f$0$22557$afc38c87@news.optusnet.com.au...
>
> "kj" <socyl@987jk.com.invalid> wrote in message
>
> [snip]
>
> >
> > I use the following in my code:
> >
> > use Inline C => Config =>
> >   INC      => '-I/path/to/header/files',
> >   LIBS     => '-L/path/to/arch/auto/Foo -lFoo',
>
> Not sure about this, but if you're trying to link to Foo.dll, then I think

Ooops - your shared object is an 'so' not a 'dll', so s/dll/so/g .

> you need to do it with MYEXTLIB instead of LIBS - something like:
>
> MYEXTLIB => '/path/to/arch/auto/Foo/Foo.dll',
>
> Let us know if that doesn't solve the problem.
>
> I've not had need to use Inline C to access a perl dll .... and I'm
> struggling to make sense of the need for it ... but that might just be a
> result of my brain being somewhat inflexible :-)
>

Also check perldoc Inline::C-Cookbook and look for the section "Event
handling with Event.pm". This appears to be similar to what you're trying.

Cheers,
Rob




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

Date: Tue, 16 Aug 2005 09:45:25 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: How to extend an XS extension? (Inline::C?)
Message-Id: <ddscjl$ff4$1@reader2.panix.com>

In <43014c9f$0$22557$afc38c87@news.optusnet.com.au> "Sisyphus" <sisyphus1@nomail.afraid.org> writes:


>"kj" <socyl@987jk.com.invalid> wrote in message

>[snip]

>>
>> I use the following in my code:
>>
>> use Inline C => Config =>
>>   INC      => '-I/path/to/header/files',
>>   LIBS     => '-L/path/to/arch/auto/Foo -lFoo',

>Not sure about this, but if you're trying to link to Foo.dll, then I think
>you need to do it with MYEXTLIB instead of LIBS - something like:

That did the trick.  Thanks!

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Tue, 16 Aug 2005 10:01:29 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Image::GD::Thumbnail
Message-Id: <43019d5d$0$1153$5402220f@news.sunrise.ch>

Hi,

I use this module to generate some thumbnail image for the web
currently I use it this way :

sub createTumb {

     local our  $filename = shift || '';
     open (IN, "<$dir/upload/$filename")  or die "Could not open 
$dir/upload/$filename";
     local our  $srcImage = GD::Image->newFromJpeg(*IN);
     close IN;
     local our  ($thumb,$x,$y) = Image::GD::Thumbnail::create($srcImage,50);
     open (OUT,">>$dir/upload/thumb.$filename") or die "Could not save ";
     binmode OUT;
     print OUT $thumb->jpeg;
     close OUT;
}

But I want to optimize the image by using GIF or PNG format, does anyone 
have already used this module and know how to use GIF format ?

Image size are to heavy with JPG format ...

Thanks in advance

Alexandre Jaquet


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

Date: Tue, 16 Aug 2005 09:49:16 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: mod_gzip and perl
Message-Id: <Pine.LNX.4.62.0508160943130.25851@ppepc56.ph.gla.ac.uk>

On Tue, 16 Aug 2005, Ron Savage wrote:

> Why not go all the way and say that every web site is optimized for 
> browsers other than IE...

My answer to that question would be that those who know what is meant 
by a "web site" in terms of the interworking specifications is already 
well aware of that - whereas those who *need* to be reached by the 
message are those who still think that MSIE is a web browser (or 
worse, who think that MSIE is the only web browser).

But we really ought not to be discussing this issue here!  (f'ups
proposed!!)


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

Date: Tue, 16 Aug 2005 00:32:08 -0700
From: fishfry <fishfry@your-mailbox.com>
Subject: Object design of a list of things
Message-Id: <fishfry-6FD4FE.00320816082005@comcast.dca.giganews.com>

Suppose I have a simple (flat) data structure, say for example a hash 
with keys name, position, average representing baseball players.

In my program I might often need a list of these hashes, along with 
methods that look up an object based on name, etc.

I have a class called PlayerList, which holds a list of players, along 
with various methods for looking up, adding, and deleting players from 
the list.

What are the pros and cons, in OO design terms, of having a separate 
class for the data structure, say Player.pm, versus not having a 
separate class?

For example in the former case I would add a new player to the list by 
saying 

   my $playerList = new PlayerList(name=>'name', position=>'outfield', 
average=>.300);
   my $player = new Player();
   $playerList->add($player);

versus

  my $playerList = new PlayerList();
  $playerList->add({name=>'name', position=>'outfield', average=>.300};


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

Date: 16 Aug 2005 09:39:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Object design of a list of things
Message-Id: <ddsc8l$1ot$1@mamenchi.zrz.TU-Berlin.DE>

fishfry  <fishfry@your-mailbox.com> wrote in comp.lang.perl.misc:
> Suppose I have a simple (flat) data structure, say for example a hash 
> with keys name, position, average representing baseball players.
> 
> In my program I might often need a list of these hashes, along with 
> methods that look up an object based on name, etc.
> 
> I have a class called PlayerList, which holds a list of players, along 
> with various methods for looking up, adding, and deleting players from 
> the list.
> 
> What are the pros and cons, in OO design terms, of having a separate 
> class for the data structure, say Player.pm, versus not having a 
> separate class?

Use separate classes.  This doesn't only go for OO.  Whenever you
have the choice of keeping two problems apart or merging them into
one, keep them apart.

Write a general list class that makes as few assumptions about its
elements as possible.  Write a player class that doesn't assume
the players are going to be collected in lists.  Then put the two
together.

> For example in the former case I would add a new player to the list by 
> saying 
> 
>    my $playerList = new PlayerList(name=>'name', position=>'outfield', 
> average=>.300);
>    my $player = new Player();
>    $playerList->add($player);

This doesn't make much sense.  You are creating a PlayerList with
parameters that pertain to a single player.  Are you assuming PlayerList
stores these values for the creation of new players?  That doesn't look
like a good arrangement.

> versus
> 
>   my $playerList = new PlayerList();
>   $playerList->add({name=>'name', position=>'outfield', average=>.300};

That still assumes that PlayerList knows how to create players, coupling
the classes closer than necessary.  Here is my take (untested):

    my $playerlist = List->new;
    $playerList->add(
        Player->new( name=>'name', position=>'outfield', average=>.300),
    );

    # ...

    my @good = $playerList->search( sub { $_->average >= .300 });

    ############################################################
    package Player;

    sub new {
        my $class = shift;
        bless { @_}, $class;
    }
    sub name { $_[ 0]->{ name} }
    sub average { $_[ 0]->{ average} }
    # etc.

    ############################################################
    package List;

    sub new { bless [], shift }

    sub add {
        my $list = shift;
        push @$l, @_;
    }

    sub search {
        my $list = shift;
        my $code = shift;
        grep $code->(), @$list;
    }
    __END__

Note that the classes Player and List are completely independent.  In
a practical implementation you may not be able to keep them as cleanly
apart as in this model, but that's the direction to go.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Tue, 16 Aug 2005 11:36:42 +0800
From: "Ross" <a@cuhk.edu.hk>
Subject: perl running question
Message-Id: <ddrme6$h68$1@justice.itsc.cuhk.edu.hk>

Dear all,
  I find posting here may be more appropriate and so tidy up my inquiries 
and feedbacks and ask this question again:

after installing FC3, perl script needs to be run using:

/usr/bin/perl test.pl

when it is in FC1, i can just type test.pl

as both OS's are installed by me and the same conf files are to be used.

In the test.pl,

The first line of the script is:

#!/usr/bin/perl

i've even tried changing it to perl5.8.5 as i know it is in /usr/bin

no matter i add set path = ($path .) or i run the perl directly at
the directory containing it (no amibugous command confirmed by using 
"which"), i must use

/usr/bin/perl test.pl

the permission of test.pl is
rwxr-xr-x

as test.pl takes one argument, when typing test.pl, something like "please
provide your filename" should be printed at the prompt but it doesn't.

Some say it would be the fixing of a security problem of FC3, could anybody 
suggest any idea?







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

Date: Mon, 15 Aug 2005 20:37:33 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: perl running question
Message-Id: <uk38t2xba8.ln2@goaway.wombat.san-francisco.ca.us>

On 2005-08-16, Ross <a@cuhk.edu.hk> wrote:
>
> as test.pl takes one argument, when typing test.pl, something like "please
> provide your filename" should be printed at the prompt but it doesn't.

What *does* it do?  Explaining what you want it to do is not helpful
unless you also explain what it actually does.  Posting a *short*,
*complete* script that replicates the problem is also helpful.

--keith

-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
see X- headers for PGP signature information



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

Date: Tue, 16 Aug 2005 14:19:44 +1000
From: Damian James <djames@thehub.com.au>
Subject: Re: perl running question
Message-Id: <slrndg2qb0.5m6.djames@stumble.qimr.edu.au>

On Tue, 16 Aug 2005 11:36:42 +0800, Ross said:
>   I find posting here may be more appropriate and so tidy up my inquiries 
> and feedbacks and ask this question again:
> 
> after installing FC3, perl script needs to be run using:
> 
> /usr/bin/perl test.pl
> 
> when it is in FC1, i can just type test.pl
> 
> as both OS's are installed by me and the same conf files are to be used.

Did you have "." in your path in the FC1 environment? Friends don't let
friends put "." in their path. If FC1 included this in the default path,
and FC3 removed it, then I would certainly call it a security enhancement.

Have you tried "./test.pl"?

This doesn't have much to do with Perl, of course.

--Damian


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

Date: Tue, 16 Aug 2005 16:12:35 +0800
From: "Ross" <a@cuhk.edu.hk>
Subject: Re: perl running question
Message-Id: <dds6j8$k6g$1@justice.itsc.cuhk.edu.hk>


"Damian James" <djames@thehub.com.au> wrote in message 
news:slrndg2qb0.5m6.djames@stumble.qimr.edu.au...
> On Tue, 16 Aug 2005 11:36:42 +0800, Ross said:
>>   I find posting here may be more appropriate and so tidy up my inquiries
>> and feedbacks and ask this question again:
>>
>> after installing FC3, perl script needs to be run using:
>>
>> /usr/bin/perl test.pl
>>
>> when it is in FC1, i can just type test.pl
>>
>> as both OS's are installed by me and the same conf files are to be used.
>
> Did you have "." in your path in the FC1 environment? Friends don't let
> friends put "." in their path. If FC1 included this in the default path,
> and FC3 removed it, then I would certainly call it a security enhancement.

? I don't know what you mean.

>
> Have you tried "./test.pl"?

i've tried.

> This doesn't have much to do with Perl, of course.
>
> --Damian


#!/usr/bin/perl

$input = $ARGV[0];
if($input =~ /^$/) {
        print "usage: addDB2HTML.pl [db name]  \n";
        exit;
}

open(IN, $input) || die "Could not open $input\n";

while($line = <IN>) {
  print "$line\n";
} 




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

Date: 16 Aug 2005 07:23:04 GMT
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <43019457$0$19256$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: Tue, 16 Aug 2005 09:35:28 +0200
From: "dario" <dariosmece@yahoo.com>
Subject: Re: regex in perl (using variables)
Message-Id: <dds4tb$fdo$1@bagan.srce.hr>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:3m3rp4F15alo2U1@individual.net...
> One thought is that you didn't convert the file in question to Unix
> format when copying it from Windows. In that case the chomp()ing may
> accidentally serve the purpose of removing the \r character.

Thank's that's right. When I converted the files to unix all worked.
Thank' again.
Dario




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

Date: 15 Aug 2005 22:37:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Very basic question on using references inside functions
Message-Id: <ddr5g3$98u$1@mamenchi.zrz.TU-Berlin.DE>

 <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> Mark Seger <Mark.Seger@hp.com> wrote:

[variable passing]

> You could use typeglobs (or whatever it is I am supposed to call those
> things). I don't particularly recommend it, but I have used it in a pinch.
> 
> use strict;
> 
> my $x='j' x 10;
> 
> print "$x\n";
> foo3($x);
> print "$x\n";
> 
> sub foo3 {
>   our $y;
>   *y = \$_[0];
>   $y =~ s/j/k/g;
> };

Yes, but why?

    sub foo4 { $_[ 0] =~ s/j/k/g }

or

    sub foo5 { s/j/k/g for shift }

do the same thing directly.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 16 Aug 2005 03:33:21 GMT
From: xhoster@gmail.com
Subject: Re: Very basic question on using references inside functions
Message-Id: <20050815233321.713$1m@newsreader.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>  <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> > Mark Seger <Mark.Seger@hp.com> wrote:
>
> [variable passing]
>
> > You could use typeglobs (or whatever it is I am supposed to call those
> > things). I don't particularly recommend it, but I have used it in a
> > pinch.
> >
> > use strict;
> >
> > my $x='j' x 10;
> >
> > print "$x\n";
> > foo3($x);
> > print "$x\n";
> >
> > sub foo3 {
> >   our $y;
> >   *y = \$_[0];
> >   $y =~ s/j/k/g;
> > };
>
> Yes, but why?

The point of a short but complete example script (like people here are
always asking for) is to show how something is done.  It is not to show why
it is done.  The why is covered in the prose.  I thought it was pretty
obvious why to do that.
>
>     sub foo4 { $_[ 0] =~ s/j/k/g }

unlike $_[0], the name of $y can be arbitrarily chosen.  If you are going
to use the variable fifty times in your subroutine, that is quite a
benefit.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 16 Aug 2005 08:39:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Very basic question on using references inside functions
Message-Id: <dds8o4$sqm$1@mamenchi.zrz.TU-Berlin.DE>

 <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> >  <xhoster@gmail.com> wrote in comp.lang.perl.misc:
> > > Mark Seger <Mark.Seger@hp.com> wrote:
> >
> > [variable passing]
> >
> > > You could use typeglobs (or whatever it is I am supposed to call those
> > > things). I don't particularly recommend it, but I have used it in a
> > > pinch.
> > >
> > > use strict;
> > >
> > > my $x='j' x 10;
> > >
> > > print "$x\n";
> > > foo3($x);
> > > print "$x\n";
> > >
> > > sub foo3 {
> > >   our $y;
> > >   *y = \$_[0];
> > >   $y =~ s/j/k/g;
> > > };
> >
> > Yes, but why?
> 
> The point of a short but complete example script (like people here are
> always asking for) is to show how something is done.  It is not to show why
> it is done.  The why is covered in the prose.  I thought it was pretty
> obvious why to do that.

You say "in a pinch", but I don't see the pinch that makes a solution
involving package variables attractive.

> >     sub foo4 { $_[ 0] =~ s/j/k/g }
> 
> unlike $_[0], the name of $y can be arbitrarily chosen.  If you are going
> to use the variable fifty times in your subroutine, that is quite a
> benefit.

You can have that lexically too:

    for my $y ( shift ) {
        $y =~ s/j/k/g;
    }

(Admitted, it doesn't scale well for more than one variable.)

You know the reason to avoid package variables: exposure.  If you have
a rogue function do_something() (say, imported from somewhere), which does

    sub do_something {
        # ....
        our $y = 'something else';
    }

then calling do_something() while "*y = \ $_[ 0]" is in effect has
unexpected and hard-to-trace consequences:

    sub foo6 {
        our $y;
        *y = \ shift();
        do_something()
        $y =~ s/g/k/g;
    }

now sets its argument to "somethink else".

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

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


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