Should I use $hash{"string"} or $hash{string} in Perl?
In Perl, which of these is the "better" style? $hash{"string"} or $hash{string}? In any case, are they functionality identical? ...
In Perl, which of these is the "better" style? $hash{"string"} or $hash{string}? In any case, are they functionality identical? ...
Is there a way to interface the Perl debugger API which perl is using to control its debugging programmatically? ...
I am new to the Perl and while doing with my new CR I stuck at the Perl code which is using Log4perl package. Already developed code is using this package and in the configuration file of this package has this configuration: log4perl.appender.Logfile.max = 2 log4perl.appender.Logfile.size = 10_000 log4perl.appender.Logfile = Log::Di...
For example, $thisMessage contains: <...> <request attribs="true" text="this is a message" ...>text here too</request> </...> The desired output should be, <...> <request attribs="true" msg="this is a message" ...>text here too</request> </...> The "text" enclosed within '<' and '>' must be replaced and the text not within '<' '>'...
Duplicate data removal using Perl called within via a batch file within Windows A DOS window in Windows called via a batch file. A batch file calls the Perl script which carries out the actions. I have the batch file. The code script I have works duplicate data is removal so long as the data file is not too big. The problem that requires...
I have inherited a 20-year-old interactive command-line unix application that is no longer supported by its vendor. We need to automate some tasks in this application. The most troublesome of these is creating thousands of new records with slightly different parameters (e.g. different identifiers, different names). The records have to ...
Can anyone please suggest me the meaning of below Perl regex: $_ =~ s/^([^,]+,)ab.([^,]+,)(?:[^,]+,)/$1$2/; What is the role of $1 and $2 and how these variables are defined? ...
Is there any method within Perl which would allow me to get the object in a read only mode, so as to avoid the dialog that pops up if the file is locked by another user? $document = Win32::OLE->GetObject("$docFile") or die "can't open $docFile"; ...
We are inserting values into a SQL Server 2005 database column of type NUMERIC(19,5) from Perl. As long as the absolute values are .0001 or greater, it is working. However, when the values go to the 5th decimal place, Perl starts storing them in exponential format (-9e-05 instead of -0.00009), and then we get the error "Error converting ...
I'm trying to use a [PerlSection][1] to get the server name and then use it to configure some RewriteCond-RewriteRule pairs and some other things. It seems I can't get very far. It says you can do this: Apache2->httpd_conf("PerlPassEnv $key $val"); But trying to start Apache I get this syntax error: "Can't locate object method "htt...
I need to write a script to show me all the alias I've set in certain config files like .tcshrc and some private script in case that I forget the meaning of alias like "a" , "b" , etc . the format of the aliases in the config file is either alias a "content of alias a" or alias b 'content of alias b' . the code I wrote is as below : ...
I need to check whether a file in a user's home directory exists so use file check: if ( -e "~/foo.txt" ) { print "yes, it exists!" ; } Even though there is a file called foo.txt under the user's home directory, Perl always complains that there is no such file or directory. When I replace "~" with /home/jimmy (let's say the user is...
I have a string: $mystring = "My cat likes to eat tomatoes."; I want to do two replacements on this string with regex. I want to do s/cat/dog/ and s/tomatoes/pasta/. However, I don't know how to properly format the regular expression to do the multiple replacements in one expression, on one line, in one declaration. Right now, all I h...
I want to have output of Windows command-line program (say, powercfg -l) written into a file which is created using Perl and then read the file line by line in a for loop and assign it to a string. ...
I have a growing list of regular expressions that I am using to parse through log files searching for "interesting" error and debug statements. I'm currently breaking them into 5 buckets, with most of them falling into 3 large buckets. I have over 140 of patterns so far, and the list is continuing to grow. Most of the regular express...
I just want to read multiple lines in a file. For example in sample.txt "Hi, how are you?" "Hello I'm fine, thank you!" Now my problem is how can I read the second statement without removing the newline in the sentence? EDIT: It seems that my questions are not clear. So I think I should edit this: In my examples above, I need to...
I've got two questions about the Perl open command: 1) I seem to remember from Perl Best Practices that the 3 argument version of open is better than the two argument version, e.g. open(OUT, '>>', $file); vs. open(OUT, ">>$file"); Why is that? I was trying to tell somebody to use the 3 argument version the other day but couldn't s...
I currently use the following Perl to check if a variable is defined and contains text. I have to check defined first to avoid an 'uninitialized value' warning: if (defined $name && length $name > 0) { # do something with $name } Is there a better (presumably more concise) way to write this? ...
What modules should I look at for doing multithreading in Perl? I'm looking to do something fairly low performance; I want threads is to run multiple workers simultaneously, with each of them sleeping for varying amounts of time. ...
I'm trying to send a packet via Perl, I sniffed the traffic of the packet I want to send and the packet from wireshark is: 0000 00 19 e0 98 17 e8 00 1a 92 41 32 13 08 00 45 00 ........ .A2...E. 0010 00 a7 03 56 40 00 80 06 7f 5d c0 a8 01 64 5e 67 ...V@... .]...d^g 0020 57 2a ea a8 08 be 41 03 2a a1 5e 12 bf 5f 50 18 W*....A....