[23967] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6168 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 20 06:05:41 2004

Date: Fri, 20 Feb 2004 03:05:06 -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           Fri, 20 Feb 2004     Volume: 10 Number: 6168

Today's topics:
    Re: can s/// return a new value, rather than modifying  <bart.lateur@pandora.be>
        Compatibility of perl on different HPUX-Versions (Alex F.)
    Re: finding the last match before a first match (regex) <nobull@mail.com>
    Re: FORM POST submission <nospam@bigpond.com>
    Re: FORM POST submission <tadmc@augustmail.com>
    Re: how can a daemon output to console (Jason Chan)
    Re: Listbox and passing entries <a@b.com>
    Re: method reference - repost <uri@stemsystems.com>
    Re: more stripping <gnari@simnet.is>
    Re: more stripping <Joe.Smith@inwap.com>
        Posting Guidelines for comp.lang.perl.misc ($Revision:  tadmc@augustmail.com
    Re: Problem with hashes <tadmc@augustmail.com>
        Really unbuffered reads... <mb@uq.net.au.invalid>
        regex  <yamini_rajan@nospam.com>
    Re: regex  <tadmc@augustmail.com>
        regex <yamini_rajan@nospam.com>
    Re: regex <nospam@bigpond.com>
    Re: Replacing a text in multiple files with regular exp (Angel)
    Re: Replacing a text in multiple files with regular exp (Angel)
    Re: TMTOWTDI <tadmc@augustmail.com>
    Re: TMTOWTDI <uri@stemsystems.com>
    Re: TMTOWTDI <graham@cs.man.ac.uk>
        Using perl over network (NFS) (Alex F.)
    Re: Using perl over network (NFS) <Joe.Smith@inwap.com>
    Re: Why is Perl losing ground? <bart.lateur@pandora.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 20 Feb 2004 10:44:54 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: can s/// return a new value, rather than modifying it's input argument?
Message-Id: <e8pb3055e4gs51ffflskog0f5tr2tfkjav@4ax.com>

James Taylor wrote:

>What's the benefit of using the qr// quoting construct here?

Compile time check that the pattern actually compiles?

-- 
	Bart.


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

Date: 20 Feb 2004 01:49:04 -0800
From: v2af@yahoo.de (Alex F.)
Subject: Compatibility of perl on different HPUX-Versions
Message-Id: <1e8fe2ae.0402200149.2cb88ad0@posting.google.com>

Hi folks,

is it possible to call perl running on HPUX11.xy from a
HPUX10.xy-machine - donīt care which perl-version and which modules,
just the perl-exe itself...

thanx
Alex


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

Date: 20 Feb 2004 08:46:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: finding the last match before a first match (regex)
Message-Id: <u9u11mcdhv.fsf@wcl-l.bham.ac.uk>

Showing a worrying trend towards insanity, Brian McCauley
<nobull@mail.com> refers to himself in the third person when he
writes:

> That well know clown Brian McCauley <nobull@mail.com> writes:
> 
> > Don't put qualifiers on m// that you don't understand.
> 
> Advice he'd do well to follow himself :-)

Yeah, and like don't remove them from other people's code without
thinking either dude!

> /foo/g or die "no foo";
> /.*(a.*)\G/ or die "no a before first foo";

I suspect in the OP's problem the real target can span newlines so the
OP's use of /s is necessary in the second match.

/.*(a.*)\G/s or die "no a before first foo";

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 20 Feb 2004 02:47:22 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: FORM POST submission
Message-Id: <12832758.UjDsr5mBMK@GMT-hosting-and-pickle-farming>

Andrew V. Tkachenko wrote:

> I'm not sure its a good idea to pass passwords through GET method. They
> may be viewed in log files either by admin or by successfull hacker :)

GET and POST offer the same level of security (ie none) unless you are using
https.

> Also, in our case putting GET instead of POST looks like a dirty hack :)

And your solution isn't? Its just very basic html.

