thanks for the info, Actually I need to add /g besides smi. Here is the script and it works for the string I provided. Here is the code

my @script=(); open FILE, "content" or die "Couldn't open file: $!"; while (<FILE>){ $line .= $_; } close FILE; my $left = quotemeta '<script>'; my $right = quotemeta '</script>'; while( $line =~ /$left(.*?)$right/gsmi ){ push (@script, $1); }

But it will break if $line contains html page with other tags and following <script> contents, for example:

<html> <head> <script language="javascript" src="" id="scptMDtl"></script> <script language="javascript">var onWL=0;var oJS = new Object();</scri +pt> <script language="javascript"> var a_fInDelItms = 0; var a_fPrv = 1; var a_fTxt = 0; </script> </head> <body> <textarea id="txtBdy" class="w100 txtBdy" style="display:none"> This is a test. </textarea> <script language="javascript"> var a_sId = "RgAAAADz6rvTg9+xRIGTnTWlmKbHBwCeJ0LFThYQQaU\/Nvmo +3DG+AAACNa1IAABO5K\/6RD2SRbSFY4IMoQCbAAAAFHnvAAAJ"; var a_sCK = "TuSv+kQ9kkW0hWOCDKEAmwAAABXdNQ=="; </script> </body> </html>

could you please to see how to that by giving this long string, Thanks,


In reply to Re^4: how to retrieve data between <script></script> and save to an array by curd8341
in thread how to retrieve data between <script></script> and save to an array by curd8341

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.