in reply to Removing Single Quote Problem

Another one without re's (Hm, I must be in mood for this..):
use warnings; use strict; my $text = "I think there's a quote in here..\n"; + my $p; substr( $text, $p - 1, 1 ) = '' while $p = index( $text, "'" ) + 1; + print $text;

Replies are listed 'Best First'.
Re^2: Removing Single Quote Problem
by Anonymous Monk on Feb 10, 2005 at 19:48 UTC
    Still having problems, here is more of the code
    foreach my $item (@{$rss->{'items'}}) { next unless defined($item->{'title'}) && defined($item->{'link +'}) && defined($item->{'description'}); $i += 1; next if $i > $feedcount; $item->{'description'}=~s/\n//gms; #$item->{'description'} =~ tr/\n'//d; $item->{'description'}=~s/'//gms; $output .= "'<font size=2><b><a target=\"_blank\" href=\"$item +->{'link'}\">$item->{'title'}</a></b></font><br /><font size=1>$item- +>{'description'}</font><br />'+\n"; }
      What problems? I would also recommend reading perlstyle
      next unless defined($item->{'title'}) && defined($item->{'link +'}) && defined($item->{'description'});
      could be written as
      next unless defined $item->{title} and defined $item->{link} and defined $item->{description};
      Also, why are you setting $output after trying to strip the singlequotes?

      Ordinary morality is for ordinary people. -- A.C.
        I like
        next if grep !defined, @$item{qw(title link description)};
        But it would be nice if the OP would do a better job of describing the problem(s).

        Caution: Contents may have been coded under pressure.
        How does your suggestion improve the code? Perlstyle doesn't say that we have to use "and" rather than "&&". I find "&&" more readable.