Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

CP: the C programmer
me: I'm only thirty percent as arrogant as I come across.

$CP in $irc_network #Perl asked a question about matching files ending in '.xls'. I answered with a regex, and $CP messaged me privately.

  • -!- Irssi: Starting query in $irc_network with $CP
  • <$CP> Would you mind if I asked you a little more about the file extension?
  • <$me> you should normally direct such questions to the channel, but go ahead.
  • <$CP> Thank you, $me.
  • <$CP> Again, I'm not very familiar with Perl, so I hope I can relay my information accurately and concisely.
  • <$CP> A friend helped me write some of this, but I need to manipulate it just a little.
  • <$CP> I have this code that checks a folder for files... and it performs a specified function on that file.
  • <$CP> But now I want to get more precise and say if the file is a .xls.
  • <$CP> Would you mind if I pasted you a bit of code?
  • <$CP> It's about 5 lines.
  • <$me> Go ahead.
  • <$CP>         opendir(TARGET, $target);
  • <$CP> Interesting. I cannot paste so easily with Firefox's IRC client.
  • <$CP> opendir(TARGET, $target);
  • <$CP> while($file = readdir(TARGET))
  • <$CP> {
  • <$CP>      next if($file eq ".");
  • <$CP>      next if($file eq "..");
  • <$CP>      &process_new_file($file);
  • <$CP> }
  • <$CP> Pretty much that's the gist.
  • <$CP> But I'd like to process_new_file if the file has the extension .xls
  • <$CP> How can I do what you told me about $f if $f =~ /[.]xls$/
  • <$me> you're not a programmer at all, are you?
  • <$CP> Not with Perl.
  • <$me> replace all that with:
  • <$me> process_new_file $_ for <$target/*.xls>;
  • <$CP> I like C.
  • <$CP> Heh. :)
  • <$CP> Thank you, $me

In reply to A conversation with a C programmer by Anonymous Monk

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 surveying the Monastery: (2)
As of 2024-04-25 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found