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
Moose arrayref addition: noob
1 direct reply — Read more / Contribute
by jorba
on Oct 20, 2017 at 17:09
    Trying to get my head around moose and running into a problem. Cut down version of code
    package AXRecord; # Our libraries use lib 'C:\Users\Jay\Desktop\SBS DEV\CODE\perl\Utilities'; use AXControl; use AXSQL; use Moose; use DBI; # Attributes has 'Keys' => (is => 'rw', isa=>'ArrayRef'); # Contains a single record sub BUILD # Constructor { } sub Select { #Get the primary key fields $self->Keys (()); $sql = AXSQL->new(ControlObject => $self->ControlObject, SQLString + => "SELECT column_name FROM information_schema.`key_column_usage` WH +ERE table_name = '" . $self->Name . "' order by ordinal_position"); $i = 1; while (($Col) = $sql->Fetch()) { $self->Keys()->[$i] = $Col; $i++; } $Cnt = scalar $self->Fields; $self->FieldCount = $Cnt; $self->Changed = -1; } 1;
    Problem is in the select method where I try to build the keys array. Specifically where I'm adding elements with the statements
    $self->Keys()->[$i] = $Col;
    The error message I'm getting is

    Can't use an undefined value as an ARRAY reference at C:\Users\Jay\Desktop\SBS DEV\CODE\perl\Utilities/AXRecord.pm line 106. C:\Users\Jay\Desktop\SBS DEV\CODE\perl>

Advice: Async Options for fire-and-forget subroutine
2 direct replies — Read more / Contribute
by mwb613
on Oct 20, 2017 at 14:51

    Thanks in advance for looking.

    I took a look back through earlier questions and saw some helpful results but some of them were older and some didn't quite match my use case. I am writing a Perl module for a piece of software called OpenSIPs (a SIP server), the module itself does some message de-construction and re-construction that's not easy to do in the OpenSIPs config file itself. I have also been extended it to logging certain messages and statistics and right now my solution for that is Redis PUB/SUB. This is working fine but it is adding some latency that is not really necessary considering it is a non-essential function of the SIP transaction.

    What I would like to do is, rather than wait for the Redis transaction to complete (sometimes in the range of 20-30 ms depending on where the Redis server is), just run the Redis PUB/SUB command asynchronously and not worry about the reply or even wait to get the acknowledgment in my main script. I've seen a few modules mentioned in earlier conversations here: threads, AnyEvent, Async, etc and also some non modular solutions like backticks, etc. What I'm looking for is the simplest, most lightweight way to call a Perl subroutine (passing it some info -- a JSON encoded string) and not worry about the response or whether it is successful. I'd appreciate any advice anyone is willing to give.

    Thanks!

