while(<>) { s#^([^/]+).*#$1#; print; } #### while(<>) { print((split '/')[0], "\n"); }