FAQ
Hello,

I am writing perl on windows installing Activestate Perl and the code is
reading a text file and processing it,

the code what i use is...

##################################
use strict;
use warnings;

my $file_name="XXXXXXXX.txt";

open(FILE,"$file_name") || die "Not been Accessed";
while (<FILE>) {
print $_ "\n";

}

################################################

I get a wired output when i run the above code..

*Useless use of a constant in void context at gathercheck.pl line 9.
Can't use string ("2006/06/11 00:00:02 (7):(4480) t") as a symbol ref while
"str
ict refs" in use at gathercheck.pl line 11, <FILE> line 1.*

Some lines in the imput file is like the below,

2006/06/11 00:00:02 (7):(4480) tc1a-pgw-1m, Waiting for another gather on
REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
2006/06/11 00:00:02 (7):(5852) tc1a-pgw-1m, Waiting for another gather on
REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
2006/06/11 00:00:02 (7):(4492) tc1a-pgw-1m, Waiting for another gather on
REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M

Please help me out on the above as i am not able to understand the error
output..

Regards

Mazhar

Search Discussions

  • Prabu Ayyappan at Jun 14, 2006 at 12:24 pm

    On 6/14/06, Mazhar wrote:
    Hello,

    I am writing perl on windows installing Activestate Perl and the code is
    reading a text file and processing it,

    the code what i use is...

    ##################################
    use strict;
    use warnings;

    my $file_name="XXXXXXXX.txt";

    open(FILE,"$file_name") || die "Not been Accessed";
    while (<FILE>) {
    print $_ "\n";

    }

    ################################################

    I get a wired output when i run the above code..

    *Useless use of a constant in void context at gathercheck.pl line 9.
    Can't use string ("2006/06/11 00:00:02 (7):(4480) t") as a symbol ref
    while
    "str
    ict refs" in use at gathercheck.pl line 11, <FILE> line 1.*

    Some lines in the imput file is like the below,

    2006/06/11 00:00:02 (7):(4480) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
    2006/06/11 00:00:02 (7):(5852) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
    2006/06/11 00:00:02 (7):(4492) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M

    Please help me out on the above as i am not able to understand the error
    output..

    Regards

    Mazhar


    Hope this wil work (place a dot before \n(concatenation) in the print)

    #!/usr/bin/perl
    use strict;
    use warnings;
    my $file_name="XXXXXXX.txt";
    open(FILE,"$file_name") || die "Not been Accessed";
    while (<FILE>) {
    print $_."\n"; #place a dot before \n(concatenation)
    }


    --
    Prabu M A
  • Mr. Shawn H. Corey at Jun 14, 2006 at 12:27 pm

    On Wed, 2006-14-06 at 15:59 +0400, Mazhar wrote:
    Hello,

    I am writing perl on windows installing Activestate Perl and the code is
    reading a text file and processing it,

    the code what i use is...

    ##################################
    use strict;
    use warnings;

    my $file_name="XXXXXXXX.txt";

    open(FILE,"$file_name") || die "Not been Accessed";
    while (<FILE>) {
    print $_ "\n";
    print $_, "\n"; # print double-spaced
    # See `perldoc -f print`
    }

    ################################################

    I get a wired output when i run the above code..

    *Useless use of a constant in void context at gathercheck.pl line 9.
    Can't use string ("2006/06/11 00:00:02 (7):(4480) t") as a symbol ref while
    "str
    ict refs" in use at gathercheck.pl line 11, <FILE> line 1.*

    Some lines in the imput file is like the below,

    2006/06/11 00:00:02 (7):(4480) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
    2006/06/11 00:00:02 (7):(5852) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M
    2006/06/11 00:00:02 (7):(4492) tc1a-pgw-1m, Waiting for another gather on
    REPORTER_GATHER_MUTEX_FOR_TC1A_PGW_1M

    Please help me out on the above as i am not able to understand the error
    output..

    --
    __END__

    Just my 0.00000002 million dollars worth,
    --- Shawn

    "For the things we have to learn before we can do them, we learn by doing them."
    Aristotle

    * Perl tutorials at http://perlmonks.org/?node=Tutorials
    * A searchable perldoc is at http://perldoc.perl.org/
  • John W. Krahn at Jun 14, 2006 at 12:28 pm

    Mazhar wrote:
    Hello, Hello,
    I am writing perl on windows installing Activestate Perl and the code is
    reading a text file and processing it,

    the code what i use is...

    ##################################
    use strict;
    use warnings;

    my $file_name="XXXXXXXX.txt";

    open(FILE,"$file_name") || die "Not been Accessed";
    while (<FILE>) {
    print $_ "\n";
    print() is interpreting the value in $_ as a filehandle. You need to either
    supply a list to print:

    print $_, "\n";

    Or a single string:

    print "$_\n";

    Or alternately set the output record separator:

    $\ = "\n";
    while ( <FILE> ) {
    print;



    John
    --
    use Perl;
    program
    fulfillment
  • Mazhar at Jun 14, 2006 at 1:56 pm
    Thanks everybody for the support..

    it is working fine..

    Regards
    Mazhar

    On 6/14/06, John W. Krahn wrote:

    Mazhar wrote:
    Hello, Hello,
    I am writing perl on windows installing Activestate Perl and the code is
    reading a text file and processing it,

    the code what i use is...

    ##################################
    use strict;
    use warnings;

    my $file_name="XXXXXXXX.txt";

    open(FILE,"$file_name") || die "Not been Accessed";
    while (<FILE>) {
    print $_ "\n";
    print() is interpreting the value in $_ as a filehandle. You need to
    either
    supply a list to print:

    print $_, "\n";

    Or a single string:

    print "$_\n";

    Or alternately set the output record separator:

    $\ = "\n";
    while ( <FILE> ) {
    print;



    John
    --
    use Perl;
    program
    fulfillment

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>

  • JupiterHost.Net at Jun 14, 2006 at 3:38 pm
    Hello,
    use strict;
    use warnings;
    Excellent use of those :)
    my $file_name="XXXXXXXX.txt";

    open(FILE,"$file_name") || die "Not been Accessed";
    Good that you checked for failure, why not also report the error ...

    Also, don't double quote strings that have nothing to be interpolated or
    are just a single variable.

    open my $file_fh, $file_name or die "Open $file_name failed: $!";
    while (<FILE>) {
    print $_ "\n";

    }
    You're trying to print a newline to the variable $_ which is just wonky :)

    while(<$file_fh>) {
    print "$_\n"; # or way more ugly and convolutedly: print $_ . "\n";
    }

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedJun 14, '06 at 11:59a
activeJun 14, '06 at 3:38p
posts6
users5
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase