Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Perl prints only last line of array

by RMGir (Prior)
on Jun 22, 2014 at 00:09 UTC ( [id://1090803]=note: print w/replies, xml ) Need Help??


in reply to Perl not printing any special characters in array

I think that your problem is that you're re-creating the file for every line.

Try moving the "open HTML" line out above the loops...

# You don't want to do this for each line! open HTML ">C:/Users/jk/Desktop/fun/perl/$site.html"; foreach(<@node>) { $death=$_; print HTML "$death\n"; }

Mike

Replies are listed 'Best First'.
Re^2: Perl prints only last line of array
by myfrndjk (Sexton) on Jun 22, 2014 at 10:51 UTC

    Hi Mike, Thanks for your help ! I modified the code as you suggested it works fine.But now i have another issue .The crawl content doesn't contain any special characters.All special characters are replaced by some junk values. for example (€)euro is printed as (-aA). I am scraping the site which is full of special characters and German language. most of the crawled content are different from original content. Thanks again, jk

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-29 11:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found