extract

How can I write a Perl script to extract the source code of each subroutine in a Perl package?

痞子三分冷 提交于 2019-11-28 10:20:32
Given a Perl package Foo.pm, e.g. package Foo; use strict; sub bar { # some code here } sub baz { # more code here } 1; How can I write a script to extract the textual source code for each sub, resulting in a hash: $VAR1 = { 'bar' => 'sub bar { # some code here }', 'baz' => 'sub baz { # more code here }' }; I'd like to have the text exactly as it appears in the package, whitespace and all. Thanks. PPI is kind of a pain to work with at the very first; the documentation is not good at telling you which class documents which methods shown in the examples. But it works pretty well: use strict; use

Extracting data from HTML using PHP and xPath

久未见 提交于 2019-11-28 09:48:20
问题 I am trying to extract data from a webpage to insert it to a database. The data I'm interested in is in the div's which have a class="company". On one webpage there are 15 or less div's like that, and there are many pages I am trying to extract this data from. For this reason I am trying to find a automatic solution for data extraction. The div with a class="company" is as follows (there are 15 or less divs like this on one page with different data): <div class="company" id="company-6666"> <!

Find and read specific string from config file with Pascal Script in Inno Setup

时间秒杀一切 提交于 2019-11-28 08:46:02
问题 I have quite long config file and I need to extract specific strings from the file. What I want to extract/read is InstallDir for specific number position e.g. for 20540. I know how to find string in INI or XML, but cannot handle this form of file. Piece of the file that shows structure: "212280" { "InstallDir" "D:\\XYZ\\stu\\opr" "UpdateKBtoDL" "0" "HasAllLocalContent" "1" "UpToDate" "1" "DisableAutoUpdate" "0" } "20540" { "UpdateKBtoDL" "0" "InstallDir" "C:\\ABC\\def\\ghi"

How to extract a single file from a remote archive file?

青春壹個敷衍的年華 提交于 2019-11-28 08:33:18
Given URL of an archive (e.g. a zip file) Full name (including path) of a file inside that archive I'm looking for a way (preferably in Java) to create a local copy of that file, without downloading the entire archive first . From my (limited) understanding it should be possible, though I have no idea how to do that. I've been using TrueZip , since it seems to support a large variety of archive types, but I have doubts about its ability to work in such a way. Does anyone have any experience with that sort of thing? EDIT: being able to also do that with tarballs and zipped tarballs is also

How do I extract lines between two line delimiters in Perl?

孤人 提交于 2019-11-28 07:42:07
I have an ASCII log file with some content I would like to extract. I've never taken time to learn Perl properly, but I figure this is a good tool for this task. The file is structured like this: ... ... some garbage ... ... garbage START what i want is on different lines END ... ... more garbage ... next one START more stuff I want, again spread through multiple lines END ... more garbage So, I'm looking for a way to extract the lines between each START and END delimiter strings. How can I do this? So far, I've only found some examples on how to print a line with the START string, or other

Extract a ZIP file programmatically by DotNetZip library?

一笑奈何 提交于 2019-11-28 06:46:21
I have a function that get a ZIP file and extract it to a directory (I use DotNetZip library.) public void ExtractFileToDirectory(string zipFileName, string outputDirectory) { ZipFile zip = ZipFile.Read(zipFileName); Directory.CreateDirectory(outputDirectory); zip.ExtractAll(outputDirectory,ExtractExistingFileAction.OverwriteSilently); } My ZIP file contains multiple files and directories. But I want to extract only some of these files, not all of them. How can I make this work? Oded You need to test each ZipEntry to see if you want to extract it: public void ExtractFileToDirectory(string

Get min and max value in PHP Array

家住魔仙堡 提交于 2019-11-28 04:21:33
I have an array like this: array (0 => array ( 'id' => '20110209172713', 'Date' => '2011-02-09', 'Weight' => '200', ), 1 => array ( 'id' => '20110209172747', 'Date' => '2011-02-09', 'Weight' => '180', ), 2 => array ( 'id' => '20110209172827', 'Date' => '2011-02-09', 'Weight' => '175', ), 3 => array ( 'id' => '20110211204433', 'Date' => '2011-02-11', 'Weight' => '195', ), ) I need to extract minimal and maximal Weight values. In this example $min_value = 175 $max_value = 200 Any help on how to do this ? Thank you ! Option 1. First you map the array to get those numbers (and not the full details

Extract digit from numeric in r

∥☆過路亽.° 提交于 2019-11-28 04:12:12
问题 I would like to extract the first digit after a decimal place from a numeric vector in R. Is there a way to do this without turning it into a character string? For example: x <- c(1.0,1.1,1.2) I would like the function to return a vector: 0,1,2 thanks. 回答1: There'll be a bunch of ways, but here's one: (x %% 1)*10 # [1] 0 1 2 This assumes there's only ever one digit after the decimal place. If that's not the case: floor((x %% 1)*10) 来源: https://stackoverflow.com/questions/21868712/extract

ZipInputStream getNextEntry is null when extracting .zip files

时光怂恿深爱的人放手 提交于 2019-11-28 04:08:00
问题 I'm trying to extract .zip files and I'm using this code: String zipFile = Path + FileName; FileInputStream fin = new FileInputStream(zipFile); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { UnzipCounter++; if (ze.isDirectory()) { dirChecker(ze.getName()); } else { FileOutputStream fout = new FileOutputStream(Path + ze.getName()); while ((Unziplength = zin.read(Unzipbuffer)) > 0) { fout.write(Unzipbuffer, 0, Unziplength); } zin

Extract sub- and superdiagonal of a matrix in R

a 夏天 提交于 2019-11-28 03:32:06
问题 As the title implies, how does one extract the sub- and superdiagonal of a matrix? 回答1: Using diag . For the superdiagonal, you just discard the last row and first column. For the subdiagonal, discard first row, last column: m <- matrix(1:9,nrow=3) > m [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > diag(m) [1] 1 5 9 > diag(m[-nrow(m),-1]) [1] 4 8 > diag(m[-1,-ncol(m)]) [1] 2 6 回答2: You may need to reshape the results.... help(lower.tri) help(upper.tri) help(diag) upper.tri and lower.tri do