Can an Ass Post From Dejanews?
ptimmins at netserv.unmc.edu
ptimmins at netserv.unmc.edu
Thu Nov 12 11:13:25 CST 1998
* * TESTING * *
Well? Can spammers send from dejanews using a valid mailing
list name? The message below was attached by dejanews automatically
and sent to hfb at happyfunball.pm.org with the 'from' filled in
as ptimmins at netserv.unmc.edu . Will it be passed on to the list?
* * TESTING * *
------------------------------------------------------------------------------
This message was forwarded to you from Deja News by ptimmins at netserv.unmc.edu.
Deja News, the discussion network, offers free web-based access to more than
50,000 high-quality discussion forums. Come and visit us on the web at
http://www.dejanews.com/=zzz_maf/
------------------------------------------------------------------------------
Sponsored by: Audio Book Club
Join and get 4 bestselling audiobooks 1c
http://www.audiobookclub.com/micro/home.asp?AID=S036L004B009
------------------------------------------------------------------------------
(beginning of original message)
Subject: Re: calling by reference
From: ptimmins at netserv.unmc.edu (Patrick Timmins)
Date: 1998/11/11
Newsgroups: comp.lang.perl.misc
In article <72ch8j$mnm$1 at cnn.cc.biu.ac.il>,
"Avshi Avital" <avitala at macs.biu.ac.il> wrote:
> hi guys (and gals),
> the following sub excepts a string and returns the last word:
>
> sub get_word {
> $_[0] =~ s/\b([^\s]*?)\s*$//;
> return $1;
> }
>
> obviously it doesn't change the value of the input string (though it
> DOES change $_[0] - locally).
> what if I wanted it to change it's value (that is: return the last word,
> and shorten the input string by one word)?
> i suppose it's some use of reference (\)?
You could shift in the $input to sub get_word using the same
variable name, thus overwriting it with the subroutine's transformation.
Then just return the part you want as usual (note I changed your regex):
$input = "Bill Clinton is Damned Good!";
print "Before : $input\n";
$trimmed = get_word($input);
print "After: $input\n";
print "$trimmed\n";
sub get_word {
$input = shift;
$input =~ s/(.*)\s+([\S]+)\s*$/$1/;
return $2;
}
__END__
gives:
Before : Bill Clinton is Damned Good!
After: Bill Clinton is Damned
Good!
Hope that helps.
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
(end of original message)
------------------------------------------------------------------------------
You can view this message and the related discussion by following this link:
http://www.dejanews.com/=zzz_maf/dnquery.xp?search=thread&svcclass=dnserver&recnum=%3c72d7db$j39$1@nnrp1.dejanews.com%3e%231/1
We hope to see you soon at Deja News, the discussion network.
http://www.dejanews.com/=zzz_maf/
More information about the Hfb-pm
mailing list