From: John Kelly on 30 Jun 2010 21:46 On Wed, 30 Jun 2010 21:08:27 -0400, "Uri Guttman" <uri(a)StemSystems.com> wrote: > JK> Try to relax. It's only Perl. Or does Perl make you tense. >no, just bad and/or useless perl makes me react. you seem to be a font >of it. i will correct your posted code whenever i feel like it. note >that others didn't even come close to your way off response to the same >ambiguous OP. and you still never answered my question, what was your >code trying to even show? reading and printing a file of line >(regardless of their being file names) doesn't do anything close to what >the OP wanted. so your analytical skills need to be honed as well. best >you sit back and not respond to most posts here until you have seen what >others have to say. Criticism is one thing. When it's mean and personal, it's trolling. Why would I want to follow the advice of a troll. -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php
From: John Kelly on 30 Jun 2010 21:55 On Wed, 30 Jun 2010 21:10:20 -0400, "Uri Guttman" <uri(a)StemSystems.com> wrote: > >> my $file; > >> (undef, undef, undef, undef, undef, undef, undef, undef, $file) = split ' ', $_, 9; > >> $file =~ / / and print "$file"; > >that is just poor code. do you want to count the undefs each time you do >something like that? and why is that last line checking for space? he >wants all the file names. That's not what he said. But trolls don't care what people say, do they. -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php
From: Ben Morrow on 30 Jun 2010 22:06 Quoth "Uri Guttman" <uri(a)StemSystems.com>: > >>>>> "BM" == Ben Morrow <ben(a)morrow.me.uk> writes: > > BM> ls -l output intentionally uses fixed-width columns, except for the > BM> filename. So > > normally that is true, but very large files can cause the name column to > be shifted over. some ls flavors or options will change the size to use > a suffix but you can't count on fixed width there. as i posted it is > best to assume fixed width until the size but that is always a number > with a possible size suffix so it is easy to match and the rest is the > file name. Meh. Yes, you're probably right. (Now I check ls(1), at least on my system, it appears most of the fields are variable-width.) Since modern systems (OS X, at least) allow user- and group names with spaces in, splitting on space doesn't work either. The correct answer, of course, is 'go back several steps and get the data in a more reasonable format'. Ben
From: John Kelly on 30 Jun 2010 22:19 On Wed, 30 Jun 2010 21:08:27 -0400, "Uri Guttman" <uri(a)StemSystems.com> wrote: > best you sit back and not respond to most posts here until you have > seen what others have to say The second "N" in NNTP means "news." If you don't have any news to share, maybe answering questions is all you can do. But don't expect everyone else to be like you. I sometimes have news to post. Which reminds me ... -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php
From: J�rgen Exner on 30 Jun 2010 22:24
James Egan <jegan473(a)comcast.net> wrote: >Assuming an array named @myfiles contained three elements like: > >-rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip >-rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip >-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip > > >I want to extract just the file which contain spaces to work with like: > >file1.zip >file2 onespace.zip >file3 two spaces.zip Easy. split() the line into its 9 elements at any non-empty sequence of spaces and then pick the last one: my $file = (split(/ +/, $_, 9))[8]; >How can I extract the file names which have spaces? I would run a grep afterwards and filter for those names that contain spaces. >I've been trying unsuccessfully with the glob function: > >foreach my $f (@myfiles) { > print join "\n",glob("*")' >} You seem to be very confused about what glob() is doing. jue |