in reply to Re^3: how to retrieve data between <script></script> and save to an array
in thread how to retrieve data between <script></script> and save to an array

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,