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

Re^4: Parsing with RegEx into Array

by mr_p (Scribe)
on Jun 25, 2010 at 22:09 UTC ( #846616=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Parsing with RegEx into Array
in thread Parsing with RegEx into Array

What does the 's' mean? Can you point me to any documentation on this if u know of?

I am also unable to print the utf8. Below is my code.

my $curLink1 = utf8::decode($curLink); # Use UNICODE semantics my $item1 = utf8::decode($item); my $fileName="/tmp/out_file.html"; use open OUT => ':utf8'; open OUT_FILE, "> $fileName"; print OUT_FILE "<item>$item1</item>"; close OUT_FILE; #open (my $fh, '>:encoding (UTF-8)', $fileName); #print $fh "<item>$item1</item>"; #close $fh;

I tried the commented code too. I also tried to print $item, which is encoded. $item or $item1 does not print in file, but it does print on STDOUT.

Thanks for you help.


Comment on Re^4: Parsing with RegEx into Array
Download Code
Re^5: Parsing with RegEx into Array
by Corion (Pope) on Jun 25, 2010 at 22:16 UTC

    You never check whether opening the output file succeeded. See open. For your original query about regular expressions, see perlre and maybe perlretut.

      I did have || die, but I removed it because when I put the code in perlmonks.
Re^5: Parsing with RegEx into Array
by ikegami (Pope) on Jun 25, 2010 at 22:19 UTC

    For the match operator. "/s" causes "." to match any byte/character. Without it, "." matches any byte/character except 0x0A/newline. Operators are documented in perlop. There's probably more info perlre.

    open(my $fh_in, '<:encoding(UTF-8)', ...) or die ...; ... my @allItems = $file_in =~ m{<item>(.*?)</item>}sg; ... open(my $fh_out, '>:encoding(UTF-8)', ...) or die ...; print $fh_out ...;
      Is that the same thing I have for writing file. The code that is commented.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2015-07-05 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls