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

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#! Perl -w ## ## #shortcuts.pl -shortcut maintaining engine# ## ## use strict; use Text::xSV; my $shortcut_file = 'scuts'; #Define file that contains shortcuts my $output_file = 'sfile'; #Define file for output ########END OF USER INPUT######## my($sf,$of)=($shortcut_file,$output_file); sub set_shortcut { my $is_taken=0; print "Which shortcut character would you like (1 letter!)? (will +appear in brackets) "; chomp(my $char=<STDIN>); print "What text do you want it to print?\n"; chomp(my $text=<STDIN>); my $csv = new Text::xSV; $csv->open_file("$sf"); $csv->bind_header(); while ($csv->get_row()) { my ($shortcut) = $csv->extract(qw(shortcut)); if ($char eq $shortcut) { warn "Shortcut character already used!"; $is_taken=1; last; } } unless ($is_taken) { open(SF, ">>$sf"); print SF "$char,$text\n"; close(SF); } } sub get_shortcuts { print"\n"; my $csv = new Text::xSV; $csv->open_file("$sf"); $csv->bind_header(); while ($csv->get_row()) { my ($shortcut, $output) = $csv->extract(qw(shortcut output)); print "\{$shortcut\} produces $output\n"; } } sub new_doc { print "Type your note/doc (type {e} on a new line to end):\n"; open(OF, ">>$of"); while (my $line = <STDIN>) { last if $line =~ /\{e\}/; my %shortcuts; my $csv = new Text::xSV; $csv->open_file("$sf"); $csv->bind_header(); while ($csv->get_row()) { my ($shortcut, $output) = $csv->extract(qw(shortcut output +)); $shortcuts{$shortcut} = $output; } $line =~ s/\{(\w)\}+/$shortcuts{$1}/g; print OF $line; } close(OF); } sub get_doc { open(OF, "<$of"); while (<OF>) { print; } close(OF); } unless (-s $sf) { open(SF, ">>$sf"); print SF "shortcut,output\n"; close(SF); } print "Welcome to S.S.E. \{Steven's Shortcut Engine\}\n"; print "\t{s} to set a shortcut\n\t{o} to view the output file's conten +ts\n\t{n} to start typing to the output file\n\t{g} to view the short +cuts you've already made\n"; while(1) { print "\%> "; chomp(my $choice=<STDIN>); if ($choice =~ /\{s\}/) { set_shortcut(); } elsif ($choice =~ /\{n\}/) { new_doc(); } elsif ($choice =~ /\{g\}/) { get_shortcuts(); } elsif ($choice =~ /\{o\}/) { get_doc(); } }

In reply to Shortcuts engine for note taking by munchie

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (3)
    As of 2014-10-26 03:25 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (150 votes), past polls