in reply to get a text out from a string

Use substitute

my $productcode = "FCLA"; $productcode =~ s/.*FCL.*/FCL/; print $producecode

Replies are listed 'Best First'.
Re^2: get a text out from a string
by adrive (Scribe) on Feb 28, 2008 at 01:15 UTC
    thanks guys :) that'll do
Re^2: get a text out from a string
by ack (Deacon) on Feb 28, 2008 at 23:08 UTC

    The only problem would be if what adrive wanted was to print out the original string (e.g., FCLA, FCLXXX, etc.) if it contains the user-specified substring (e.g., FCL).

    The solution with substitution would destroy the original string so that what would be printed would just be the sought-after substring.

    Of course maybe that what was wanted...I couldn't tell from the original qustion.

    ack Albuquerque, NM