Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: extracting words with certain characters

by space_monk (Chaplain)
on Dec 04, 2012 at 10:44 UTC ( #1007056=note: print w/replies, xml ) Need Help??

in reply to extracting words with certain characters

Update: Just had to make a correction for multiple matches on one line...

perl -ne 'while (/(\w*_\w*)/g) { print "$1\n";}' code_file(s)

You may want to change the regex to accept only names with a leading alpha character, or so it must contain at least one alpha character, or save the names into a hash to remove duplicates, so YMMV from what I've produced here...

Mapping into a hash using:

perl -ne 'BEGIN { my %hash; }; END { print map { "$_\n"} keys %hash} while (/(\w*_\w*)/g) { $hash{$1}=1};' code_file(s)

Gives all the unique names, e.g.

no_wait ZERO_TABLE_SIZE subpart_name segment_config __END__ skip_table_list rnc_dspp_dspresu range_end dry_run gp_partition_drop keep_empty ignore_table_list get_lock FULL_DATE_FORMAT get_summarised_days log_init tv_interval get_partition_row_count drop_agg_level table_name total_table_size keep_summarised summarisation_log DATE_FORMAT get_config MAX_CACHE_TIME lock_table skip_tables GPM_BIN day_count drop_daily_agg_level lock_attempt get_dbh get_drop_partition_list agg_level lock_type schema_name _ site_perl empty_only partition_name range_start drop_partition keep_unclassified time_zone pm_nsn_3g_ran row_count GPI_RECOVER_BACKLOG
A Monk aims to give answers to those who have none, and to learn from those who know more.

Replies are listed 'Best First'.
Re^2: extracting words with certain characters
by rjt (Deacon) on Dec 04, 2012 at 11:28 UTC

    In progress...

    perl -ne '/([A-Za-z_]+)/ && print "$1\n";' code_file(s)

    Just had to be first, didn't we? :-)

      Not really ; its a slow work day and I was bored, so I kept changing the answer.... :-P
      A Monk aims to give answers to those who have none, and to learn from those who know more.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007056]
[james28909]: i have thught about this and though about it lol
[james28909]: also remember, that if 'Today' is may 1, then Yesterday is not may 31 lol
[james28909]: theoretically speaking ofcourse
[james28909]: so if you subtracting as you loop, be aware that you will eventually be subtracting into a past month, or year <.<
[james28909]: dontcha love it!
[james28909]: Today would be scalar localtime. Yesterday would be scalar localtime - 1. sunday - monday would variate scalar localtime - ?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2017-04-29 03:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.