Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Seekers of Perl Wisdom

( #479=superdoc: print w/ replies, xml ) Need Help??

If you have a question on how to do something in Perl, or you need a Perl solution to an actual real-life problem, or you're unsure why something you've tried just isn't working... then this section is the place to ask. Post a new question!

However, you might consider asking in the chatterbox first (if you're a registered user). The response time tends to be quicker, and if it turns out that the problem/solutions are too much for the cb to handle, the kind monks will be sure to direct you here.

User Questions
File Upload On Windows 8 and Perl
5 direct replies — Read more / Contribute
by skosterow
on Jul 04, 2015 at 11:31

    Greetings!

    I'm having a heck of a time and Im not sure I'm not the idiot.

    Im using http://www.sitepoint.com/uploading-files-cgi-perl/ script EXACTLY as it is on a Windows 8 box.

    I see the file name upload into my upload directory BUT THERE IS NOT DATA IN IT :( In other words I see the file being created, the file name / file is there but the image is not! Its like its a blank .jpg file (or .gif)

    Anyone else having this Issue? ill post code but its EXACTLY like the one on the URL i submitted - Thank you Guys/Gals in advance for ANY help!

    Also - The directory rights are set - "Full Control" for the IUSER! So i KNOW thats not the issue - besides it creates the file but NO data grrrr! :)

Getting (famous) error during running perl script
6 direct replies — Read more / Contribute
by Kati
on Jul 04, 2015 at 06:23

    Hi all,

    I'm really new in this field, so my problem may be so basic for you, please accept my apologize in advance. I faced with the following error during running a perl script

    .
    Use of uninitialized value in concatenation (.) or string at sequence +_replacement.pl line 56, <TWO> line 48001. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48007. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48023. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48033. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48055. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48059. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48061. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48079. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48087. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48101. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48103. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48107. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48131. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48135. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48189. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48219. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48221. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48225. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48235. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48237. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48243. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48247. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48253. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48299. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48351. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48371. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48387. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48391. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48395. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48403. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48423. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48425. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48447. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48451. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48453. Use of uninitialized value in concatenation (.) or string at sequence_ +replacement.pl line 56, <TWO> line 48455.
    .

    The error was really large and sounds that it's for almost line, I put just small part of it. I would highly appreciate if you could please help me to solve the problem in a simple language

    .
Fetch Problem uri
2 direct replies — Read more / Contribute
by Anonymous Monk
on Jul 04, 2015 at 05:41

    hi monks

    I am having problems fetching files from some sort of URIs. I used LWP::UserAgent (same problem) but now I changed to File::Fetch as it seems to me quite suitable for my task. I came out with this:

    #!/usr/bin/perl use strict; use warnings; use File::Fetch; my $url=" http://www.ekey.net/downloads-475?download=2132cbe2-2fb1-eef +f-583c-50a39b6aba6c&name=v2_ITA_12-Seiter_Programm_1207_web.pdf"; print "Downloading $url\n"; my $ff = File::Fetch->new(uri => $url); my $where = $ff->fetch( to => "ekey corpus" ) or $ff->error;

    The file definitivly exists in that location. Compy and paste in Firefox and you get promped to download the file (Firefox knows the file names starts after the last "=").

    Any idea why this does no work?

error in copy folder recursively
3 direct replies — Read more / Contribute
by mrityunjaynath
on Jul 04, 2015 at 04:27

    i am trying to code a perl script in which one of my objectives is to copy a source folder(which contains files and sub folders) to a target folder. what i have written is as

    use strict; use warnings; use File::Copy; use File::Basename; use Cwd; use Data::Dumper; use File::Copy::Recursive; my $source_dirrtl = ("$newpath"."/rtl"); my $target_dirrtl1 = ("$newpath"."/rtl1"); mkdir($target_dirrtl1,0777); opendir(my $DIRRTL1, $source_dirrtl) || die "can't opendir $source_dir +rtl: $!"; my $cp = File::NCopy->new(recursive => 1); my $cp->copy("$source_dirrtl/*",$target_dirrtl1) or die "couldnt copy +$source_dirrtl to $target_dirrtl1);

    each time i run this a error comes saying

    Can't locate File/copy/recursive.pm in @INC <@INC contains C:/Perl/site/lib C:/Perl/lib .) at newperlfile2.pl line 9
    BEGIN failed--compilation aborted at newperlfile2.pl line 9
    please help as i am new to perl and struck in this error

Convert CSV file to XML file using Perl?
4 direct replies — Read more / Contribute
by laknarc
on Jul 03, 2015 at 21:10

    I have already posted this question as Anonymous monk. Please delete my previous thread. I have registered and created this question again. we have a CSV file which need be to converted to XML using Perl or Unix shell scripting. I was able to build this XML using SQL and Korn shell script. However, SQL/shell script is running for long time. Hence, I'm considering to write a Perl to generate this XML file. Basically need to build this XML hierarchically by avoiding the duplicate values. Please take a look into the CSV and XML file below. But the both SQL and Korn shell script takes 15 minutes to create the XML for just 6000 records. Please let me know if there is any other efficient way to process this CSV file. this CSV file contains total 20 million records. Need to build this XML file within 60 to 120 minutes. Appreciate your help. Input data below:-

    RLTP_ID,RLTP_NAME,PROD_ID,PROD_NAME,CUST_ID,CUST_NAME,ACC_ID,ACC_NAME, +ACC_BALANCE,TXN_ID,TXN_AMT,ACC_TYPE,ACC_CODE,TXN_CODE 10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,YY,11 10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,YY,12 10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,ZZ,11 10,Phil,1,Personal,2,Fixed,3,Savings,3000,4,500,X,ZZ,12 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,11 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,12 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,AA,13 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,11 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,12 10,Phil,1,Personal,2,Fixed,7,Savings,3000,8,500,X,BB,13

    Output XML

    <transactiondetails> <rltp_id>10</rltp_id> <rltp_name>Phil</rltp_name> <product> <prod_id>1</prod_id> <prod_name>Personal</prod_name> <customer> <cust_id>2</cust_id> <cust_name>Fixed</cust_name> <account> <acc_id>3</acc_id> <acc_name>Savings</acc_name> <acc_balance>3000</acc_balance> <acc_type>X</acc_type> <acc_code>ZZ</acc_code> <acc_code>YY</acc_code> <transaction> <txntrack> <txn_id>4</txn_id> <txn_amt>500</txn_amt> <txn_code>11</txn_code> <txn_code>12</txn_code> </txntrack> </transaction> <transaction> <txntrack> <txn_id>5</txn_id> <txn_amt>500</txn_amt> <txn_code/> </txntrack> </transaction> <transaction> <txntrack> <txn_id>6</txn_id> <txn_amt>500</txn_amt> <txn_code/> </txntrack> </transaction> </account> <account> <acc_id>7</acc_id> <acc_name>Savings</acc_name> <acc_balance>3000</acc_balance> <acc_type>X</acc_type> <acc_code>AA</acc_code> <acc_code>BB</acc_code> <transaction> <txntrack> <txn_id>8</txn_id> <txn_amt>500</txn_amt> <txn_code>11</txn_code> <txn_code>12</txn_code> <txn_code>13</txn_code> </txntrack> </transaction> </account> </customer> </product> </transactiondetails>
Stopping script execution from within the code like Python's pdb
4 direct replies — Read more / Contribute
by schrodinger
on Jul 03, 2015 at 09:23
    I am a newcomer to Perl from Python. I am trying to debug an API call's Perl code, which is run via uWSGI. Currently, I'm using logs and `say`s to debug my code, but ideally, I would like to invoke the debugger at arbitrary locations in the code. In Python, I can do,
    import pdb pdb.set_trace()
    And the debugger will be invoked, pausing the script at the location of the set_trace() call. I'm sure there's an equivalent in Perl, but I'm just not able to find it. Please help :)
Another one perl LWP quastion
3 direct replies — Read more / Contribute
by m4merg
on Jul 03, 2015 at 07:25

    Hi, Monks!

    I'm trying to use LWP::UserAgent to get content from URL. I've succeed, but after some time URL just banned my IP (at least i think that they did, because I could not access to site at all). So i decided to use proxy, but i still can't get to this URL. Here is the code im using for this:

    my $ua = new LWP::UserAgent; my $proxy = "http://112.137.164.232:3128"; $ua->proxy(['https'], $proxy); $ua->agent('Mozilla/5.0'); my $links = "http://sci-hub.org/"; my $req = new HTTP::Request GET => $links; my $stuff = $ua->request($req); print "Content-type: text/html\n\n"; print $stuff->content;

    Using this code i can get content from another URL (for ex. google.com), but cant get it from the desired one (sci-hub.org). Also i actually can get access to the desired URL through web browser using this proxy (though i can't without proxy as they banned me), but can't get it from perl script:

    Can't connect to sci-hub.org:80 (Connection timed out) LWP::Protocol::http::Socket: connect: Connection timed out at /usr/sha +re/perl5/LWP/Protocol/http.pm line 41

    So, proxy is correct in general and code is correct in general (at least i think so), but for the desired URL it doesnt work. So what is the problem?

    Sorry if I duplicate another topic, but i've searched for the solution of my problem hard (on this site also), used a lot of different ways and didnt find anything usefull at the end and thanks in advance for any help.

"Type mismatch" Error While Using Win32:OLE for MS Outlook
3 direct replies — Read more / Contribute
by dushyant
on Jul 03, 2015 at 03:30

    Hi Monks,

    I am tring to download email attachments from Microsoft Outlook using Win32::OLE. But I stuck at initial level I don't even able to get outlook folder list.
    Please find below code I am using and Error I got.

    I am using,
    32 bit Straberry Perl ( perl 5, version 20, subversion 1 (v5.20.1) built for MSWin32-x86-multi-thread-64int),
    OS (64 bit) = Windows 7 Enterprise Service Pack 1
    Microsoft Outlook 2013

    Error :

    D:\Perl_Project\OutLook>test1.pl
    Win32::OLE(0.1712) error 0x80020005: "Type mismatch" in METHOD/PROPERTYGET "GetDefaultFolder" argument 1 at D:\Perl_Project\OutLook\test1.pl line 9.
    Can't call method "Folders" on an undefined value at D:\Perl_Project\OutLook\test1.pl line 15.
    D:\Perl_Project\OutLook>perl -v

    #! D:\Straberry\perl\bin\perl -w use strict; use Win32::OLE qw/in/; #use Win32::OLE::Const 'Outlook.Application'; #use Win32::OLE::Variant; my $OL = Win32::OLE->GetActiveObject('Outlook.Application') || Win32:: +OLE->new('Outlook.Application') or die "$!\n";; my $NameSpace = $OL->GetNameSpace("MAPI"); my $Folder = $NameSpace->GetDefaultFolder("olFolderInbox"); #print ref($Folder->{Items}) . "\n"; foreach my $subfolder ( in $Folder->Folders) { printf "%s\n", $subfolder->{Name}; }

    Thanks.
Perl expect : send command executing multiple times
1 direct reply — Read more / Contribute
by ryalagikar
on Jul 03, 2015 at 03:11

    I am writing perl-expect script, in script am trying to login to remote machine then sudo su to another user and then execute two commands. Everything is working fine but the first command is executing multiple times.

    my $ssh = Net::OpenSSH->new("$user:password\@$host"); $ssh->error and die "Unable to connect $host " . $ssh->error; my ($pty,$pid) = $ssh->open2pty({stderr_to_stdout => 1}, 'sudo su - us +er1') or die "Failed to attempt"; my $expect = Expect->init($pty); $expect->log_file("expect.pm_log", "w"); my $result = $expect->expect(3, ["\[\r\n]?\[^\r\n]+\[%#>\$] \$" ,sub { shift->send("da +te\r"); exp_continue;}], [qr/Day/ , sub { my $self = shift; $self->send("touch +test.txt\r"); $self->soft_close();}] )or die "**** Failed ** ";

    Here 'date' command is executing multiple times(2...20times).

    Suggestions Please

missing values when using Parallel::ForkManager
1 direct reply — Read more / Contribute
by plagent
on Jul 03, 2015 at 01:51
    I used Parallel::ForkManager to scan the motifs in DNA string pairs. The script is the following:
    foreach my $id (1..100) { PWM: for my $pwm (@ciona_pwm_array) { $pm->start and next PWM; ($count) = count_pwm_num($pwm,$seq_1,$seq_2); $pm->finish; } $pm->wait_all_children; }
    There are three parameters for the function count_pwm_num. The first one is $pwm, which is from list @ciona_pwm_array and is the motif feature. The second and third are DNA strings. The function is to calculate the motif number (how many?)using motif feature $pwm in the DNA strings. The aim of the function count_pwm_num is to report the motif number from both strings. The following table is the report from the program. However, I calculated the same DNA strings 100 times ( the first for-loop) and used same motif list (@ciona_pwm_array, the second for-loop), there is always missed motif(s) in the report. For example, row a (first row), the program reported all six motif number from A-F. row b missed the number of the motif A (because they were same DNA strings, the output should keep the same). row c missed the number of motif B.row d missed the number for motif A and B. It seemed the missed motif numbers were randomly selected. So my question is: why count_pwm_num randomly skip some $pwm and do not perform the function of count_pwm_num?

    program result table:

    id	A	B	C	D	E	F
    a	1	1	0	1	1	0
    b		1	0	1	1	0
    c	1		0	1	1	0
    d			0	1	1	0
    e	1	1	0	1	1	0
    ..
    
    Expected result
    
    id	A	B	C	D	E	F
    a	1	1	0	1	1	0
    b	1	1	0	1	1	0
    c	1	1	0	1	1	0
    d	1	1	0	1	1	0
    e	1	1	0	1	1	0
    ..
    

Add your question
Title:
Your question:
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!
  • 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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (5)
    As of 2015-07-04 19:23 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (60 votes), past polls