in reply to matching substring in url

Sometimes Perl is not the right tool for the job. You are starting an entire instance of perl just for a regex match, when sed will do:

echo "$XXX" | sed -e 's/;arg=.*$//' -e 's!^.*/!!'

On my box, simply running perl -e 1 takes longer than the above sed command. For a shell script, these differences matter.

Perl oneliners are great at the prompt, but if you are putting them into a shell script, you should probably move the entire script to Perl.

Replies are listed 'Best First'.
Re^2: matching substring in url
by cioperl (Novice) on Nov 09, 2019 at 02:21 UTC
    you have a good point jcb. For simple one-liners sed will do. Thanks!