Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: do does not read massive containing element w/ ' sign.

by nikolay (Beadle)
on Aug 22, 2015 at 20:36 UTC ( [id://1139549]=note: print w/replies, xml ) Need Help??


in reply to Re^3: do does not read massive containing element w/ ' sign.
in thread «Do» does not read an array containing element w/ «'» sign.

Thank you for your time.

1. the line from the file means my view on the data, and its actual organization. :o)

2. It is awesome to use the module then -- the only point i'm worrying about is its speed -- w/ the array (as it is now in my script) the data is already in the script (in its array) while w/ the module it seems to me it has to be processed as yet (i.e. to be inputted into array) -- what about tens of thousands of strings? -- Please let know, if had such experience. -- It's better to know before doing! :o).

3. Actually i've written the code already (this is from whence the _\'_ combination comes -- and it works only once: when adding new data to the file -- then, multiple times it works as is w/o checking/modification.

4. I did not edit. but had noted that will use array elements as regexps -- but what does it change?

5. No, i didn't see that, but i will go to read it. Thank you, again.

  • Comment on Re^4: do does not read massive containing element w/ ' sign.

Replies are listed 'Best First'.
Re^5: do does not read massive containing element w/ ' sign.
by karlgoethebier (Abbot) on Aug 23, 2015 at 10:01 UTC
    "...i'm worrying about is its speed...the data is already in the script...what about tens of thousands of strings?"

    I assume you expect/want qweqwe rtyr tyr \'asdasd fghfghfgh as output, right?

    Perhaps it might be an alternative to write your data to a file as JSON with something like this:

    use JSON::XS; my $data = [qw( qweqwe rtyr tyr \'asdasd fghfghfgh)]; my $json = encode_json $data; # to file...

    Then process your data line by line as usual:

    #!/usr/bin/env perl use JSON::XS; use strict; use warnings; use feature qw (say); # use Data::Dump; open my $fh, '<', 'data.dat' or die $!; while ( my $line = <$fh> ) { chomp $line; say nikolay( decode_json($line) ); } close $fh; sub nikolay { my $data = shift; join " ", @$data; # what ever... } __END__ karls-mac-mini:monks karl$ ./json.pl qweqwe rtyr tyr \'asdasd fghfghfgh ...

    Please see also JSON::XS, JSON and Benchmark.

    Edit: Link added.

    Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

      Thank you, Karl, but i think it is a lot of overhead for my script at run time. -- Suppose to run nikolay sub. 10 000 times! -- How it is now -- i like because it is already in array (ready to use): to be fed to reg.exp.

      Alright, i think we can finish here. -- I have learned a lot from all the answers! -- And that would have impact on my future PERL development. Thank you all!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-24 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found