BTW, there's also a syntax to supply userid & password in the URL when using 
basic authentication ie those pop up boxes the browser gives you for some
sites. The syntax to logon would be:
http://userid:password@youresite.com/rest-of-url

gtoomey





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

Date: Thu, 19 Feb 2004 22:48:43 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: FORM POST submission
Message-Id: <slrnc3b4db.1eq.tadmc@magna.augustmail.com>

Cognition Peon <cenxnfu@rpr.nevmban.rqh> wrote:

> HTML for the form is in the following file
                                        ^^^^
> http://68.0.148.101:8055/login.html


That is not a file spec, that is an URL.

"resources" are not the same as "files".


   HTML for the form is at the following URL ...

would have been accurate.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 19 Feb 2004 18:52:18 -0800
From: jason@sted.minidns.net (Jason Chan)
Subject: Re: how can a daemon output to console
Message-Id: <5eee3998.0402191852.363472ad@posting.google.com>

yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones) wrote in message > 
> One option would be Sys::Syslog.  I think you'll find that one of the
> logging options is to send the message to the console, but sending it to a
> log file (see /etc/syslog.conf maybe?) may be even better, since if it's a
> daemon then what "user" will actually be examining the console?
> 

Thanks for your comment.

Rgds,
Michael


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

Date: Fri, 20 Feb 2004 04:45:55 GMT
From: "Old School" <a@b.com>
Subject: Re: Listbox and passing entries
Message-Id: <7igZb.21738$M76.10740@fe2.texas.rr.com>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:c13boc$1dt59q$1@ID-184292.news.uni-berlin.de...
> Old School wrote:
> > Gunnar Hjalmarsson wrote:
> >> It's not possible to tell what mistake you made out from the code
> >> fragments you posted. You'd better post a *minimal* but
> >> *complete* script and ditto form that people can copy, paste and
> >> run. If you do so, the script should be written with strictures
> >> and warnings enabled, so that you don't unnecessarily bother the
> >> group with trivial errors that Perl could have let you know
> >> about.
> >
> > The SplitParam sub does the same thing as param(),
>
> The *same* thing? Not even close.
>
>      @lchar = SplitParam($form{LCHAR});
>
> does nothing but
>
>      @lchar = split /\0/, $form{LCHAR};
>
> so it's basically redundant (IMO).
>
> > however, you may need to run the input through ReadParse, before
> > proccessing with SplitParam.
>
> Yes, ReadParse() is the main function in cgi-lib.pl.
>
> > The script is much too large to post here, but the idea behind what
> > I want to do is:
> >
> > 1.  collect data from a multiple item listbox (created within an
> > html form via print EOF)
> > 2.  strip out the \0s and assign to list array elements
> > 3.  be able to print out the elements
>
> What you are trying to do is perfectly clear to me, but obviously you
> are making a mistake, since it should work AFAICT. When asking you to
> post a *minimal* script I meant that you should write a script for the
> sole purpose of illustrating the problem. If you don't, I'm afraid
> that nobody can help you.
>
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl

Gunner,  thanks for taking some time to post on this matter.  I've spent too
much time on something that should have been a piece of cake.  I will take a
hard look at it again, and will get it worked out if it kills me.  Peace
out...

>




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

Date: Fri, 20 Feb 2004 05:13:06 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: method reference - repost
Message-Id: <x7hdxml4f2.fsf@mail.sysarch.com>

>>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:

  BM> Uri Guttman <uri@stemsystems.com> wrote:
  >> >>>>> "BM" == Ben Morrow <usenet@morrow.me.uk> writes:
  >> 
  NS> how could it be called without creating the intermediate $m ?
  >> >> 
  >> >> can't be done. it has nothing to do with how you get the dynamic
  >> >> method. the method slot of a call must be a single scalar variable or
  >> >> bareword. it can't be an expression.
  >> 
  BM> Howsabout (not exactly clear, but...:)
  BM> $obj->can($obj->{lst}[0])->($obj, 20);
  BM> ?

  >> that isn't selecting the method but getting back a code ref. not the
  >> same thing. and i am not even sure that will be a method call there
  >> since there is no method being used in the final call.

  BM> What difference does it make? I thought that $obj->meth(@args) was
  BM> equivalent to Class::meth($obj, @args) once the method lookup has been
  BM> done (which is what can() does). Am I wrong?

