perl에서는 memcmp 같은 기능을 하는 함수가 없나요?

allwhites의 이미지

perl로 메모리에서 특정 문자열을 찾으려고 하는데

perl에서는 memcmp 같은 기능을 함수가 보이질 않네요!

따로 제공되는 함수는 없는건가요?

redneval의 이미지

질문이 명확하지가 않네요.

`어떤' 메모리에서 찾는 것인지 좀 더 설명해주세요.

일단, 윈도우즈에서 다른 프로세스의 메모리에 접근하는 경우라고 생각해보면

다음 모듈이 있습니다.

http://search.cpan.org/~qjzhou/Win32-Process-Memory-0.20/Memory.pm

--------------------Signature--------------------
Light a candle before cursing the darkness.

allwhites의 이미지

질문이 너무 간략했네요 ㅠㅠ

일단 사용하는 시스템은 리눅스상이고요.

특정 메모리 번지(예로, 0x00000000 ~ 0x11111111)에서부터 특정 문자열(test)을 찾는 작업을 하고 있습니다.

C에서 memcmp를 이용하는 경우에는 while(memcmp((void*)시작주소, "test", 4)) 주소++; 같은 코드를 이용할 수 있는데

perl에서는 대체할 수 있는 함수가 있는지 궁금합니다.

없으면 직접 만들어서 써야되겠네요..

redneval의 이미지

펄에서 로우레벨 작업을 하려면,

모듈에 적당한게 없는 경우

결국 C언어를 써야하는데, 그게 좀 복잡합니다.

http://www.perlmania.or.kr:8949/bbs/bbs.html?mode=read&table=lang&article=1373

C언어로 간단하게 프로그램 만들어 따로 컴파일해주고,

펄로 그 프로그램을 실행하는 편이 (성능에서 좀 손해보더라도) 편합니다.

--------------------Signature--------------------
Light a candle before cursing the darkness.

allwhites의 이미지

제목에 꼭 완료를 붙이고 싶었는데 안되겠네요 ㅠㅠ

알려주신거 참고해서 잘 해보겠습니다. 고맙습니다!!

aero의 이미지

Perl에서는 POSIX ( http://perldoc.perl.org/POSIX.html )
모듈에 각종 시스템콜 함수들을 제공하는데
문서를 보면 memcmp는

memcmp
memcmp() is C-specific, use eq instead, see perlop.

라고 설명되어 있네요 뭔가 위험성이 있어서 의도적으로 구현을 안한듯 합니다만.

Perl에서 C와 연동해서 작업을 하려면 XS라는 것을 통해서 하시든지

http://en.wikipedia.org/wiki/XS_(Perl)

Inline::C 모듈을 사용하시면 됩니다.

http://search.cpan.org/dist/Inline/C/C-Cookbook.pod

http://search.cpan.org/perldoc?Inline::C

아니면 FFI ( http://search.cpan.org/perldoc?FFI ) 같은 걸 쓰셔도 되고요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.