Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

output of dumper

by Anonymous Monk
on Mar 23, 2004 at 16:44 UTC ( [id://339211]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to regex issue

Edit by tye: Moved this previous version of the question from SoPW into this new thread.


hi monks , I get this output
ER 34 9YT 44 EE 66
I need to do somthing like this
my $ER = 34; my $9YT = 44; my $EE = 66;
thanks

Replies are listed 'Best First'.
Re: output of dumper
by hardburn (Abbot) on Mar 23, 2004 at 16:49 UTC

    What have you tried so far?

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated

Re: output of dumper
by tcf22 (Priest) on Mar 23, 2004 at 17:27 UTC
    First off $9YT isn't a valid valiable name. Variables can start with letters and underscores only. Using Data::Dumper should get almost what you want. There are no my's and i'm not sure how to get them, or if it is even possible with Data::Dumper.
    use strict; use warnings; use Data::Dumper; my $ER = 34; my $YT = 44; my $EE = 66; print Data::Dumper->Dump([$ER, $YT, $EE], [qw(ER YT EE)]); __OUTPUT__ $ER = 34; $YT = 44; $EE = 66;

    - Tom

      First off $9YT isn't a valid valiable name

      It is if you do enough tricks.

      $ perl -MData::Dumper -le '$f = "9YT"; $$f = "foo"; print Data::Dumper +::Dumper(\%main::)' $VAR1 = { # snip '9YT' => *{'::9YT'}, # snip };

      With symbol table lookups and symbolic refs, pretty much anything is possible in a Perl variable name. I don't know of a way to get lexicals to do this, though.

      ----
      : () { :|:& };:

      Note: All code is untested, unless otherwise stated

Re: output of dumper
by DamnDirtyApe (Curate) on Mar 25, 2004 at 00:44 UTC

    This seems like what you want:

    #! /usr/bin/perl use strict; use warnings; use Data::Dumper; my $str; do { local $/; $str = <DATA>; }; my $hash = { split /\s+/, $str }; print Dumper $hash; __DATA__ ER 34 9YT 44 EE 66

    _______________
    DamnDirtyApe
    Those who know that they are profound strive for clarity. Those who
    would like to seem profound to the crowd strive for obscurity.
                --Friedrich Nietzsche

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://339211]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.