Re: Regex behavior in command line

2012-06-07 Thread Jon Forsyth
I overlooked the missing single quotes, Thanks! -Jon

Regex behavior in command line

2012-05-31 Thread Jon Forsyth
Hello, I'm using the following line in Terminal, on OSX Lion, but I can't seem to match parentheses '()': perl -n -e 'print if(/\\(Submit\\)/)' visits/admin_add.ctp I tried with one backslash in front of each '(' ')' as well to no avail. If I remove the '\'s and '()' the match is printed like s

Getting text from an XML file using XML::Twig

2011-12-03 Thread Jon Forsyth
Dear Beginners List, My code is based on an example from the XML::Twig documentation. I want to capture the text of a couple elements that have descendant elements and put this text in separate variables (one for each element's text). The problem in the code example is that all the text of the l

Perl Regex with unix grep command

2011-09-03 Thread Jon Forsyth
Hello, According to the grep manual page I can use the -P option to use Perl regular expressions as follows: grep -P PERL_REGEX INPUT_FILE however, I cannot get the following pattern to match a literal dollar sign: grep -P makan\$ file.txt when I know this pattern is in the file. It matches

Word Frequency Script

2011-06-08 Thread Jon Forsyth
Hello Perl community, I am trying to get a simple program working that will count the words in a text file and put them in a hash with the key being the word and the value being its frequency in the text file. Here is my code: --- #!/usr/bin/perl use strict; use warnings; { open IN, "; forea

Syntax of Foreach loop

2010-03-30 Thread Jon Forsyth
I am truly a beginner. Could someone help me understand this syntax out of a code example from "Learning Perl"? On line 5 I'm confused as to why "my $number" is between "foreach" and the ()? is "my $number part of the loop? sub running_sum { state $sum = 0; state @numbers; foreach my $

Set Restriction/Requirement for

2010-02-20 Thread Jon Forsyth
Hello, How can I set a requirement for (e.g. require the to continue running the program)? Thanks, Jon