Dieser Post wurde aus meiner alten WordPress-Installation importiert. Sollte es Darstellungsprobleme, falsche Links oder fehlende Bilder geben, bitte einfach hier einen Kommentar hinterlassen. Danke.
Scalar (text) processiong is easy using Perl, but things get a bit more complicated if you need to handle huge data. One of m tickets at work included a special scalar text variable today.Imagine, you want to cut off $given_but_not_constant bytes from a huge scalar variable. My variable was not only unlimited in size, it will be several MB during daily business and could grow up to 2 GB or more in a normal use case.I avoid to copy it as long and often as possible but finally, something between two and 120 kB need to be cutted of the beginning for further processing.$y = substr($x,0,2048);$x = substr($x,2048);Would do the job, but clearly copy the reminder in memory. After looking at the splice perldoc and Scalar::Util just before trying out Regex memory and time costs, I discovered... substr!It turned out that substr can replace the substring by anything including an empty string "". It might be able to do this for a very long time - but I never noticed until today. Let's hope that it's more efficient than other ways.
My module also accepts blockwise input and will start flushing data when it's still small enough to handle everything without problems. If every developer here feeds in the data as it appears, everything will be fine, but you know developers... They try to do wrong things for the right reasons from time to time :-)
Noch keine Kommentare. Schreib was dazu