newbie question

Discussion in 'Perl Misc' started by fzhang@calamos.com, Mar 1, 2006.

  1. Guest

    What does the following do?

    ($input) = $input =~ /^\s*(.+)\s*$/;

    Thanks.

    Frank
    , Mar 1, 2006
    #1
    1. Advertising

  2. Keith Keller Guest

    Please put the subject of your post in the Subject: of your post.

    On 2006-03-01, <> wrote:
    > What does the following do?
    >
    > ($input) = $input =~ /^\s*(.+)\s*$/;


    Have you read perldoc perlre? Have you read the Posting Guidelines that
    are posted here frequently?

    --keith

    --
    -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
    Keith Keller, Mar 1, 2006
    #2
    1. Advertising

  3. wrote in news:1141246133.873937.255500
    @t39g2000cwt.googlegroups.com:

    > Subject: newbie question


    Please read the posting guidelines for this group.

    > What does the following do?
    >
    > ($input) = $input =~ /^\s*(.+)\s*$/;


    It matches $input in list context and stores the captured match in
    $input.

    The purpose seems to be to trim leading and trailing spaces, but it
    fails because the capture group matches any character. See:

    D:\Home\asu1\UseNet\clpmisc> cat r.pl
    #!/usr/bin/perl

    use warnings;
    use strict;

    my $s = "\t \t \n test \n\n\n";

    ($s) = $s =~ m{ \A \s* (.+) \s* \z}x;

    print "-$s-\n";

    __END__

    D:\Home\asu1\UseNet\clpmisc> r
    -test -

    Compare that to:

    D:\Home\asu1\UseNet\clpmisc> cat r.pl
    #!/usr/bin/perl

    use warnings;
    use strict;

    my $s = "\t \t \n test \n\n\n";

    ($s) = $s =~ m{ \A \s* (\S+) \s* \z}x;

    print "-$s-\n";

    __END__

    D:\Home\asu1\UseNet\clpmisc> r
    -test-

    Note that this will not work if $s is

    $s = ""\t \t \n test me \n\n\n";

    A better way to trim leading and trailing spaces in this case would be:

    $s =~ s{\A\s+}{};
    $s =~ s{\s+\z}{};

    Sinan


    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Mar 1, 2006
    #3
  4. UkJay Guest

    "Keith Keller" <-francisco.ca.us> wrote in message
    news:eek:-francisco.ca.us...
    > Please put the subject of your post in the Subject: of your post.
    >


    He did Keith, next you will be wanting the whole message there as well !



    --
    Best Regards,
    James (ukjay)

    http://www.ukjay.co.uk

    Garden WebCam,Photography,Competitions,Weather (AWS)
    UkJay, Mar 2, 2006
    #4
  5. "UkJay" <> wrote in
    news:du68g8$rdb$:

    >
    > "Keith Keller" <-francisco.ca.us> wrote in
    > message news:eek:-francisco.ca.us...
    >> Please put the subject of your post in the Subject: of your post.
    >>

    >
    > He did Keith,


    No he did not.

    Please read the posting guidelines.

    > next you will be wanting the whole message there as well


    On second thought, bye!

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
    A. Sinan Unur, Mar 2, 2006
    #5
  6. UkJay Guest

    "A. Sinan Unur" <> wrote in message
    news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    > "UkJay" <> wrote in
    > news:du68g8$rdb$:
    >
    >>
    >> "Keith Keller" <-francisco.ca.us> wrote in
    >> message news:eek:-francisco.ca.us...
    >>> Please put the subject of your post in the Subject: of your post.
    >>>

    >>
    >> He did Keith,

    >
    > No he did not.
    >


    Yes he did
    It was a NEWBIE QUESTION
    and his question was in the message!


    --
    Best Regards,
    James (ukjay)

    http://www.ukjay.co.uk

    Garden WebCam,Photography,Competitions,Weather (AWS)
    UkJay, Mar 2, 2006
    #6
  7. Anno Siegel Guest

    UkJay <> wrote in comp.lang.perl.misc:
    >
    > "A. Sinan Unur" <> wrote in message
    > news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    > > "UkJay" <> wrote in
    > > news:du68g8$rdb$:
    > >
    > >>
    > >> "Keith Keller" <-francisco.ca.us> wrote in
    > >> message news:eek:-francisco.ca.us...
    > >>> Please put the subject of your post in the Subject: of your post.
    > >>>
    > >>
    > >> He did Keith,

    > >
    > > No he did not.
    > >

    >
    > Yes he did
    > It was a NEWBIE QUESTION
    > and his question was in the message!


    Wrong. The message is about a substitution operation, not a newbie
    question. "Substitution Operation" would be an appropriate subject,
    "newbie question" isn't.

    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.
    Anno Siegel, Mar 2, 2006
    #7
  8. UkJay Guest

    "Anno Siegel" <-berlin.de> wrote in message
    news:du6dq8$ero$-Berlin.DE...
    > UkJay <> wrote in comp.lang.perl.misc:
    >>
    >> "A. Sinan Unur" <> wrote in message
    >> news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    >> > "UkJay" <> wrote in
    >> > news:du68g8$rdb$:
    >> >
    >> >>
    >> >> "Keith Keller" <-francisco.ca.us> wrote in
    >> >> message news:eek:-francisco.ca.us...
    >> >>> Please put the subject of your post in the Subject: of your post.
    >> >>>
    >> >>
    >> >> He did Keith,
    >> >
    >> > No he did not.
    >> >

    >>
    >> Yes he did
    >> It was a NEWBIE QUESTION
    >> and his question was in the message!

    >
    > Wrong. The message is about a substitution operation, not a newbie
    > question. "Substitution Operation" would be an appropriate subject,
    > "newbie question" isn't.
    >
    > Anno

    Sorry Anno I don't fully agree with that...
    The poster thought it prudent to advise n.g. readers that his question was
    of a simple nature.
    I get so angry with pedantic replies about posts here! So this is my final
    reply on this subject,
    you carry on if you like, but I have had my say, and am far too busy to
    play!
    Ok I'll settle for newbie question - Substitution Operation :)


    --
    Best Regards,
    James (ukjay)

    http://www.ukjay.co.uk

    Garden WebCam,Photography,Competitions,Weather (AWS)
    UkJay, Mar 2, 2006
    #8
  9. Ian Wilson Guest

    UkJay wrote:
    > "A. Sinan Unur" <> wrote in message
    > news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    >
    >>"UkJay" <> wrote in
    >>news:du68g8$rdb$:
    >>
    >>>"Keith Keller" <-francisco.ca.us> wrote in
    >>>message news:eek:-francisco.ca.us...
    >>>
    >>>>Please put the subject of your post in the Subject: of your post.
    >>>
    >>>He did Keith,

    >>
    >>No he did not.
    >>

    >
    > Yes he did
    > It was a NEWBIE QUESTION
    > and his question was in the message!


    The posting guidelines for this newsgroup
    (http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html) say

    "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"


    http://www.catb.org/~esr/faqs/smart-questions.html#bespecific gives
    similar good advice.
    Ian Wilson, Mar 2, 2006
    #9
  10. UkJay wrote:
    > "Anno Siegel" <-berlin.de> wrote in message
    > news:du6dq8$ero$-Berlin.DE...
    >
    >>UkJay <> wrote in comp.lang.perl.misc:
    >>
    >>>"A. Sinan Unur" <> wrote in message
    >>>news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    >>>
    >>>>"UkJay" <> wrote in
    >>>>news:du68g8$rdb$:
    >>>>
    >>>>
    >>>>>"Keith Keller" <-francisco.ca.us> wrote in
    >>>>>message news:eek:-francisco.ca.us...
    >>>>>
    >>>>>>Please put the subject of your post in the Subject: of your post.
    >>>>>>
    >>>>>
    >>>>>He did Keith,
    >>>>
    >>>>No he did not.
    >>>>
    >>>
    >>>Yes he did
    >>>It was a NEWBIE QUESTION
    >>>and his question was in the message!

    >>
    >>Wrong. The message is about a substitution operation, not a newbie
    >>question. "Substitution Operation" would be an appropriate subject,
    >>"newbie question" isn't.
    >>
    >>Anno

    >
    > Sorry Anno I don't fully agree with that...
    > The poster thought it prudent to advise n.g. readers that his question was
    > of a simple nature.


    So, what distinguishes "newbie question" from "newbie question" from
    "newbie question" from ...?
    Maybe others have a "newbie question" about dynamic scoping! Where
    should they look for an answer?
    If I have a "Simple question" about the substitution operator, where
    should I look for an answer?

    Most, if not all newsreaders, first give you a list of subject lines to
    choose articles from. Having a subject line that clearly states the
    subject of the article
    1. allows me to skip questions that I surely will be unable to answer
    2. allows me to peek into threads that may enlighten me on certain subjects.

    > I get so angry with pedantic replies about posts here! So this is my final
    > reply on this subject,
    > you carry on if you like, but I have had my say, and am far too busy to
    > play!
    > Ok I'll settle for newbie question - Substitution Operation :)


    Much better!

    My 2cts as a co-reader and potential answerer,
    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
    Josef Moellers, Mar 2, 2006
    #10
  11. Ian Wilson Guest

    Ian Wilson <> trolled:

    > The posting guidelines for this newsgroup
    > (http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html) say


    > "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"



    > http://www.catb.org/~esr/faqs/smart-questions.html#bespecific gives
    > similar good advice.


    Holy ****, are you guys ever anal! I have never seen anything like
    this before. "Choosing Good Subject Lines."

    Hilarious!

    cordially, as always,

    rm
    Ian Wilson, Mar 2, 2006
    #11
  12. Ian Wilson wrote:
    > Ian Wilson <> trolled:
    >
    >
    >>The posting guidelines for this newsgroup
    >>(http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html) say

    >
    >
    >> "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"

    >
    >
    >
    >>http://www.catb.org/~esr/faqs/smart-questions.html#bespecific gives
    >>similar good advice.

    >
    >
    > Holy ****, are you guys ever anal! I have never seen anything like
    > this before. "Choosing Good Subject Lines."


    No need to use four letter words (d'ya know: "UNIX" is a four letter
    word? B-{).

    You might want to read RFC1178 ;-)

    Josef, who prefers RFCs 1149 and 2549
    --
    Josef Möllers (Pinguinpfleger bei FSC)
    If failure had no penalty success would not be a prize
    -- T. Pratchett
    Josef Moellers, Mar 2, 2006
    #12
  13. choice of Subject (was Re: newbie question)

    UkJay <> wrote:
    >
    > From: "UkJay" <>



    Please choose one posting address and stick with it.


    > "A. Sinan Unur" <> wrote in message
    > news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    >> "UkJay" <> wrote in
    >> news:du68g8$rdb$:
    >>
    >>>
    >>> "Keith Keller" <-francisco.ca.us> wrote in
    >>> message news:eek:-francisco.ca.us...
    >>>> Please put the subject of your post in the Subject: of your post.
    >>>>
    >>>
    >>> He did Keith,

    >>
    >> No he did not.
    >>

    >
    > Yes he did
    > It was a NEWBIE QUESTION



    His post was not _about_ newbie questions.


    > and his question was in the message!



    Nobody said, or even expected, that the question be in the Subject.

    Only that the Subject give some indication of what the post
    was _about_.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 2, 2006
    #13
  14. choosing a useful Subject header (was Re: newbie question)

    UkJay <> wrote:
    >
    > "Anno Siegel" <-berlin.de> wrote in message
    > news:du6dq8$ero$-Berlin.DE...
    >> UkJay <> wrote in comp.lang.perl.misc:
    >>>
    >>> "A. Sinan Unur" <> wrote in message
    >>> news:Xns977A2301FE25Dasu1cornelledu@127.0.0.1...
    >>> > "UkJay" <> wrote in
    >>> > news:du68g8$rdb$:
    >>> >
    >>> >> "Keith Keller" <-francisco.ca.us> wrote in
    >>> >> message news:eek:-francisco.ca.us...
    >>> >>> Please put the subject of your post in the Subject: of your post.
    >>> >>
    >>> >> He did Keith,
    >>> >
    >>> > No he did not.
    >>>
    >>> Yes he did
    >>> It was a NEWBIE QUESTION


    >> Wrong. The message is about a substitution operation, not a newbie
    >> question.


    > Sorry Anno I don't fully agree with that...



    Then you are in the vast minority.

    Having 50 threads about "newbie question" that are about 50 different
    aspects of Perl help neither someone searching for a problem similar
    to theirs, nor to folks looking for questions that they can answer.

    The Subject header is like a book's index. Nobody will be able
    to find what they are looking for if every indexed entry is
    the same.


    > The poster thought it prudent to advise n.g. readers that his question was
    > of a simple nature.



    That's fine, but he should still include what the simple question
    is _about_.

    People that know about that subject are much more likely to read
    the question when they know that it is about something that they
    might be able to answer.


    > I get so angry with pedantic replies about posts here!



    That's fine, but what does it have to do with replies that
    are teaching something widely valuable rather than something
    of narrow focus?

    Putting the subject of your article in the Subject of your
    article is not being pedantic, it is helping the OP to draw
    in readers familar with that subject, and allows peers with
    a similar problem to find previous discussions of that problem.


    > So this is my final
    > reply on this subject,



    On the subject of "newbie question"?


    > you carry on if you like, but I have had my say,



    People will be hurt if they do as you said.

    Please try saying things that will be helpful rather than hurtful.


    > Ok I'll settle for newbie question - Substitution Operation :)



    Then the OP could have been helped even more.

    Subject: Substitution Operation - simple question

    would get more folks to read the article than your proposed Subject,
    increasing the OP's chances of getting an answer.

    Consider these article scoring rules:

    % red flag subjects
    Score:: -5000
    Subject: newbie

    % interesting subjects
    Score:: 9000
    Subject: beginner


    I expect that 1st one to be a rather common scorerule.

    Why do you suppose that "newbie" is scored down while "beginner"
    is scored up?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 2, 2006
    #14
  15. At 2006-03-01 04:02PM, A. Sinan Unur <> wrote:
    > my $s = "\t \t \n test \n\n\n";
    > ($s) = $s =~ m{ \A \s* (.+) \s* \z}x;
    > print "-$s-\n";
    > -test -


    Although all trailing spaces would be trimmed if the capturing
    expression was not greedy:
    ($s) = $s =~ m{ \A \s* (.+?) \s* \z}x;

    --
    Glenn Jackman
    Ulterior Designer
    Glenn Jackman, Mar 2, 2006
    #15
  16. Dr.Ruud Guest

    Glenn Jackman schreef:

    > ($s) = $s =~ m{ \A \s* (.+?) \s* \z}x;


    If there were only spaces in the line, one would survive.
    If there were no spaces at both ends, a lot of work would be done to
    achieve exactly nothing.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
    Dr.Ruud, Mar 2, 2006
    #16
  17. Ian Wilson <> wrote:


    Are you "Ian Wilson" masquerading as "Roger Maynard",
    or are you "Roger Maynard" masquerading as "Ian Wilson"?

    Why are you masquerading at all?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Mar 2, 2006
    #17
  18. Ian Wilson Guest

    Re: distinguishing trolls from non-trolls on CLPM

    Tad McClellan wrote:
    > Ian Wilson <> wrote:
    > > <snip: typical RM posting>

    >
    > Are you "Ian Wilson" masquerading as "Roger Maynard",


    I'd probably muddle up his style with XL and r0's.
    Ian Wilson, Mar 3, 2006
    #18
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry C.
    Replies:
    8
    Views:
    214
    Uri Guttman
    Nov 23, 2003
  2. Kruno Saho
    Replies:
    0
    Views:
    129
    Kruno Saho
    Apr 7, 2013
  3. Dave Angel
    Replies:
    0
    Views:
    113
    Dave Angel
    Apr 7, 2013
  4. rusi
    Replies:
    0
    Views:
    102
  5. Miki Tebeka
    Replies:
    0
    Views:
    76
    Miki Tebeka
    Apr 7, 2013
Loading...

Share This Page