Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: print failing to output anything

by Roy Johnson (Monsignor)
on Nov 12, 2003 at 20:57 UTC ( [id://306632]=note: print w/replies, xml ) Need Help??


in reply to print failing to output anything

Some comments:
my $filename = ""; my $outputfile = "";
No real need to declare and initialize these here. You can do it when you get the input:
my $filename = <STDIN>; chop ($filename);
Should use chomp, instead.

Then you make the computer read the whole file and do a bunch of matches that you completely ignore:

while (<INFILE>) #read the input file { while ( /(\w['\w-]*)/g ){ #if we have a "word"; }

Then a whole bunch of (re-)declarations and initializations, several of which were pointless, then some attempts to match on $_, but none of them happen because it's empty now.

The main problem is that you haven't wrapped your file-reading loop around the code that's supposed to be doing the work. Apart from that, you've made some sub-optimal decisions about what to use: the foreach's should probably be whiles, and the patterns should be qr//'d instead of double-quoted.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://306632]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-24 04:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found