Re: awk's NF in Perl
From: Jim Gibson (jgibson_at_mail.arc.nasa.gov)
Date: 03/05/04
- Next message: Jim Gibson: "Re: check if another process on my perl program is running"
- Previous message: JSM: "Re: Imposing a timeout on the <> operator - is this possible?"
- In reply to: Thorsten Gottschalk: "awk's NF in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 05 Mar 2004 12:04:01 -0800
In article <beb38f7.0403050405.6c3988df@posting.google.com>, Thorsten
Gottschalk <iqrity@web.de> wrote:
> Hi all,
>
> I want to have the awk NF variable in Perl. Yes I know there are many
> hints for that. But I only found the folloing:
>
> #!/usr/bin/perl
use strcit:
use warnings;
>
> $ln="1;2;3;4;;;;;;10";
my $ln = "1;2;3;4;;;;;;;";
> $nf = @records = split(/;/, $ln);
my $nf = my @records = split(/;/, $ln, -1 );
> print "NF:$nf\n";
> $"=";";
> print "@records\n";
>
> output:
> NF:10
> 1;2;3;4;;;;;;10
>
> so it looks good, now I change the script a little bit, look here:
>
> # change this line in script:
> $ln="1;2;3;4;;;;;;";
>
> output:
> NF:4
> 1;2;3;4
NF:10
1;2;3;4;;;;;;;
>
> So now you can see the trick with spilt did not work any time. Are
> there any other suggestions out there?
>
> ciao
> Thorsten
Check the documentation on split:
perldoc -f split
FYI: this newgroup is defunct. Try comp.lang.perl.misc in the future.
- Next message: Jim Gibson: "Re: check if another process on my perl program is running"
- Previous message: JSM: "Re: Imposing a timeout on the <> operator - is this possible?"
- In reply to: Thorsten Gottschalk: "awk's NF in Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|