Substitution regex
I want to substitute all white space that precedes the class [A-Za-z0-9_], with $. $string = "STRING sDir = sDrive"; $string =~ s/\s(?=[A-Za-z0-9_])/ \$/; It only matches one time and produces: STRING $sDir = sDrive; ...
I want to substitute all white space that precedes the class [A-Za-z0-9_], with $. $string = "STRING sDir = sDrive"; $string =~ s/\s(?=[A-Za-z0-9_])/ \$/; It only matches one time and produces: STRING $sDir = sDrive; ...
I am new to perl and I want to use screen input on my script. here is my script and I want the IOS command to be enter from keyboard. can some one show me where I am wrong.the problem i have now the script not read my keyboard input, I am not sure if work on my case. thanks!! # ### Show ################################################...
I've run Devel::Leak in my program and I don't understand the output it's giving me. To start, I see it's printing a list of pointers. Can I get that list in an array? Then I can use FindRef to see where it's coming from. For example: new 0xaebc28 : SV = PVGV(0x30e7e48) at 0xaebc28 REFCNT = 1 FLAGS = (GMG,SMG) IV = 0 NV = 0 ...
I am trying to find filesize using -s operator. I looks like this: my $filesz = -s $filename I tried lots of various way but it can not get this size. However, If I give static content instead of filename, it works fine For exa: $filesz = -s "/tmp/abc.txt" This works fine. I tried adding " in filename, it didn't work. I removed \n fr...
I am using XML::Twig to parse my input xml using Perl. I need to extact a particular node in this XML and validate that node to see if it has multiple <p> tags and then count words in those P tags. For example: <XML> <name> </name> <address> <p id="1">a b c d </p> <p id="2">y y y </p> </address> </XML> Output: Address has 2 para...
I have a cshell script that is something like this: `netstat -ap | & grep tcp | grep myprocess | awk '{print $4}' | awk 'BEGIN { FS = :"}{print $2}'` This is how it works 1. $ netstat -ap | & grep tcp | grep myprocess tcp 0 0 *:1234 *:* LISTEN 8888/myprocess 2. $ netstat -ap | & grep tcp | grep myprocess | ...
I wrote a Perl program which searches and manipulates one text file. This CGI process slurps the file directly into memory, manipulates the file based on the User's input, then generates the HTML result. It works functional wise. However, I know that once I deploy on high volume server, it will not be able to respond in due time. I sus...
I'm wondering, does -MO=Deparse show you all of the Perl optimizations, and why doesn't this get folded in Perl 5.10? $ perl -MO=Deparse -e'[qw/foo bar baz/]->[0]' ['foo', 'bar', 'baz']->[0]; -e syntax OK Some on IRC thought that O=Deparse might not be showing it all, but it certainly shows some constant folding. $ perl -MO=Deparse -...
Hi, I'm writing a script in perl strawberry. The first thing it needs to be able to do is take a path argument and get a directory listing for that path, and it needs to be able to distinguish between files and folders. I read some tutorials on the subject and wrote the script below, but it only works when I give it the path that the s...
I have one script i'm trying to call from another script, passing the information from the script that is being called to the calling script. When i use do or require it runs through but doesnt pass the value. ex. I have the following line at the bottom of the script that i am calling called script.pl print " $hold IS VALUE\n"; wh...
I just need to fetch an https page, and I'm using curl currently by having the curl.exe application in my Path and calling it with a Perl file. However, then I get the error "* Protocol https not supported or disabled in libcurl". I've been looking around and I can't find a solid set of instructions to get it to work. I have installed cy...
Pretty simple, I don't want an introduction that introduces me to the concepts of loops, arrays, etc. I want a book that "gets into" perl right off the bat and is up to date enough for me to follow the conventions of modern perl use. Format doesn't matter, book, pdf, online tutorial, etc. I'd also prefer for it to be short. I can get aro...
I need a way to read and delete text between two different strings found in some file, then delete the two strings. Like a "cut command." I would like to have the text stored in a variable. I saw the post about reading text between two strings, but I could not figure out how to delete it as well. I intend to execute the stored text i...
I'm working with a big, old, messy, bloated framework. It regularly goes well over 100 levels deep in subroutine calls. The Perl debugger sees fit to stop and inform me of this fact... over and over again. Package::Stash::name(/usr/local/perl/5.10.1/lib/site_perl/5.10.1/Package/Stash.pm:21): 21: return $_[0]->{package}; 100 levels...
I would like to have my scripts keep track of thier last date of revision internally as a comment. Is this possible? It seems to me that it would need to grab the date and then open its script file for an append, write the data and save the file. Thanks Everone, great answsers one and all. Based on the code snippet left by GreenMatt ...
I have written a small script in Perl which I am executing on Windows with ActivePerl as below: C:\Documents and Settings\Administrator> perl io.pl io.pl #!/usr/bin/perl use warnings; sub test6 { while (defined($_ = <>)) { #chomp($_); print $_; } } test6; As you can see, the code is similar to the Unix cat com...
I've seen perl statements that look like this: () unless $some_var; What is that intended to achieve? ...
How can I get support for jumping to Moose methods using Eclipse with the EPIC plugin? (Using F3) They're declared like class Point { method getDistance { ... } } ...
How can I get ctags to generate tags for MooseX::Declare methods, classes, attributes and such? ...
Hi, I have a package (really just one subroutine) I use frequently to parse config file etc. Basically it looks like this: sub get_settings { my %config; my $config = 'path...'; unless(-r $config) { die("Couldn't read config"); } open CONFIG, '<', $config or die $!; while(...