Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Strip first name from string

by 2teez (Vicar)
on Jan 29, 2014 at 07:58 UTC ( [id://1072458]=note: print w/replies, xml ) Need Help??


in reply to Re: Strip first name from string
in thread Strip first name from string

While I agree with your statement that ..The trouble with this sort of problem statement is that it is subject to all kinds of counter-exemplification I will want to second toolic mention of Lingua::EN::NameParse.

And for a one off name like you mentioned one could do this:

print sprintf 'Mr. %3$s' => split/ / => "G. Gordon Liddy Sr., PhD"; #M +r. Liddy

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^3: Strip first name from string
by hippo (Bishop) on Jan 29, 2014 at 09:17 UTC

    While I understand what the fat commas are doing in there (I think), it's more perplexing why you used print sprintf instead of just printf. What am I missing here?

      FWIW , usually, when one goes the more verbose route in posts, its to help the noobs, for example
      my $foo = sprintf ...; print "$foo\n";

      So  print sprintf ...

      Its kinda like using qq{} and q{} for oneliners --- makes the readers life more copy/paste and less editing :)

      Just my impression

      hi hippo,
      ..it's more perplexing why you used print sprintf instead of just printf. What am I missing here?..

      Apart from printf doc. stating that printf and print sprintf(FORMAT, LIST) are equivalent. Atleast it's obvious from the usage of sprintf that one wants a formatted string.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1072458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-04-24 11:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found