Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I think you need to read our responses more carefully. Corion gave you most of the answer, and I helped you with the substitution, noting in my response: "...which you would apply line by line as you read through the file". If you don't understand what Corion wrote, then ask a specific question, but please don't just ignore the advice. As you seem to need a little more fundamental guidance, I'll say this: Perl will let you do what you want in many possible ways, but a basic approach to run your code in a file (your script.pl) from the Perl command line as you appear to have chosen, that code will have to:

  • open the input file (tip: check out the "null filehandle" in perlop)
  • read lines one by one,
  • apply the substitution regex you want, and
  • write the result somewhere. Your output could go to the console, pipe to a file, get written to a file you opened in your code, or you could even investigate Perl's handy feature for editing a file in place via the -i command line option (read up on this in perlrun).
All your code (and please do use code tags - see Writeup Formatting Tips just above the editing box when you're composing your message) does is apply a substitution to nothing and ends, so of course you get no result.

Quick tips on your regex modification: The colon has no special meaning so you need not put it in square brackets. Functionally there is no difference, but using unnecessary characters makes it harder for others to easily pick out what you mean to do. Also, unless you want to accept cases of more than one colon, don't put a + after the colon. Please read up on regular expressions; the + symbol is not used to assemble parts of a regex, it is a quantifier and means 'match one or more of the preceding element'.

--
I'd like to be able to assign to an luser


In reply to Re^3: Simple Text Manipulation by Albannach
in thread Simple Text Manipulation by pseingalt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 17:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found