You don't explain in the tuturial what the trailing /i
does, hardly seems fair to quiz on it. There should be a
section detailing what /i or /g does trailing the reg expr.
I looked and found nothing about it.
| [reply] |
The trailing "i" means it ignores the case.
The "g" is the global replace option.
There's a good example of "i" in Learning Perl 2nd edition.
On page 11 and the program continues on page 12.
It's really helpful for making your programs dummy proof for users.
An example of "g" can be found on page 88 of the same book.
It is my bible although I have two other books I am using.
(a programming newbie can never have enough books)
I almost forgot to mention that issuing the command "perldoc perlop" (without the quotes) on most systems will give you detailed information on perl operators.
Perldoc is excellent! use "perldoc perldoc" to learn how to use it.
| [reply] |
Another really good book is Mastering Regular Expressions. Not only does it give easy to understand detailed and insightful information on regular expressions, it also suggests having a beer while your reading the book. ;-)
| [reply] |
My service for German language perl beginners ;-)
While Mastering Regular Expressions is available in translation you might
want to have a first short look at what RegEx can do for you in a short German article.
You can find that here: Reguläre Ausdrücke in Perl.
Hope this helps.
neophyte | [reply] |
even after reading the tutorial and the perlman:perlre page, i still don't understand why everywhere it is said to use s/// or m//, and every example use ~s/// or ~m// - i mean, i don't understand where this ~ comes from and what it means ...
| [reply] |
It's not ~s and ~m but =~. See perlop for details.rdfield
| [reply] |
Need Help!
How would I match a user input (password) to a database and halt the user is it does not match or allow the user in if it does. School project is hung up on this.
| [reply] |
I'm having a wicked time setting up a pattern for the following: I have a text doc that contains info like the following:
<space>
\\dir1\<return>
group\name1<return>
group\name2<return>
group\name3<return>
<space>
\\dir2\<return>
group\name4<return>
group\name5<return>
group\name6<return>
<space>
I need to go through the list and find the "group\name" I am searching for (using $search as a variable), dump all the info pertaining to where that group is to a file handle. For ex: If I am searching for "group\name5" , I want to return the following info:
\\dir2\<return>
group\name4<return>
group\name5<return>
group\name6<return>
I've setup a pattern that looks for /^\s+.*($search).*\s+$/ using the /si at the end for any case and including line returns, but it never matches anything up. What is the secret with the /s and multiple input lines? Thanks!
| [reply] |
In the Exercises the solution to number 1 has an error.
13: print $text; #write changes to file
should be
13: print FILE $text; #write changes to file
I did this one and the solution just prints to screen but leaves the file empty.
Lane | [reply] [d/l] |
Hi,
I have a doubt about this.
Lets take this scenario.
The Input data is as follows:
header
{
subheader1
{
field1 : value
field2 : value
field3: value
}
subheader2
{
subheader3
{
field4 : value
field5 : value
field6: value
}
subheader4
{
field7 : value
field8 : value
field9: value
}
}
}
header
{
subheader1
{
field1 : value1
field2 : value1
field3: value1
}
subheader2
{
subheader3
{
field4 : value1
field5 : value1
field6: value1
}
subheader4
{
field7 : value1
field8 : value1
field9: value1
}
}
}
The output will be :
field1,field2,field3,field4,field5,field6,field7,field8,field9
value,value,value,value,value,value,value,value,value
value1,value1,value1,value1,value1,value1,value1,value1,value1
Here main problem is that:
The value os field2 or field3 may be missing then the output may be:
field1,field2,field3,field4,field5,field6,field7,field8,field9
value,value,value,,value,value,value,value,value
value1,value1,value1,value1,value1,value1,,value1,value1
In the above output
The first line field4 is missing
and in the second line field7 is missing
How Can I get the output can you please help me. | [reply] |