you lose inheritance with Class::meth($obj, @args). yes, you did get
inheritance with the can() call above but that is so fugly as to be just
fun code and not real. it still doesn't really solve the syntax issue
where only a literal method or single scalar var can be in the method
slot. no one will use your code and they will complain about not being
able to use an expression for the method without a temp var. now, i was
one of those who fell into this very trap and learned my lesson a few
years ago. 

  BM> (If I am wrong then yes, clearly that is a sub rather than a method
  BM> call...)

well, it is a sub (code ref) call on a method looked up with can. i just
won't let it be called a real method call. :)

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: Fri, 20 Feb 2004 08:43:58 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: more stripping
Message-Id: <c14has$kvq$1@news.simnet.is>


"Michael Hill" <hillmw@ram.lmtas.lmco.com> wrote in message
news:40355894.98456116@ram.lmtas.lmco.com...
>
>
> >
[attribution to Gunnar lost]
> > Again, I posted in this thread because security aspects were mentioned
> > in such a way that you falsely could get the impression that using
> > CGI.pm automatically takes care of them. If those comments hadn't been
> > posted, I would have kept my mouth shut this time. ;-)
> >
>
> And this was why I asked about security because it didn't seem correct.

see what you have done, Gunnar ?
you have made support for hand-rolled cgi to a newbie that thinks that
POST will make his script more secure

gnari





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

Date: Fri, 20 Feb 2004 09:54:51 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: more stripping
Message-Id: <LPkZb.364110$na.562406@attbi_s04>

thumb_42@yahoo.com wrote:

> In general I don't see many *security problems* with rolling your own parsing.
> (except maybe someone giving you bogus data or posting way more data
> than they really ought to, or feeding you data that some how chokes up your
> regex's into doing things it shouldn't.)
> 
> Where you may run into trouble is in how you use those parsed values, but
> the exact same things can be said for CGI.pm, ...

Hand-rolled CGI code is typically looked over by only one set of eyes.
CGI.pm has been gone over with a fine toothed comb many times.

Bugs tend to get fixed quicker (and in a more robust manner) when
under public scrutiny, like CGI.pm is.
	-Joe


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

Date: Fri, 20 Feb 2004 02:22:04 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <m7udnbzuY68xXqjdRVn-tA@august.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: Thu, 19 Feb 2004 22:35:26 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Problem with hashes
Message-Id: <slrnc3b3ke.1eq.tadmc@magna.augustmail.com>

cousin_bubba <cousin_bubba@hotmail.com> wrote:

