develooper Front page | perl.beginners | Postings from March 2012

RE: problem with nested regex matchs

Thread Previous | Thread Next
From:
Kronheim, David
Date:
March 8, 2012 23:35
Subject:
RE: problem with nested regex matchs
Message ID:
F25B3888E10C0F40B1AFEB8E63A27AB10827BC6596@ROCH-EXCH1.corp.pvt
Chris Stinemetz [chrisstinemetz@gmail.com]  wrote:
>Hello Shanmugam,
>
>Please start a new thread when you post a new topic.
>
>
>On Wed, Mar 7, 2012 at 5:14 PM, shanmugam m <bluepulse5577@gmail.com> wrote:
>> Hi,
>>  This is my first perl program..I'm getting wired errors.Please take a
>> look.
>>
>>

This line looks incorrect.
>> #!persist/pkg/bin/perl

Everything following the #! on the first line of a script should be the path to the Perl interpreter.
This could keep the Perl script program from being properly executed.
Frequently this shebang line looks like:
#!/usr/bin/perl

>> use diagnostics;
>> use warnings;
>
>always use the strict pragma especially when you are learning Perl.
>This will help you understand what is going on and also enforce you to
>use better programming practices such as lexical scope.
>use strict;
>
>>
>> open(MYINPUTFILE ,"/net/fallsroot/export/d100/m4/input_file");
>> open(MYOUTFILE, "> output_file");
>
>it is recommended to use a three argument filehandle
>open my $INPUTFILE, '<',$input_file or die "ERROR opening $input_file: $!";
>open my $OUTFILE, '>',$output_file or die "ERROR opening $output_file: $!";
>
>>
>> foreach $line (<MYINPUTFILE>){
>
>use a while loop to read one line at a time
>while ( my $line = $INPUTFILE ) {
>    chomp $line;
>
>>
>>    chomp($line);                    # remove the newline from $line.
>>                                     # do line-by-line processing.
>>    my @column1 = split("/\\/",$line);
>I'm not sure what you are trying to do here. Split will split on white
>space by default
>
>>    print MYOUTFILE $column1[5] ,"\t" ;
>you are trying to print the fifth element in the array @column1
>
>>    my @column2 = split("=",$line);
>now it looks like you are wanting to split $line again based on "="
>this would require you to reread the input file or create a better
>regex to capture everything you want in the first read
>
>>    print MYOUTFILE $column2[1]  ,"\n" ;
>>
>>    }
>>
>> close(MYOUTFILE);
>> Regards,
>> Shanmugam
>>
>
>--
HTH, David Kronheim

This communication is confidential.  Frontier only sends and receives email on the basis of the terms set out at http://www.frontier.com/email_disclaimer.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About