From: C.DeRykus on 1 Jul 2010 00:53 On Jun 30, 9:08 pm, "C.DeRykus" <dery...(a)gmail.com> wrote: > On Jun 30, 4:56 pm, James Egan <jegan...(a)comcast.net> wrote: > > > ... > > A split'n-splice perhaps: > > my @f = split ' ', $dirline; > splice( @f, 0, 8 ); > print qq{@f} if @f > 1; > > This'll squeeze down multiple spaces though. > To avoid that: > > chomp $dirline; > my @f = split /(\s+)/x, $dirline; > splice( @f, 0, 16 ); > print join '',@f,"\n" if @f > 1; > I just spotted Ben's mention of potential spaces in other fields so this could be a portability issue. -- Charles DeRykus
From: Dr.Ruud on 1 Jul 2010 03:55 John Kelly wrote: > open DATA, 'data'; ITYM: open my $fh_data, "<", "data"; Under which rock were you the last 10 years? > @files = <DATA>; > foreach (@files) { > print; > } A for-loop? Make it a while. -- Ruud
From: Justin C on 1 Jul 2010 06:17 On 2010-07-01, John Kelly <jak(a)isp2dial.com> wrote: > On Wed, 30 Jun 2010 23:03:46 -0500, Tad McClellan <tadmc(a)seesig.invalid> > wrote: > [snip] >>If so, and if you truly believe that Uri is a troll, >>then please attempt to exert some self control and don't feed it! > > Why don't you ask Uri to ignore me. I'm not important, but he seems > obsessed with me. Mr Pot, may I introduce you to Mr Kettle.... Justin. -- Justin C, by the sea.
From: Justin C on 1 Jul 2010 07:14 On 2010-07-01, Uri Guttman <uri(a)StemSystems.com> wrote: >>>>>> "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. An observation (that may be erroneous) of the output of ls: The second to last field is always the time, which contains a colon. How about matching /:\d{2}\s+.*\s+.+\b/ ? #!/usr/bin/perl use strict; use warnings; while (<DATA>) { if (/:\d{2}\s+(.*\s+.+)\b/) { print $1, "\n"; } } __DATA__ -rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip -rwxrwxrwx 1 777 22000 9941 Jan 28 18:10 file2 onespace.zip -rwxrwxrwx 1 777 22000 3002969941 Jan 29 13:28 file3 two spaces.zip Justin. -- Justin C, by the sea.
From: John Kelly on 1 Jul 2010 07:55
On Thu, 01 Jul 2010 09:55:52 +0200, "Dr.Ruud" <rvtol+usenet(a)xs4all.nl> wrote: >John Kelly wrote: > >> open DATA, 'data'; > >ITYM: open my $fh_data, "<", "data"; > >Under which rock were you the last 10 years? > > >> @files = <DATA>; >> foreach (@files) { >> print; >> } > >A for-loop? Make it a while. The OP was not initially clear on what he wanted. So I threw something together and put it out there, to see if he would elaborate. At that early stage, starting a dialog was more important than providing elegant Perl code. Sometimes people wander into a newsgroup looking for ideas, and need a friendly helping hand more than elegant code. He seems to have disappeared though. I guess the mean people scared him away. -- Web mail, POP3, and SMTP http://www.beewyz.com/freeaccounts.php |