> I
> would like to do the following:
> 
> @{$line_xx_section{$variable}


What do the unbalanced curlie brackets mean?


> in this case the hash name is $line_xx_section 


No it isn't.

If it starts with a dollar sign then it is the name of a scalar.

The name of the hash in question is %line_xx_section.

$line_xx_section{$variable} accesses a scalar _value_
in the hash, not the whole hash structure. 

The scalar named $line_xx_section does not appear anywhere
in the code you posted, and if it did, it would not have
any relationship with a hash named line_xx_section other
than similar-looking names.


> Any idea how I
> can make this work.


Use a hash-of-hashes (HoH).

   perldoc perlreftut
   perldoc perlref
   perldoc perllol
   perldoc perldsc


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 20 Feb 2004 12:08:35 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: Really unbuffered reads...
Message-Id: <c13q73$8f9$1@bunyip.cc.uq.edu.au>

Hi all,

I'm using GnuPG::Interface to verify some PGP signed data, and for the 
most part it all seems to be working nicely.

I have come across a small problem though. Sometimes (not always, which 
makes this nicely annoying) the function I use to read through the 
output blocks indefinitely.

The segment of code that causes the problem is:

# $fh is a filehandle passed in to the function -
# its an IO::Handle object that's been used as the
# stderr handle to GnuPG::Interface::verify
my ($buffer, $ok) = ('', undef);
while (1) {
	if (not sysread($fh, $buffer, 1024, length($buffer)) {
		last if not length $buffer;
		$ok = [1, $1] if $buffer =~ PGP_SIGOK;
		last;
	}
	# Do some stuff with buffer to look for individual lines...
}

This _almost_ always works fine. Rarely, that sysread hangs. If i'm 
looking at the process table at the time and I kill off the gpg process, 
everything trucks along as it should.

Is there a way to fix this. Maybe a different method for reading in the 
data? I'm guessing that the problem is that sometimes gpg doesn't spit 
out a newline at the end of its stderr messages, but I can't find any 
obvious differences between messages that work and those that block.

MB



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

Date: Thu, 19 Feb 2004 22:19:18 -0600
From: "yamini" <yamini_rajan@nospam.com>
Subject: regex 
Message-Id: <7401ede63b2a5509275b5e9d04c6c8ec@localhost.talkaboutprogramming.com>

  $tag="({NP_PP}|{NP_B})";
$tag1="({\/NP_PP}|{\/NP_B})";
 $_="{NP_PP} kinase{/NP_PP} a {NP_B}tyrosine{/NP_B}";
 
s/$tag[^{}]+$tag1/have/;
s/$tag[^{}]+$tag1/nice day/;
expected o/p:have a nice day
actual o/p: have a {NP_B}tyrosine{/NP_B}
will anyone help me in understanding this?




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

Date: Thu, 19 Feb 2004 22:41:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regex 
Message-Id: <slrnc3b40l.1eq.tadmc@magna.augustmail.com>

yamini <yamini_rajan@nospam.com> wrote:
>   $tag="({NP_PP}|{NP_B})";
> $tag1="({\/NP_PP}|{\/NP_B})";
>  $_="{NP_PP} kinase{/NP_PP} a {NP_B}tyrosine{/NP_B}";
>  
> s/$tag[^{}]+$tag1/have/;
> s/$tag[^{}]+$tag1/nice day/;
> expected o/p:
  ^^^^^^^^^^^^
  ^^^^^^^^^^^^

None.

There are no output statements in the code you posted.


Please post a short and complete program that we can run that
illustrates the problem you are having, and we will help you fix it.

Have you seen the Posting Guidelines that are posted here frequently?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 20 Feb 2004 00:06:38 -0600
From: "yamini" <yamini_rajan@nospam.com>
Subject: regex
Message-Id: <d4fc1040acc399f5b4152fc1b3f48f69@localhost.talkaboutprogramming.com>

hi,
$tag="{PAGE}";
$tag1="{/PAGE}";
$t="<p>";
$t1="</p>";
$_="{PAGE}this is the index<p>dfkdf</p>{/PAGE}";#or it may be
   $_="{PAGE}<p>dsgsg</p>{/PAGE}";
      
can anyone help me in writing a generalized regex for both the possibilities of $_?



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

Date: 20 Feb 2004 05:59:08 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: regex
Message-Id: <1237706.llQmd17Qjm@GMT-hosting-and-pickle-farming>

yamini wrote:

> hi,
> $tag="{PAGE}";
> $tag1="{/PAGE}";
> $t="<p>";
> $t1="</p>";
> $_="{PAGE}this is the index<p>dfkdf</p>{/PAGE}";#or it may be
>    $_="{PAGE}<p>dsgsg</p>{/PAGE}";
>       
> can anyone help me in writing a generalized regex for both the
> possibilities of $_?

 .*PAGE.*PAGE.*

gtoomey


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

Date: 19 Feb 2004 23:03:33 -0800
From: anichin@vip.bg (Angel)
Subject: Re: Replacing a text in multiple files with regular expressions
Message-Id: <8732d910.0402192303.1f215d45@posting.google.com>

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<l55Zb.27814$5W3.6744@nwrddc02.gnilink.net>...
> Angel wrote:
> > anichin@vip.bg (Angel) wrote in message
> > news:<8732d910.0402190049.3933532a@posting.google.com>...
> >> I would like to make an image clickable, in other words
> >> to replace all occurrences of:
> >>
> >> <img src="pic.gif" width="199" height="31" alt="" border="0">
> >>
> >> with
> >>
> >> <a href="http://somewhere.com"><img src="pic.gif" width="199"
> >> height="31" alt="" border="0"></a>
> >>
> >> I would like to search and replace on many files located in
> >> different subfolders of one main folder.
> >>
> >> I know it should be possible using regular expressions but
> >> all my attempts failed. Can anyone help me ?
> >
> > The problem was not the regular expression itself but
> > the need to process many files and recursively to search
> > the sub-folders.
> 
> Then why didn't you say so in the beginning?
> And btw., no it is not possible to recurse through a directory structure
> using REs. Those two have nothing to do with each other.

I said that:

"I would like to search and replace on many files located in
different subfolders of one main folder."

> 
> > I tried something similar to:
> >
> > perl -pi.bak -e "s#(<img[^>]+>)#<a
> > href="http://somewhere.com">$1</a>#gi" *.html
> >
> > The problem is that wildcards does not work with my
> > perl on Windows XP. I am not sure if it works in Unix either.
> 
> The proper way is to use File::Find
> It will recurse through any directory structure, visiting any file on the
> way.
> Then it is up to you to do whatever you want to for each file.
> 
> jue


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

Date: 19 Feb 2004 23:04:02 -0800
From: anichin@vip.bg (Angel)
Subject: Re: Replacing a text in multiple files with regular expressions
Message-Id: <8732d910.0402192304.69a6fa96@posting.google.com>

Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrnc39veg.3uh.tadmc@magna.augustmail.com>...
> Angel <anichin@vip.bg> wrote:
> 
> > The problem is that wildcards does not work with my 
> > perl on Windows XP.
> 
> 
> But you can make "wildcards" work yourself by using:
> 
>    perldoc -f glob

Thanks, I will try this.


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

Date: Thu, 19 Feb 2004 23:02:43 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: TMTOWTDI
Message-Id: <slrnc3b57j.1eq.tadmc@magna.augustmail.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:

> There are a few keywords that make a Perl programmer think "Hash!", and
> one of them is "a few exceptions".  (Another such keyword is "unique").


Yet some more:

   lookup
   cross-reference
   related to        ( a "relation" )
   associated with
   duplicate
   symbolic reference
   dispatch table


Sometimes you can cut right through that thinking stuff and
head right on over to the solution:

   Message-ID: <slrn95u8og.1cr.rgarciasuarez@rafael.kazibao.net>

        I don't know what your original problem is, 
        but I suggest to use a hash.  --Rafael Garcia-Suarez


:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 20 Feb 2004 05:42:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: TMTOWTDI
Message-Id: <x73c96l31e.fsf@mail.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:

  TM> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
  >> There are a few keywords that make a Perl programmer think "Hash!", and
  >> one of them is "a few exceptions".  (Another such keyword is "unique").


  TM> Yet some more:

  TM>    lookup
  TM>    cross-reference
  TM>    related to        ( a "relation" )
  TM>    associated with
  TM>    duplicate
  TM>    symbolic reference
  TM>    dispatch table

table (of any sort)
record
structure
convert
is a
set
has a
tree
mapping (or map)
dictionary
objects (most use hashes)
attributes
properties
traits
registry

this is actually an interesting list and maybe could be converted into
an FAQ: when should i use a hash? :)

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: 20 Feb 2004 10:01:56 +0000
From: Graham Gough <graham@cs.man.ac.uk>
Subject: Re: TMTOWTDI
Message-Id: <ttlptca9ii3.fsf@sphere.cs.man.ac.uk>

Thanks for all the interesting suggestions. Like some of the posters,
my usual reaction to many programming problems is to use a hash, I
don't know why I didn't think of it this time. Old age, probably

Thanks again

Graham


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

Date: 19 Feb 2004 23:54:17 -0800
From: v2af@yahoo.de (Alex F.)
Subject: Using perl over network (NFS)
Message-Id: <1e8fe2ae.0402192354.39217c5e@posting.google.com>

Dear all,

we have a PC-based server that works as a "perl-server" - that means
we only installed perl on that server and about 25 PCs run perl from
there without any problems (using TK and GD for example)...
- the only thing we did was setting the link (plus the search-path)
for perl-scripts to the remote server on every client.

Now we want to establish the same thing in another department that
uses HPUX11 -
we installed perl on one Unix-server and would like to run perl from
another Unix-machine...

If we try to do the same thing as on the PCs over NFS (Network File
System - on Unix) we get following error message:

user4@client3> /net/<server>/opt/perl/bin/perl tkmenu.pl
Can't locate Tk.pm in @INC (@INC contains:
/opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi /opt/perl/lib/5.6.1
/opt/perl/lib/site_perl/5.
6.1/PA-RISC1.1-thread-multi /opt/perl/lib/site_perl/5.6.1
/opt/perl/lib/site_perl .) at tkmenu.pl line 5.
BEGIN failed--compilation aborted at tkmenu.pl line 5.

