On 9/17/05, Gary Kline <[EMAIL PROTECTED]> wrote: > > I scarfed up a slew of php files that are around 100 bytes > in strlen and with "\ " and other non-shell-friendly bytes. > Is there a way to use perl to chop off the first N bytes? > > For example, a file many be named 00001\ > 00002xyz\?00003=Test.php. What's the most logical way to > perl this file to "Test.php?
a script you run as: % script.pl * from the directory these files are in might look like: foreach $old (@ARGV) { $new = $old; $new =~ s/\W//g; rename $old, $new; } That would remove all non "word" characters in the filename. Perl defines word characters as A-Z 0-9 and underscores. or you could do something like this: foreach $old (@ARGV) { $old =~ /(\w+\.php)/; rename $old, $1; } which catches any series of one or more word characters, a period, and "php" in the variable $1. There are lots of options, sounds like you need a book on perl maybe... There is good online documentation here: http://perldoc.perl.org/perl.html Aaron _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "[EMAIL PROTECTED]"