Command line option for split
Command line option for split
am 17.09.2007 19:32:41 von xlue897
Hi,
Can we specify the [limit] option for split in command line? For perl
code, we can do things like
@F=split /pattern/, expr, limit;
in command line, we can express pattern like
perl -F"/pattern/" -anle '...'
but how can we specify the limit in command line?
Thanks,
Steven
Re: Command line option for split
am 17.09.2007 21:01:40 von Michele Dondi
On Mon, 17 Sep 2007 10:32:41 -0700, xlue897@rogers.com wrote:
>Can we specify the [limit] option for split in command line? For perl
>code, we can do things like
No, I don't really think so.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
Re: Command line option for split
am 17.09.2007 21:25:46 von Dummy
xlue897@rogers.com wrote:
>
> Can we specify the [limit] option for split in command line?
No.
> For perl code, we can do things like
>
> @F=split /pattern/, expr, limit;
That is what you are going to have to do.
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
Re: Command line option for split
am 18.09.2007 16:41:53 von xlue897
On Sep 17, 3:01 pm, Michele Dondi wrote:
> On Mon, 17 Sep 2007 10:32:41 -0700, xlue...@rogers.com wrote:
> >Can we specify the [limit] option for split in command line? For perl
> >code, we can do things like
>
> No, I don't really think so.
>
> Michele
If there are fields with trailing empty fields, Perl cannot get the
correct number of fields using command line options. So Perl is not
convenient and accurate in getting fields numbers with command line
options. And we should avoid using command line options to try to get
fields number.
Re: Command line option for split
am 18.09.2007 18:09:22 von Michele Dondi
On Tue, 18 Sep 2007 07:41:53 -0700, xlue897@rogers.com wrote:
>If there are fields with trailing empty fields, Perl cannot get the
>correct number of fields using command line options. So Perl is not
>convenient and accurate in getting fields numbers with command line
>options. And we should avoid using command line options to try to get
>fields number.
It seems sensible and reasonable: after all command line options are
there for small tasks and not to solve all the problems that one may
face in Perl. In fact they would be better adopted for relatively
small scripts. In longer ones, adding a pair of lines for an explicit
loop or a split() makes things easier to follow and doesn't hurt much.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,