Escaping Apostrophe
3 direct replies — Read more / Contribute
by perl_gvenk
on Oct 20, 2017 at 09:42

    I have a situation where I'm looping through to generate a SQL statement to update a table. Wha'ts happening though is The site name has an apostrophe in the value and the perl script throws an error at that point.

    SQL = UPDATE LIR_BUT_SITE SET ROW_IDENTIFIER = '4' , M_CUSTOMER_ABBREV = 'IBHW' , M_SITE_KEY = 'R_LIR_BUT_SITE-' , RESP_CENTER = 'Global Custom Svcs GCSC' , M_SITE_NAME = 'MZ3481-CHILDREN'S HOSPITAL WALTHAM'
    Here is the piece of code that generates the SQL
    for $idx (0..$#hdr) { if ($row[$idx] ne "") { if ($found ne "N") { $updstmt .= ", "; $insstmt .= ", "; $valstmt .= ", "; } $found = "Y"; $updstmt .= $hdr[$idx]." = '".$row[$idx]."' \ +r\n";

    The values for the update are generated by the $row$idx.How do I put that $row$idx within double quotes or how do i make the perl interpreter escape any apostrophes in that field. Can some one suggest a solution?

    Thanks.
Exception handling
2 direct replies — Read more / Contribute
by Anonymous Monk
on Oct 20, 2017 at 03:33

    my script logs in to console of router and clear all the user (console) lines. When it encounters the current line, it comes out of the script. Is there a way to handle this situation, more precisely, when it encounters current line, it should not clear and it should go to the next line which is used by somebody else

    ######################### sub clear_line { ######################### print "router name? "; my $r = <STDIN>; chomp($r); print "term? "; my $terms = <STDIN>; chomp($terms); my $values; my @test_array; my @data_set = ( JT->new( host => $r ), ); foreach my $rh (@data_set) { for (my $term = $terms; $term <=40; $term++) { $rh->cmd("request system logout terminal pts/$term"); } } }

    Logs below

    [shell]$ ./ft_generic_bk.pl router name? abc term? 1 Oct 20 00:21:07 [INFO ] [abc] JT::Device::connect: abc is connected vi +a /volume/labtools/bin/nicetelnet pid 16210 Oct 20 00:21:09 [INFO ] [abc] [cmd] cat /usr/share/cevo/cevo_version Oct 20 00:21:10 [INFO ] [abc] [cmd] request system logout terminal pts +/1 Oct 20 00:21:12 [INFO ] [abc] [cmd] request system logout terminal pts +/2 Oct 20 00:21:14 [INFO ] [abc] [cmd] request system logout terminal pts +/3 Oct 20 00:21:16 [INFO ] [abc] [cmd] request system logout terminal pts +/4 Oct 20 00:21:17 [INFO ] [abc] [cmd] request system logout terminal pts +/5 Oct 20 00:21:17 [INFO ] [abc] [cmd] request system logout terminal pts +/6 Oct 20 00:21:18 [INFO ] [abc] [cmd] request system logout terminal pts +/7 Oct 20 00:21:18 [INFO ] [abc] [cmd] request system logout terminal pts +/8 Oct 20 00:21:19 [INFO ] [abc] [cmd] request system logout terminal pts +/9 Oct 20 00:21:20 [INFO ] [abc] [cmd] request system logout terminal pts +/10 Oct 20 00:21:21 [INFO ] [abc] [cmd] request system logout terminal pts +/11 Oct 20 00:21:22 [INFO ] [abc] [cmd] request system logout terminal pts +/12 Oct 20 00:21:23 [INFO ] [abc] [cmd] request system logout terminal pts +/13 Oct 20 00:21:24 [INFO ] [abc] [cmd] request system logout terminal pts +/14 Oct 20 00:21:25 [INFO ] [abc] [cmd] request system logout terminal pts +/15 Oct 20 00:21:26 [INFO ] [abc] [cmd] request system logout terminal pts +/16 Oct 20 00:21:27 [INFO ] [abc] [cmd] request system logout terminal pts +/17 Oct 20 00:21:28 [INFO ] [abc] [cmd] request system logout terminal pts +/18 Oct 20 00:21:29 [WARN ] [abc] Device response :Connection closed by fo +reign host. Oct 20 00:21:29 JT.pm:2877 [ERROR] [abc] JT::Device::_send: Expect rep +orted 3:Child PID 16210 exited with status 256 JT::error_handler HARD at /volume/labtools/lib/JT/Device.pm li +ne 2867, <STDIN> line 2. JT::Device::_send('JT::JUNOS=HASH(0xf0867c4)', 'cmd', 'request + system logout terminal pts/18', 'timeout', 60, 'timeout_ok', 0, 'slo +w', 0, ...) called at /volume/labtools/lib/JT/JUNOS.pm line 2106 JT::JUNOS::cmd('CMD', 'request system logout terminal pts/18') + called at ./ft_generic_bk.pl line 1912 ft_generic_tc::clear_line() called at ./ft_generic_bk.pl line +2417 JT: die ./ft_generic_bk.pl with exit code 18 CONNECT_LOST

    Line 18 is used by my script and it disconnects and i should avoid it. Is there a way to avoid my line and go to the next line ?

How can one extract a name using perl?
1 direct reply — Read more / Contribute
by supriyoch_2008
on Oct 20, 2017 at 01:06

    Hi Perlmonks,

    I am interested in extracting the name of genes from a NCBI Genbank file using accession number. Say, the accession number is NC_025572. When the accession number is used as a query in Nucleotide database of NCBI (https://www.ncbi.nlm.nih.gov/), it opens up a Genbank file with the title "Petrolisthes haswelli complete mitochondrial genome, isolate Mar55". In this file, the word CDS is repeated several times with a link and followed by information like <1..1534 /gene="COX1" or 1605..2289 /gene="COX2" or 2423..2773 /gene="ND3" etc. I have come across some perl codes from google search to extract the name from Genbank file. I have given the script below. It gives only the main title i.e. "Petrolisthes haswelli complete mitochondrial genome, isolate Mar55" and not the individual gene name like COX1 or COX2 or ND3. The digits prior to each gene name indicate position of sequence like 1..1534 or 1605..2289 or 2423..2773, respectively. I seek suggestions from perlmonks how to extract the gene name and its corresponding sequence for each gene. The output may look like:

    >NC_025572 Gene COX1 ACGAAACGATGATTTTTTTCAACTAACCATAAGGATATTGGAACTTTATACTTTATTTTTGGAGCTTGAT CGGGTATAGTAGGCACTACACTCAGATTAATTATTCGAACAGAACTCGGTCAGCCAGGTAGATTAATTGG AGATGATCAGATTTATAATGTTGTTGTTACCGCCCACGCTTTCGTTATAATTTTTTTTATAGTTATACCA ATCATAATTGGAGGATTTGGCAATTGACTAGTTCCTTTAATACTAGGAGCCCCTGATATAGCCTTTCCTC GAATGAATAACATAAGATTTTGACTCCTACCTCCCTCGCTCACCCTACTTCTAATAAGAGGGATAGTTGA AAGAGGAGTTGGTACTGGATGAACTGTCTACCCACCTCTATCAGCAGGTATTGCCCACGCAGGAGCATCA GTTGATATAGGAATCTTTTCTCTCCATCTTGCAGGTGTTTCTTCTATTTTAGGAGCAGTTAACTTTATAA CTACTGTTATTAATATACGACCCTCAGGAATGACTATAGACCGTATGCCATTATTTGTTTGGGCCGTATT TATTACAGCTATTTTACTTTTATTATCTTTACCTGTTTTAGCAGGAGCCATCACAATACTTTTAACAGAT CGTAATTTAAATACTTCCTTTTTTGACCCTGCTGGAGGAGGAGACCCTATTCTTTATCAACATCTTTTTT GATTTTTTGGTCACCCCGAGGTTTATATTCTTATTCTTCCCGCATTTGGTATAATTTCACACATCGTAAG TCAAGAATCAGGAAAAAAAGAGTCTTTTGGAACATTAGGTATGATTTACGCAATATTGGCTATTGGTATC TTAGGTTTTATCGTTTGAGCACACCACATATTCACCGTTGGTATAGACGTTGATACACGAGCTTATTTTA CATCAGCCACAATAATTATTGCCATCCCCACTGGAATTAAAATTTTCAGATGACTAGGAACGCTTCAAGG AAACCAAATGAATTACAGACCTTCTATAGTCTGAGCTCTAGGTTTTATTTTTCTCTTTACAGTTGGAGGC TTGACTGGTGTTATTTTAGCTAACTCTTCTATTGATACCGTACTACATGACACTTATTATGTAGTAGCTC ACTTTCATTATGTTCTTTCAATAGGAGCTGTCTTCGGAATTTTTGCTGGTATTGCCCATTGATTTCCTCT ATTTACTGGTGTTTCTACTAATCCTAAATGACTAAAAATCCATTTTTCAGTAATATTCCTAGGGGTAAAC TTAACTTTCTTTCCTCAACACTTCCTTGGATTAAATGGAATACCTCGACGTTATTCTGATTATCCTGACG CTTATACCCCATGAAACGTTTTATCTTCCGTTGGATCTTTAGTTTCTTTATGCGCAGTTATTGGTTTCAT CTTTATTGTATGAGAAGCTCTAATTTCTTCACGACCTGTCTTATTTACCCTTTCTCAACCTACATCGATT GAATGAAAACATCCTTATCCGCCCGCTGATCACAGATATATAGAAATTCCTATTCTTTCTAATT >NC_025572 Gene COX2 ATGGCAACATGAGGTTCACTTGGTTTTCAAGATAGAGCATCTCCTTTAATGGAGCACCTTATTTACTTCC ACGATCACGCGATAATTGTCCTTACCTTGATTACAGCCTTCGTGGGCTATATAATAATTTCCCTTTTACC AAACACTTTTACAAATCGATTCCTTTTAGAAAATCAAAAGATTGAAATCATTTGAACTATTATCCCAGCT TTCATTTTAGTTTTTATTGCTCTCCCCTCATTACGGCTTCTTTACCTTCTTGATGAAGTCAACAATCCAA GAATTACTTTAAAAACCGTTGGCCATCAATGGTACTGGTCTTATGAATACTCCGATTTTCATCAAATTGA ATTTGACTCTTATATAATCCAACCAAGAGATTCAGTAGACTCAACATTCCGTCTCATTGACGTTGACAAT CGAGCAGTTTTACCAATAAATTCTCAAATTCGTGTACTAATTAGAGCCGCTGATGTAATTCATTCTTGAA CCGTACCTGCTCTAGGAGTTAAAGCTGATGCTATCCCAGGCCGATTAAATCAAGTAAGATTCATAATTAA CCGCCCAGGTTTATTTTTCGGTCAATGTTCTGAAATTTGCGGAGCTAATCACAGGTTTATACCTATTGTT ATCGAAAGTGTTTCACTTGATTGTTTTCTAAAATGAGTGTCATCACAAGAAGAAT

    Here goes the code:

    #!/usr/bin/perl use warnings; use strict; use Bio::DB::GenBank; use Bio::SeqIO; use Text::Wrap; my $gb= new Bio::DB::GenBank; my $acc="NC_025572"; my $seq1 = $gb->get_Seq_by_acc($acc); my $desc=$seq1->desc(); print "\n $desc\n"; exit;

    I have got the following output from the script. It does not show name of individual gene.

    Microsoft Windows [Version 6.1.7600] Copyright (c) 2009 Microsoft Corporation. All rights reserved. C:\Users\x>cd d* C:\Users\x\Desktop>k.pl Petrolisthes haswelli complete mitochondrial genome, isolate Mar55. C:\Users\x\Desktop>

    I welcome suggestions from perlmonks to sort out this problem.

Getting unique line counts between lines starting with '>'
1 direct reply — Read more / Contribute
by james.v
on Oct 19, 2017 at 17:23

    Hi all,

    I am trying to alter this script:

     perl -lne '/>/ && do {print $c if defined $c; $c = 0; print} || $c++; END {print $c}' input_file > output_file

    In order to make the output counts for only unique lines that are between lines starting with '>'

    Currently this script works well in generating overall counts of the lines that are between lines that begin with '>'

    Example input_file:
    >05143_African_trypanosomiasis TRINITY_DN26760_c1_g1 18169 42987 42987 >05145_Toxoplasmosis 43736 38319 38320 38320 TRINITY_DN24151_c3_g1 TRINITY_DN25493_c0_g1
    Example of output_file:
    >05143_African_trypanosomiasis 4 >05145_Toxoplasmosis 6
    Example of desired output:
    >05143_African_trypanosomiasis 3 >05145_Toxoplasmosis 5

    I'm also very new to perl so an explanation of the tweaked code would be much appreciated.

    -James

Integer regex, different results in windows and mac - I just need regex help
6 direct replies — Read more / Contribute
by hiyesthanks
on Oct 18, 2017 at 22:42
    When I test the code in windows, I get the results im looking for (https://imgur.com/a/59SKl). But when I test it on mac, I get different results (https://imgur.com/a/ZJMEg) in the positive and negative integers. Whats wrong with my regex?
    #!/usr/bin/perl # The program calculates the total zeros and positive intergers from t +he data using regex use strict; use warnings; my ( $ctrP, $ctrN, $ctrZ ) = ( 0, 0, 0 ); while( my $num = <DATA> ) { chomp($num); ## print "num=[$num]\n"; if ( $num =~ /^[0].{0}/ ) { $ctrZ++; } elsif ( $num =~ /^\d[0-9]{1,3}$/ ) { $ctrP++; } else { $ctrN++; } } printf("freq(Z+):%8s\n", $ctrP ); printf("freq(Z-):%8s\n", $ctrN ); printf("freq(0):%9s\n", $ctrZ ); printf("Total:%11s\n", ($ctrP+$ctrN+$ctrZ) ); exit; __DATA__ 19 -22 498 512 15 -932 0 22 808 17 -32
Using negative lookahead
5 direct replies — Read more / Contribute
by ibm1620
on Oct 18, 2017 at 21:14
    I want to create a regex that will identify a string surrounded by quotes, and remove the quotes. If the quote symbol appears within the string, the match should fail. The quotes can be either ' or ". Eventually they might be multi-character strings (e.g. ''). I'm not concerned at this point about recognizing escaped embedded quotes. This is slightly contrived .. I mostly want to understand why a negative lookahead isn't working the way I thought it would.

    I sure would appreciate being shown what I'm misunderstanding.

    #!/usr/bin/env perl use warnings; use strict; my @cases = ( q{'abc"def'}, q{'abc'}, q{"abc"}, q{''}, q{'abc'def'}, # Want this to fail matching q{'This shouldn't match'}, # Want this to fail matching q{"This isn't a problem"}, q{"abc}, q{abc"}, q{abc}, q{'abc"}, q{'ab''}, # Want this to fail matching ); strip_quotes($_) for @cases; # If we can remove a matching pair of single or double quotes from # a string, without the quote symbol also appearing within the string, # do so. Otherwise don't change the string. sub strip_quotes { my $line = shift; print "\n$line\n"; # NO NEGATIVE LOOKAHEAD # This works except it allows an embedded delimiter if ( $line =~ m{^ # anchor ( # capture delimiter in pos 1 ["'] # delim is single or double quote ) (.*) # anything \g1$}x # finally, the delim ) { print " 1- Got a match: delimiter was {$1}, body was {$2}\n"; } else { print " 1- No match.\n"; } # ATTEMPTING NEGATIVE LOOKAHEAD # This should fail if the delimiter is found in non-terminal pos. if ( $line =~ m{^ # anchor ( # capture delimiter in pos 1 ["'] # delim is single or double quote ) (.*(?!\g1)) # neg lookahead for delim \g1$}x # finally, the delim ) { print " 2- Got a match: delimiter was {$1}, body was {$2}\n"; } else { print " 2- No match.\n"; } }
    Result:
    'abc"def' 1- Got a match: delimiter was {'}, body was {abc"def} 2- No match. 'abc' 1- Got a match: delimiter was {'}, body was {abc} 2- No match. "abc" 1- Got a match: delimiter was {"}, body was {abc} 2- No match. '' 1- Got a match: delimiter was {'}, body was {} 2- No match. 'abc'def' 1- Got a match: delimiter was {'}, body was {abc'def} 2- No match. 'This shouldn't match' 1- Got a match: delimiter was {'}, body was {This shouldn't match} 2- No match. "This isn't a problem" 1- Got a match: delimiter was {"}, body was {This isn't a problem} 2- No match. "abc 1- No match. 2- No match. abc" 1- No match. 2- No match. abc 1- No match. 2- No match. 'abc" 1- No match. 2- No match. 'ab'' 1- Got a match: delimiter was {'}, body was {ab'} 2- No match.
Help with Web Scraping Script - Updated
3 direct replies — Read more / Contribute
by EagerforPerl
on Oct 18, 2017 at 20:44
    use strict; use warnings; use LWP::Simple; use File::Compare; use File::Copy; $| = 1; sub main { #Create a file with current content, compare with all present file +s in directory if same, delete, if not, keep. unless(-e('filesaves') or mkdir('filesaves')) { die("Directory Couldn't Be Created.\n"); } #create directory if it does not already exist my $fileName; print("Enter Site Directory: "); #Test input: http://caveofprogram +ming.com #Gather site URL with directory my $siteDirectory = <STDIN>; print("Number of Times to Run: "); #Test input: 10 my $runAmount = <STDIN>; #Gather the number of times to check the web address unless(opendir(DIR, 'C:\\Program Files\\OSNE')) { die("Unable to open directory 'C:\\Program Files\\OSNE'\n"); } for(my $i = 0; $i <= $runAmount; $i++) { my $file = readdir(DIR); closedir(DIR); $file = grep(/\.txt$/i, $file); #Filter as to only look for .t +xt files my $searchTable = get($siteDirectory); #Get HTML code from web +site if(defined($searchTable)) { $fileName = localtime() . '.txt'; #Set file name to the ti +me it will be created $fileName =~ s/:/-/g; #remove the disallowed characters an +d replace them so that it can be the file name open(my $outputFile, '>', $fileName) or die("Couldn't Crea +te File.\n"); while($searchTable =~ m|<\s*a\s+[^>]*href\s*=\s*['"]([^>"' +]+)['"][^>]*>\s*([^<>]*)</|sig) { #HTML code title filter regex print $outputFile ("$2: $1\n"); #print the titles to t +he text file } if(compare($fileName, $file) == 0) { close($outputFile); #close output unlink($fileName); #delete file } else { close($outputFile); move("C:\\Program Files\\OSNE\\'$file'","C:\\Program F +iles\\OSNE\\filesaves\\'$file'"); #Move the old file to filesave folder +and keep the new file in the same directory as the script print("Change Detected.\n"); } } else { print("URL Unaccessible: $siteDirectory\n"); } } } main();

    I'm new to Perl, and I am trying to make a program that reads a sites html(specifically the titles) continuously as long as the user has specified and compares it with the other scan of the website by comparing files. If the file is the same as the other, delete the newer file. If the file is different, move the old file into the filesaves folder and keep the newer file in the same directory as the script. The program runs, but doesn't create the amount of files specified by the for loop, doesn't move them to the correct file, and doesn't delete them. For example, if you specify the number of times to run as 10, then you will only have 7 text files. Console Log: readdir() attempted on invalid dirhandle DIR at C:\Program Files\OSNE\OSNE.pl line 23, <STDIN> line 2. closedir() attempted on invalid dirhandle DIR at C:\Program Files\OSNE\CPMonitor.pl line 23, <STDIN> line 2. Use of uninitialized value $_ in pattern match (m//) at C:\Program Files\OSNE\CPMonitor.pl line 24, <STDIN> line 2. Change Detected.

Clearing a hash reference
2 direct replies — Read more / Contribute
by jorba
on Oct 18, 2017 at 19:22
    so, creating a moose class to represent a single record from a db table. The class has a property "Fields" which is a hash which stores the name of each field along with the value of the field in the record being represented.

    When the class loads the record, it needs to clear this hash reference, so it can load the "new" record. Being a "property" of the moose class, Fields is a hash ref, not a hash. Getting an error when I try to clear the hash reference before repopulating.

    specific line with the problem is

    $self->Fields = 0;

    in the select method.

    package AXRecord; # Our libraries use lib 'C:\Users\Jay\Desktop\SBS DEV\CODE\perl\Utilities'; use AXControl; use AXSQL; use Moose; use DBI; # Attributes has 'Name' => (is => 'rw', isa => 'Str', required => 1); has 'Fields' => (is => 'rw', isa => 'HashRef'); has 'FieldCount' => (is => 'rw', isa => 'Num'); has 'Changed' => (is=>'rw', isa => 'Boolean'); has 'Where' => (is => 'rw', isa => 'Str'); has 'ControlObject' => (is => 'rw', isa => 'Object', required => 1); has 'Keys' => (is => 'rw', isa=>'Array'); has 'Populated' => (is => 'rw', isa => 'Boolean'); # Contains a single record sub BUILD # Constructor { my $self; $self = shift; if (defined $self->Where) { $self->Select(); } else { $self->Populated = 0; } } # Insert the record sub Insert { } #Delete using the keys in the record sub Delete { } #Update using the keys and values in the record sub Update { } #Save the record sub Save { } sub Select { my ($SQLStr, $Cnt, $sql, @Values, $self, $Col, @Flds, $i); $self = shift; $SQLStr = "SELECT * FROM " . $self->Name . ' ' . $self->Where; print "Record.pm \t $SQLStr\n"; $sql = AXSQL->new(ControlObject => $self->ControlObject, SQLString + => $SQLStr); #construct a hash using the metadata and the data from the actual +table $self->Fields = 0; @Values = $sql->Fetch(); if ($sql->Rowcount >= 1) { $self->Populated = 1; } else { $self->Populated = 0; } #Get field Names $sql = AXSQL->new(ControlObject => $self->ControlObject, SQLString + => "show fields from '" . $self->Name . "'"); @Flds = $sql->fetch(); # Construct the hash for ($i..$#Flds) { if ($self->Populate == 0) { $self->Fields->{$Flds[$i]} = $Values[$i]; } Else { $self->Fields->{$Flds[$i]} = ' '; } } #Get the primary key fields $self->Keys = (); $sql = AXSQL->new(ControlObject => $self->ControlObject, SQLString + => "SELECT column_name FROM information_schema.`key_column_usage` WH +ERE table_name = '" . $self->name . "' order by ordinal_position"); while (($Col) = $sql.fetch()) { push $self->Keys, $Col; } $Cnt = $self->Fields; $self->FieldCount = $Cnt; $self->Changed = -1; } 1;
    Error message is

    C:\Users\Jay\Desktop\SBS DEV\CODE\perl>perl -w CollectEmail.pl Record.pm SELECT * FROM customer WHERE NAME = 'Testing' RowCount 1 Can't modify non-lvalue subroutine call at C:\Users\Jay\Desktop\SBS DEV\CODE\per l\Utilities/AXRecord.pm line 73. C:\Users\Jay\Desktop\SBS DEV\CODE\perl>


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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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 all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (3)
    As of 2017-10-20 22:00 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My fridge is mostly full of:

















      Results (268 votes). Check out past polls.

      Notices?