in reply to stripping characters from a string

Try this,

use strict; use warnings; my $string = "Good O'l Time"; $string =~ y/ '/\_/d; print $string;

Regards,
Velusamy R.


eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

Replies are listed 'Best First'.
Re^2: stripping characters from a string
by ayrnieu (Beadle) on Mar 06, 2006 at 09:41 UTC

    I'd prefer this, actually:

    for ($string) { tr/ '/_/d; print }

      ayrnieu, OP's need

      Good_Ol_Time

      but your output shows

      Good_O l_Time

      As per perlfunc - Perl builtin functions tutorial.

      y///
      The transliteration operator. Same as tr///.

      Updated: ayrnieu updated his answer without proper information.

      Regards,
      Velusamy R.


      eval"print uc\"\\c$_\""for split'','j)@,/6%@0%2,`e@3!-9v2)/@|6%,53!-9@2~j';

        ah, "and remove any '". I know what y/// is, I just don't know why anyone would use it. Why do you have a \ ?