of course running this TK-script on the "server" works fine!
TK-modules are installed there... it seems that perl searches for the
modules on the local machine

Now we donīt know
- if did some mistakes
- if using perl on Unix isnīt that simple as on PCs


Thanx
Alex


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

Date: Fri, 20 Feb 2004 09:32:34 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Using perl over network (NFS)
Message-Id: <SukZb.83878$jk2.432844@attbi_s53>

Alex F. wrote:

> user4@client3> /net/<server>/opt/perl/bin/perl tkmenu.pl
> Can't locate Tk.pm in @INC (@INC contains:
> /opt/perl/lib/5.6.1/PA-RISC1.1-thread-multi /opt/perl/lib/5.6.1
> /opt/perl/lib/site_perl/5.
> 6.1/PA-RISC1.1-thread-multi /opt/perl/lib/site_perl/5.6.1
> /opt/perl/lib/site_perl .) at tkmenu.pl line 5.
> BEGIN failed--compilation aborted at tkmenu.pl line 5.

Looks like you left out the obvious:
   root@client3# ln -s /net/$server/opt/perl /opt/perl
   user4@client3> set path=($path /opt/perl/bin)
   user4@client3> perl tkmenu.pl

	-Joe


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

Date: Fri, 20 Feb 2004 07:12:46 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why is Perl losing ground?
Message-Id: <pfcb30dh2e3foqm53anpoai77suljlpe9q@4ax.com>

Eric Schwartz wrote:

>Just be aware that hardly anyone uses those in practise, and it will
>make your programs more difficult to maintain in the future (as an
>otherwise experienced Perl programmer will hunt around forever to see
>where the #($*&! $PID is defined, etc.).  

There's no need for that FUD, because that's what it is. If people see
that English has been used, then they should be aware of the chance them
having to look it up. It's the same as with any other module used.

The problem I'm having with the English names, is that despite being
easy to read, they're very hard to write... was it $INPUT_LINENUMBER or
$INPUT_LINE_NUMBER?

>If you read the Camel book,
>it has some mnemonics for the special variables, such as '$<' is where
>you're coming FROM, '$>' is where you're going TO, and so on.

No need to read the Camel, as perlvar lists them too. And the English
names too.

>Learning the API will do you more good than learning 'use English;' in
>the long run, I believe.

That's what I do, I never use English.

Familiarity with the name of the special variable goes on par with
actual *use* of a variable. It's not enough to know what $| is for, you
should also know how to use it. It's the same with any other of these
special variables.

-- 
	Bart.


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

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


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